[MPlayer-dev-eng] [PATCH 2/4] String handling audit/cleanup

Nico Sabbi nsabbi at email.it
Sat Mar 3 17:26:46 CET 2007


Nicholas Kain wrote:

> On 3/3/07, Nico Sabbi <nicola_sabbi at fastwebnet.it> wrote:
>
>> > @@ -868,7 +869,7 @@ static int open_s(stream_t *stream,int m
>> >          int i;
>> >          char buf[33];
>> >          for (i = 0; i < 16; i ++)
>> > -          sprintf(buf+2*i, "%02X", discid[i]);
>> > +          snprintf(buf+2*i, sizeof buf - ((buf+2*i)-buf), "%02X",
>> > discid[i]);
>> >          mp_msg(MSGT_IDENTIFY, MSGL_V, "ID_DVD_DISC_ID=%s\n", buf);
>> >        }
>> >      }
>> >
>> > looks too horrendous to read (not that stream_dvd.c looks nice 
>> overall,
>> > very old-team style)
>
>
> Agreed.  The attached patch is much clearer.


yes, but this is much better

Index: stream_dvd.c
===================================================================
--- stream_dvd.c        (revisione 22422)
+++ stream_dvd.c        (copia locale)
@@ -867,10 +867,10 @@
       if (DVDDiscID(dvd, discid) >= 0)
       {
         int i;
-        char buf[33];
+        mp_msg(MSGT_IDENTIFY, MSGL_V, "ID_DVD_DISC_ID=");
         for (i = 0; i < 16; i ++)
-          sprintf(buf+2*i, "%02X", discid[i]);
-        mp_msg(MSGT_IDENTIFY, MSGL_V, "ID_DVD_DISC_ID=%s\n", buf);
+          mp_msg(MSGT_IDENTIFY, MSGL_V, "%02X", discid[i]);
+        mp_msg(MSGT_IDENTIFY, MSGL_V, "\n");
       }
     }
     /**




More information about the MPlayer-dev-eng mailing list