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

John Baldwin jhb at freebsd.org
Tue Oct 26 18:38:41 UTC 2010


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).

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

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.

-- 
John Baldwin


More information about the freebsd-hackers mailing list