[MPlayer-dev-eng] [PATCH] -identify DVD titles
The Wanderer
inverseparadox at comcast.net
Wed Sep 21 14:52:16 CEST 2005
Oded Shimon wrote:
> On Wed, Sep 21, 2005 at 12:57:14PM +0200, Aurelien Jacobs wrote:
>
>> On Tue, 20 Sep 2005 23:57:04 -0400 Rich Felker <dalias at aerifal.cx>
>> wrote:
>>> Try this:
>>>
>>> char buf[17];
>>> for(i=0;i<16;i++) sprintf(buf+2*i, "%02X", discid[i]);
>>> mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_DVD_DISC_ID=%s\n", buf);
>>>
>>> Simple, readable, no possibility of endian problems or
>>> portability issues.
>>
>> But a nice buffer overflow ;-)
>> This should probably be:
>> char buf[33];
>
> Whats the buffer for to begin with, just mp_msg directly...
I wondered that myself at first. My guess is that it's there to avoid
the overhead (and comparative complexity) of multiple mp_msg calls - one
before the loop to print "ID_DVD_DISC_ID=", one per character while in
the loop, and one after the loop to print the newline. Not really a huge
performance issue, most likely, but I personally think that the code
with the buffer is cleaner-looking (and, hence, less ugly) than what
would seem to be necessary to avoid it. (And, unrelated to the issue at
hand, unlike the previous two versions I can actually understand this
code without much effort...)
--
The Wanderer
Warning: Simply because I argue an issue does not mean I agree with any
side of it.
Secrecy is the beginning of tyranny.
More information about the MPlayer-dev-eng
mailing list