[FFmpeg-devel] [PATCH] Set frame rate on v4l2 devices

Måns Rullgård mans
Mon Sep 13 14:24:46 CEST 2010

jose.goncalves at inov.pt writes:

> Quoting M?ns Rullg?rd <mans at mansr.com>:
>>> First, initializing a struct with {0} instead of using a memset(). I
>>> always use memset() because gcc gives a warning of "missing
>>> initializer" in the other way if you activate the '-Wextra' option.
>> Don't do that then.  The C standard makes it quite clear that missing
>> elements in an initialiser are implicitly zero.  Just do it.
> I assumed that when using the options "-std=c99 -Wextra" gcc would
> only give me warnings for not complying with the C standard. It seems
> I'm wrong. Nevertheless, I quickly take a look to the C99 standard,
> section 6.7.8, and that is not so clear to me.

Which part of the following paragraph do you find unclear?

  If there are fewer initializers in a brace-enclosed list than there
  are elements or members of an aggregate, or fewer characters in a
  string literal used to initialize an array of known size than there
  are elements in the array, the remainder of the aggregate shall be
  initialized implicitly the same as objects that have static storage

>>> Second, testing ioctl error against -1 instead of negative. As rule of
>>> thumb I test for a function error as the negation of returning
>>> OK. Most ioctls return 0 for OK, but some return a positive value,
>>> hence testing for negative.
>> The ioctl() definition says it returns -1 on error.  Therefore,
>> testing for -1 is correct and testing for negative is not.  The same
>> goes for most system calls.  This is a very common mistake but a
>> mistake nonetheless.
> Hum... I tend to disagree. The definition also says that OK is 0 or a
> positive value. So it's better to assume that values not explicitly
> indicated (all negative, except -1) are an error. But, this is a minor
> thing, the important is to add the missing functionality to
> ffmpeg... here goes the corrected patch.

Actually, in this particular case, the ioctl() return value is
expected to be zero, so treating any non-zero value as an error is
probably the best course of action.  In general, the meaning of the
return value is defined by specific request.  The only value reserved
as an error code is -1, all others can be valid return values from the
requested operation.

M?ns Rullg?rd
mans at mansr.com

More information about the ffmpeg-devel mailing list