[ovs-dev] [PATCH] util: New ovs_retval_to_string() function.

Ben Pfaff blp at nicira.com
Sun Jan 30 21:30:43 UTC 2011


On Sun, Jan 30, 2011 at 11:37 AM, Andrew Evans <aevans at nicira.com> wrote:
> +    if (!retval) {
> +        return "";
> +    }
> +    if (retval > 0) {
> +        return strerror(retval);
> +    }
> +    switch (retval) {
> +    case EOF:
> +        return "End of file";
> +    default:
> +        return "***unknown error***";
> +    }

This is an odd combination of 'if' and 'switch' statements.  I would
rather have it written entirely as 'if...else' statement.  Also, in the
"unknown error" case I would prefer to see a sprintf of a message that
includes the error number to a static buffer.  This would generally
indicate a bug in our code, but having the number at hand would give
us a better ability to debug the problem.  (It's quite likely, for example,
that it's a negative errno value.)

Otherwise this looks fine to me.  Thank you!




More information about the dev mailing list