[FFmpeg-devel] [PATCH] Implement the function cmdutils.c:parse_int_or_die

D. Hugh Redelmeier hugh
Sun Feb 17 17:27:23 CET 2008

| From: Stefano Sabatini <stefano.sabatini-lala at poste.it>

| as in $subject, relevant thread:
| http://thread.gmane.org/alpine.LRH.1.00.0802150032240.23194 at redclaw.mimosa.com

There is one bug that I noticed in reading your patch:  errno MIGHT be
set to ERANGE due to a previous library call.  Before calling strtol,
the code should initialize errno to zero.

This is explained in the NOTES section of the strtol manpage on my

Your first patch also replaced a bunch of atoi calls with calls to
parse_int_or_die.  I hope you submit a patch to do that too.

I still like the idea of a context parameter to parse_int_or_die (or
to another similar function).  At least most of the atoi call sites in
parse_int_or_die did seem to know enough to specify a context (for
example, "left crop size").

At least eight of these call sites check for and reject negative
numbers.  This suggests that a parse_nat_or_die would pay for itself
by factoring out those checks for negative numbers.  Without a context
argument, the diagnostic would be worse than the current one.


More information about the ffmpeg-devel mailing list