[FFmpeg-devel] [PATCH] RPL demuxer

Måns Rullgård mans
Sat Nov 3 02:19:43 CET 2007


Rich Felker <dalias at aerifal.cx> writes:

> On Sat, Nov 03, 2007 at 12:56:42AM +0100, Michael Niedermayer wrote:
>> On Sat, Nov 03, 2007 at 12:04:01AM +0100, Aurelien Jacobs wrote:
>> [...]
>> > > +	rpl->author = b;
>> > > +
>> > > +	i++;
>> > > +
>> > > +	sscanf(buffer + so[i], "%i", &rpl->video_format);
>> > > +
>> > > +	i++;
>> > > +
>> > > +	sscanf(buffer + so[i], "%i", &rpl->video_width);
>> > 
>> > All those i++ lines and empty lines make the code much longer than needed.
>> > I would prefer seeing something like:
>> > 
>> > +	sscanf(buffer + so[i++], "%i", &rpl->video_format);
>> > +	sscanf(buffer + so[i++], "%i", &rpl->video_width);
>> 
>> even better would be IMHO:
>> rpl->video_format= atoi(buffer + so[i++]);
>> rpl->video_width = atoi(buffer + so[i++]);
>
> Functionality is not the same. sscanf with %i will read 010 as 8 while
> atoi will read 010 as 10. Also %i will interpret 0x1 as 1 while atoi
> will interpret it as a 0 followed by junk. Behavior matching %i can be
> obtained by using strtol with 0 for the base argument, but I wonder
> which is actually the correct behavior here and if anyone's even
> thought about it...

Whichever parsing is correct, using atoi() or strtol() rather than
sscanf() should certainly be preferred.

-- 
M?ns Rullg?rd
mans at mansr.com




More information about the ffmpeg-devel mailing list