[PATCH] mfiutil(8) - capture errors and percolate up to caller

Garrett Cooper yanegomi at gmail.com
Tue Oct 26 18:52:19 UTC 2010


On Tue, Oct 26, 2010 at 11:38 AM, John Baldwin <jhb at freebsd.org> wrote:
> On Tuesday, October 26, 2010 2:09:53 pm Garrett Cooper wrote:
>>     Because a number of places in the mfiutil(8) code immediately call
>> warn(3) after an error to an API occurred, and because warn(3) employs
>> printf, et all (multiple times) in libc, there's an off-chance that
>> the errno value can get stomped on by the warn(3) calls, which could
>> lead to confusing results from anyone depending on the value being
>> returned from the mfiutil APIs. Thus, the attached patch I'm providing
>> fixes those cases, as well as converts an existing internal API
>> (display_pending_firmware) to an non-void return mechanism. I also
>> made a few stack variable alignment changes to match style(9) as well
>> as got rid of the ad hoc powerof2 call in favor of the value in
>> sys/param.h.
>>     I've run a small number of unit tests on my desktop at home with
>> my mfi(4) card, but will test out other failing cases with equipment I
>> have access to at work.
>
> Just a few nits:
>
> 1) The include of <sys/param.h> should replace <sys/types.h> (there's a note
> about these two headers in style(9), FYI).

Done -- thanks for pointing me to that :).

> 2) patrol_get_props() should return 'error' on failure rather than 'errno'.

Good catch -- fixed!

> 3) mfi_get_time() failing isn't fatal.  The code already handles this case by
> not printing out a 'next run time' if at is zero.  I think you can remove the
> check for at == 0.  If all the other commands work and just that command fails
> I don't think it should be fatal.

Ok -- removed the at == 0 check.

Thanks!
-Garrett
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mfiutil-capture-errno-values.patch
Type: text/x-patch
Size: 27584 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20101026/559f0fa6/mfiutil-capture-errno-values.bin


More information about the freebsd-hackers mailing list