Re: [AD] Re: CVS: allegro/src/dos gripjoy.c,1.9,1.10 sndscape.c,1.8,1.9

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Saturday 03 July 2004 08:08, Peter Wang wrote:
> ... but there's no need to get silly with this kind of thing.  The 
> strcpy() call was perfectly safe.  Now it's unreadable.

I agree that strcpy() was safe in that case. I do feel that it's good 
practice to use strncpy() instead though...
(not that I always do, but anyway).

> Please use sizeof where appropriate.

Agreed. The attached patch changes static buffer sizes to buffer sizes 
specified by sizeof().

Evert
Index: src/beos/bjoyapi.cpp
===================================================================
RCS file: /cvsroot/alleg/allegro/src/beos/bjoyapi.cpp,v
retrieving revision 1.6
diff -u -p -r1.6 bjoyapi.cpp
--- src/beos/bjoyapi.cpp	2 Jul 2004 16:25:41 -0000	1.6
+++ src/beos/bjoyapi.cpp	3 Jul 2004 09:43:20 -0000
@@ -75,7 +75,7 @@ extern "C" int be_joy_init(void)
    }
    be_joy->GetControllerName(temp);
    name = temp->LockBuffer(0);
-   _al_sane_strncpy(desc, name, 30);
+   _al_sane_strncpy(desc, name, sizeof(desc));
    temp->UnlockBuffer();
    joystick_beos.desc = desc;
 
@@ -98,12 +98,12 @@ extern "C" int be_joy_init(void)
          joy[i].stick[0].name = name_stick;
          be_joy->GetAxisNameAt(0, temp);
          name = temp->LockBuffer(0);
-         _al_sane_strncpy(name_x, name, 10);
+         _al_sane_strncpy(name_x, name, sizeof(name_x));
          temp->UnlockBuffer();
          joy[i].stick[0].axis[0].name = name_x;
          be_joy->GetAxisNameAt(1, temp);
          name = temp->LockBuffer(0);
-         _al_sane_strncpy(name_y, name, 10);
+         _al_sane_strncpy(name_y, name, sizeof(name_y));
          temp->UnlockBuffer();
          joy[i].stick[0].axis[1].name = name_y;
          
Index: src/dos/gripjoy.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/dos/gripjoy.c,v
retrieving revision 1.10
diff -u -p -r1.10 gripjoy.c
--- src/dos/gripjoy.c	2 Jul 2004 16:25:41 -0000	1.10
+++ src/dos/gripjoy.c	3 Jul 2004 09:43:22 -0000
@@ -288,7 +288,7 @@ static int grip_init()
 	    stick_class[i][stick] = GRIP_CLASS_AXIS;
 
 	    /* name stick... :( */
-	    _al_sane_strncpy(tmpstr, "Stick", 1287);
+	    _al_sane_strncpy(tmpstr, "Stick", sizeof(tmpstr));
 	    if (joy[i].num_sticks > 1) {
 	       tmpstr[strlen(tmpstr)+2] = '\0';
 	       tmpstr[strlen(tmpstr)+1] = '1'+stick;
@@ -302,7 +302,7 @@ static int grip_init()
 	    joy[i].stick[stick].num_axis = ((stick*2) == last_axis) ? 1 : 2;
 	    _GrGetControlName(slot_index[i], GRIP_CLASS_AXIS, stick*2, tmpstr);
 	    if (tmpstr[0] == '\0')
-	       _al_sane_strncpy(tmpstr, "X", 1287);
+	       _al_sane_strncpy(tmpstr, "X", sizeof(tmpstr));
 
 	    SIMPLIFY_AXIS(tmpstr);
 
@@ -314,7 +314,7 @@ static int grip_init()
 	    if (joy[i].stick[stick].num_axis == 2) {
 	       _GrGetControlName(slot_index[i], GRIP_CLASS_AXIS, stick*2 + 1, tmpstr);
 	       if (tmpstr[0] == '\0')
-		  _al_sane_strncpy(tmpstr, "Y", 1287);
+		  _al_sane_strncpy(tmpstr, "Y", sizeof(tmpstr));
 
 	       SIMPLIFY_AXIS(tmpstr);
 
@@ -348,7 +348,7 @@ static int grip_init()
 	    stick_class[i][stick] = GRIP_CLASS_ANALOG;
 
 	    /* name pad... :( */
-	    _al_sane_strncpy(tmpstr, "Analog", 1287);
+	    _al_sane_strncpy(tmpstr, "Analog", sizeof(tmpstr));
 	    if (num_pads > 1) {
 	       tmpstr[strlen(tmpstr)+2] = '\0';
 	       tmpstr[strlen(tmpstr)+1] = '1'+stick-analog_start;
@@ -362,7 +362,7 @@ static int grip_init()
 	    joy[i].stick[stick].num_axis = 2;
 	    _GrGetControlName(slot_index[i], GRIP_CLASS_ANALOG, (stick-analog_start)*2, tmpstr);
 	    if (tmpstr[0] == '\0')
-	       _al_sane_strncpy(tmpstr, "X", 1287);
+	       _al_sane_strncpy(tmpstr, "X", sizeof(tmpstr));
 
 	    SIMPLIFY_AXIS(tmpstr);
 
@@ -373,7 +373,7 @@ static int grip_init()
 
 	    _GrGetControlName(slot_index[i], GRIP_CLASS_ANALOG, (stick-analog_start)*2 + 1, tmpstr);
 	    if (tmpstr[0] == '\0')
-	       _al_sane_strncpy(tmpstr, "Y", 1287);
+	       _al_sane_strncpy(tmpstr, "Y", sizeof(tmpstr));
 
 	    SIMPLIFY_AXIS(tmpstr);
 
@@ -406,7 +406,7 @@ static int grip_init()
 	    stick_class[i][stick] = GRIP_CLASS_POV_HAT;
 
 	    /* name hat... :( */
-	    _al_sane_strncpy(tmpstr, "Hat", 1287);
+	    _al_sane_strncpy(tmpstr, "Hat", sizeof(tmpstr));
 	    if (num_hats > 1) {
 	       tmpstr[strlen(tmpstr)+2] = '\0';
 	       tmpstr[strlen(tmpstr)+1] = '1'+stick-pov_start;
@@ -420,7 +420,7 @@ static int grip_init()
 	    joy[i].stick[stick].num_axis = 2;
 	    _GrGetControlName(slot_index[i], GRIP_CLASS_POV_HAT, (stick-pov_start)*2, tmpstr);
 	    if (tmpstr[0] == '\0')
-	       _al_sane_strncpy(tmpstr, "X", 1287);
+	       _al_sane_strncpy(tmpstr, "X", sizeof(tmpstr));
 
 	    SIMPLIFY_AXIS(tmpstr);
 
@@ -431,7 +431,7 @@ static int grip_init()
 
 	    _GrGetControlName(slot_index[i], GRIP_CLASS_POV_HAT, (stick-pov_start)*2 + 1, tmpstr);
 	    if (tmpstr[0] == '\0')
-	       _al_sane_strncpy(tmpstr, "Y", 1287);
+	       _al_sane_strncpy(tmpstr, "Y", sizeof(tmpstr));
 
 	    SIMPLIFY_AXIS(tmpstr);
 
@@ -499,7 +499,7 @@ static int grip_init()
 	    joy[i].stick[stick].num_axis = last_axis;
 
 	    /* name throttle... */
-	    _al_sane_strncpy(tmpstr, "Throttle", 1287);
+	    _al_sane_strncpy(tmpstr, "Throttle", sizeof(tmpstr));
 	    if (num_throt_sticks > 1) {
 	       tmpstr[strlen(tmpstr)+2] = '\0';
 	       tmpstr[strlen(tmpstr)+1] = '1'+stick-throttle_start;
@@ -512,7 +512,7 @@ static int grip_init()
 	       /* name axis */
 	       _GrGetControlName(slot_index[i], GRIP_CLASS_THROTTLE, throttle_count, tmpstr);
 	       if (tmpstr[0] == '\0')
-		  _al_sane_strncpy(tmpstr, "Throttle", 1287);
+		  _al_sane_strncpy(tmpstr, "Throttle", sizeof(tmpstr));
 
 	       joy[i].stick[stick].axis[a].name = get_config_text(tmpstr);
 	       joy[i].stick[stick].axis[a].pos = 0;
@@ -540,7 +540,7 @@ static int grip_init()
 	 for (b=0; b<joy[i].num_buttons; b++) {
 	    _GrGetControlName(slot_index[i], GRIP_CLASS_BUTTON, b, tmpstr);
 	    if (tmpstr[0] == '\0')
-	       _al_sane_strncpy(tmpstr, name_b[b], 1287);
+	       _al_sane_strncpy(tmpstr, name_b[b], sizeof(tmpstr));
 	    joy[i].button[b].name = get_config_text(tmpstr);
 	    joy[i].button[b].b = 0;
 	 }
Index: src/dos/sndscape.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/dos/sndscape.c,v
retrieving revision 1.9
diff -u -p -r1.9 sndscape.c
--- src/dos/sndscape.c	2 Jul 2004 16:25:41 -0000	1.9
+++ src/dos/sndscape.c	3 Jul 2004 09:43:22 -0000
@@ -375,7 +375,7 @@ static int get_ini_config_entry(char *en
    char *p;
 
    /* make a local copy of the entry, upper-case it */
-   _al_sane_strncpy(tokstr, entry, 33);
+   _al_sane_strncpy(tokstr, entry, sizeof(tokstr));
    strupr(tokstr);
 
    /* rewind the file and try to find it... */
@@ -433,18 +433,18 @@ static int get_init_config(void)
    if (!(ep = getenv("SNDSCAPE")))
       return FALSE;
 
-   _al_sane_strncpy(str, ep, 78);
+   _al_sane_strncpy(str, ep, sizeof(str));
 
    if (str[strlen(str)-1] == '\\')
       str[strlen(str)-1] = 0;
 
-   strncat(str, "\\SNDSCAPE.INI", 78-1);
+   strncat(str, "\\SNDSCAPE.INI", sizeof(str)-1);
 
    if (!(fp = fopen(str, "r")))
       return FALSE;
 
    /* read all of the necessary config info ... */
-   if (get_ini_config_entry("Product", str, 78, fp)) {
+   if (get_ini_config_entry("Product", str, sizeof(str), fp)) {
       fclose(fp);
       return FALSE;
    }
@@ -456,21 +456,21 @@ static int get_init_config(void)
    else
       soundscape_irqset = ss_irqs;
 
-   if (get_ini_config_entry("Port", str, 78, fp)) {
+   if (get_ini_config_entry("Port", str, sizeof(str), fp)) {
       fclose(fp);
       return FALSE;
    }
 
    soundscape_baseport = strtol(str, NULL, 16);
 
-   if (get_ini_config_entry("WavePort", str, 78, fp)) {
+   if (get_ini_config_entry("WavePort", str, sizeof(str), fp)) {
       fclose(fp);
       return FALSE;
    }
 
    soundscape_waveport = strtol(str, NULL, 16);
 
-   if (get_ini_config_entry("IRQ", str, 78, fp)) {
+   if (get_ini_config_entry("IRQ", str, sizeof(str), fp)) {
       fclose(fp);
       return FALSE;
    }
@@ -480,7 +480,7 @@ static int get_init_config(void)
    if (soundscape_midiirq == 2)
       soundscape_midiirq = 9;
 
-   if (get_ini_config_entry("SBIRQ", str, 78, fp)) {
+   if (get_ini_config_entry("SBIRQ", str, sizeof(str), fp)) {
       fclose(fp);
       return FALSE;
    }
@@ -490,7 +490,7 @@ static int get_init_config(void)
    if (soundscape_waveirq == 2)
       soundscape_waveirq = 9;
 
-   if (get_ini_config_entry("DMA", str, 78, fp)) {
+   if (get_ini_config_entry("DMA", str, sizeof(str), fp)) {
       fclose(fp);
       return FALSE;
    }
Index: src/macosx/qzmouse.m
===================================================================
RCS file: /cvsroot/alleg/allegro/src/macosx/qzmouse.m,v
retrieving revision 1.10
diff -u -p -r1.10 qzmouse.m
--- src/macosx/qzmouse.m	2 Jul 2004 16:25:41 -0000	1.10
+++ src/macosx/qzmouse.m	3 Jul 2004 09:43:22 -0000
@@ -122,13 +122,13 @@ static int osx_mouse_init(void)
          }
          if (buttons > max_buttons) {
             max_buttons = buttons;
-	    _al_sane_strncpy(driver_desc, "", 256);
+	    _al_sane_strncpy(driver_desc, "", sizeof(driver_desc));
             if (device[i].manufacturer) {
-	       strncat(driver_desc, device[i].manufacturer, 256-1);
-	       strncat(driver_desc, " ", 256-1);
+	       strncat(driver_desc, device[i].manufacturer, sizeof(driver_desc)-1);
+	       strncat(driver_desc, " ", sizeof(driver_desc)-1);
 	    }
 	    if (device[i].product)
-	       strncat(driver_desc, device[i].product, 256-1);
+	       strncat(driver_desc, device[i].product, sizeof(driver_desc)-1);
 	    mouse_macosx.desc = driver_desc;
 	 }
       }
Index: src/misc/runner.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/misc/runner.c,v
retrieving revision 1.2
diff -u -p -r1.2 runner.c
--- src/misc/runner.c	2 Jul 2004 16:25:41 -0000	1.2
+++ src/misc/runner.c	3 Jul 2004 09:43:22 -0000
@@ -66,11 +66,11 @@ int main(int argc, char *argv[])
       }
       else {
 	 if (buf[0])
-	    strncat(buf, " ", 256-1);
+	    strncat(buf, " ", sizeof(buf)-1);
 
 	 if (flip_slashes) {
 	    j = strlen(buf);
-	    strncat(buf, argv[i], 256-1);
+	    strncat(buf, argv[i], sizeof(buf)-1);
 	    while (buf[j]) {
 	       if (buf[j] == '/')
 		  buf[j] = '\\';
@@ -78,13 +78,13 @@ int main(int argc, char *argv[])
 	    }
 	 }
 	 else
-	    strncat(buf, argv[i], 256-1);
+	    strncat(buf, argv[i], sizeof(buf)-1);
       }
    }
 
    if (f) {
       fclose(f);
-      strncat(buf, " @_tmpfile.arg", 256-1);
+      strncat(buf, " @_tmpfile.arg", sizeof(buf)-1);
    }
 
    p = strchr(buf, ' ');
Index: src/misc/runnergw.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/misc/runnergw.c,v
retrieving revision 1.3
diff -u -p -r1.3 runnergw.c
--- src/misc/runnergw.c	2 Jul 2004 16:25:41 -0000	1.3
+++ src/misc/runnergw.c	3 Jul 2004 09:43:22 -0000
@@ -33,7 +33,7 @@ int main(int argc, char *argv[])
          fclose(file);
       }
       else {
-         strncat(var, argv[i], 4096-1);
+         strncat(var, argv[i], sizeof(var)-1);
          p = var + strlen(var);
       }
 
Index: src/misc/vbeafex.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/misc/vbeafex.c,v
retrieving revision 1.4
diff -u -p -r1.4 vbeafex.c
--- src/misc/vbeafex.c	2 Jul 2004 16:25:42 -0000	1.4
+++ src/misc/vbeafex.c	3 Jul 2004 09:43:23 -0000
@@ -50,6 +50,8 @@
 #endif
 
 
+#define BUFFER_SIZE  256
+
 
 /* FAFEXT_LIBC extension structure */
 typedef struct LIBC_DATA
@@ -922,9 +924,9 @@ static const char *get_current_path(void
    static char *buffer = NULL;
 
    if (!buffer)
-      buffer = malloc(256);
+      buffer = malloc(BUFFER_SIZE);
 
-   getcwd(buffer, 255);
+   getcwd(buffer, BUFFER_SIZE-1);
 
    return buffer;
 }
@@ -956,10 +958,10 @@ static const char *get_nucleus_path(void
    p = getenv("WINBOOTDIR");
    if (p) {
       if (!buffer)
-	 buffer = malloc(256);
+	 buffer = malloc(BUFFER_SIZE);
 
-      _al_sane_strncpy(buffer , p, 256);
-      strncat(buffer, "\\nucleus", 256-1);
+      _al_sane_strncpy(buffer , p, BUFFER_SIZE);
+      strncat(buffer, "\\nucleus", BUFFER_SIZE-1);
       return buffer;
    }
 
@@ -976,11 +978,11 @@ static const char *get_nucleus_config_pa
    static char *buffer = NULL;
 
    if (!buffer)
-      buffer = malloc(256);
+      buffer = malloc(BUFFER_SIZE);
 
-   _al_sane_strncpy(buffer, get_nucleus_path(), 256);
+   _al_sane_strncpy(buffer, get_nucleus_path(), BUFFER_SIZE);
    put_backslash(buffer);
-   strncat(buffer, "config", 256-1);
+   strncat(buffer, "config", BUFFER_SIZE-1);
 
    return buffer;
 }
@@ -1005,12 +1007,12 @@ static const char *get_machine_name(void
    static char *buffer = NULL;
 
    if (!buffer)
-      buffer = malloc(256);
+      buffer = malloc(BUFFER_SIZE);
 
    #ifdef ALLEGRO_DJGPP
-      gethostname(buffer, 255);
+      gethostname(buffer, BUFFER_SIZE-1);
    #else
-      _al_sane_strncpy(buffer, "pc", 256);
+      _al_sane_strncpy(buffer, "pc", BUFFER_SIZE);
    #endif
 
    return buffer;
Index: src/unix/alsamidi.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/unix/alsamidi.c,v
retrieving revision 1.19
diff -u -p -r1.19 alsamidi.c
--- src/unix/alsamidi.c	2 Jul 2004 16:25:42 -0000	1.19
+++ src/unix/alsamidi.c	3 Jul 2004 09:43:24 -0000
@@ -185,11 +185,11 @@ static int alsa_rawmidi_init(int input, 
       snd_rawmidi_nonblock(rawmidi_handle, 0);
       snd_rawmidi_info_malloc(&info);
       snd_rawmidi_info(rawmidi_handle, info);
-      _al_sane_strncpy(alsa_rawmidi_desc, snd_rawmidi_info_get_name(info), 256);
+      _al_sane_strncpy(alsa_rawmidi_desc, snd_rawmidi_info_get_name(info), sizeof(alsa_rawmidi_desc));
 #else  /* ALLEGRO_ALSA_VERSION == 5 */
       snd_rawmidi_block_mode(rawmidi_handle, 1);
       snd_rawmidi_info(rawmidi_handle, &info);
-      _al_sane_strncpy(alsa_rawmidi_desc, info.name, 256);
+      _al_sane_strncpy(alsa_rawmidi_desc, info.name, sizeof(alsa_rawmidi_desc));
 #endif
       midi_alsa.desc = alsa_rawmidi_desc;
    }
Index: src/win/wddbmp.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/win/wddbmp.c,v
retrieving revision 1.33
diff -u -p -r1.33 wddbmp.c
--- src/win/wddbmp.c	2 Jul 2004 16:25:42 -0000	1.33
+++ src/win/wddbmp.c	3 Jul 2004 09:43:25 -0000
@@ -80,75 +80,75 @@ static char *dd_err(long err)
    switch (err) {
 
       case DD_OK:
-         _al_sane_strncpy(err_str, "DD_OK", 64);
+         _al_sane_strncpy(err_str, "DD_OK", sizeof(err_str));
          break;
 
       case DDERR_GENERIC:
-         _al_sane_strncpy(err_str, "DDERR_GENERIC", 64);
+         _al_sane_strncpy(err_str, "DDERR_GENERIC", sizeof(err_str));
          break;
 
      case DDERR_INCOMPATIBLEPRIMARY:
-         _al_sane_strncpy(err_str, "DDERR_INCOMPATIBLEPRIMARY", 64);
+         _al_sane_strncpy(err_str, "DDERR_INCOMPATIBLEPRIMARY", sizeof(err_str));
          break;
 
      case DDERR_INVALIDCAPS:
-         _al_sane_strncpy(err_str, "DDERR_INVALIDCAPS", 64);
+         _al_sane_strncpy(err_str, "DDERR_INVALIDCAPS", sizeof(err_str));
          break;
 
       case DDERR_INVALIDOBJECT:
-         _al_sane_strncpy(err_str, "DDERR_INVALIDOBJECT", 64);
+         _al_sane_strncpy(err_str, "DDERR_INVALIDOBJECT", sizeof(err_str));
          break;
 
       case DDERR_INVALIDPARAMS:
-         _al_sane_strncpy(err_str, "DDERR_INVALIDPARAMS", 64);
+         _al_sane_strncpy(err_str, "DDERR_INVALIDPARAMS", sizeof(err_str));
          break;
 
      case DDERR_INVALIDPIXELFORMAT:
-         _al_sane_strncpy(err_str, "DDERR_INVALIDPIXELFORMAT", 64);
+         _al_sane_strncpy(err_str, "DDERR_INVALIDPIXELFORMAT", sizeof(err_str));
          break;
 
       case DDERR_NOFLIPHW:
-         _al_sane_strncpy(err_str, "DDERR_NOFLIPHW", 64);
+         _al_sane_strncpy(err_str, "DDERR_NOFLIPHW", sizeof(err_str));
          break;
 
       case DDERR_NOTFLIPPABLE:
-         _al_sane_strncpy(err_str, "DDERR_NOTFLIPPABLE", 64);
+         _al_sane_strncpy(err_str, "DDERR_NOTFLIPPABLE", sizeof(err_str));
          break;
 
       case DDERR_OUTOFMEMORY:
-         _al_sane_strncpy(err_str, "DDERR_OUTOFMEMORY", 64);
+         _al_sane_strncpy(err_str, "DDERR_OUTOFMEMORY", sizeof(err_str));
          break;
 
       case DDERR_OUTOFVIDEOMEMORY:
-         _al_sane_strncpy(err_str, "DDERR_OUTOFVIDEOMEMORY", 64);
+         _al_sane_strncpy(err_str, "DDERR_OUTOFVIDEOMEMORY", sizeof(err_str));
          break;
 
      case DDERR_PRIMARYSURFACEALREADYEXISTS:
-         _al_sane_strncpy(err_str, "DDERR_PRIMARYSURFACEALREADYEXISTS", 64);
+         _al_sane_strncpy(err_str, "DDERR_PRIMARYSURFACEALREADYEXISTS", sizeof(err_str));
          break;
 
       case DDERR_SURFACEBUSY:
-         _al_sane_strncpy(err_str, "DDERR_SURFACEBUSY", 64);
+         _al_sane_strncpy(err_str, "DDERR_SURFACEBUSY", sizeof(err_str));
          break;
 
       case DDERR_SURFACELOST:
-         _al_sane_strncpy(err_str, "DDERR_SURFACELOST", 64);
+         _al_sane_strncpy(err_str, "DDERR_SURFACELOST", sizeof(err_str));
          break;
 
      case DDERR_UNSUPPORTED:
-         _al_sane_strncpy(err_str, "DDERR_UNSUPPORTED", 64);
+         _al_sane_strncpy(err_str, "DDERR_UNSUPPORTED", sizeof(err_str));
          break;
 
      case DDERR_UNSUPPORTEDMODE:
-         _al_sane_strncpy(err_str, "DDERR_UNSUPPORTEDMODE", 64);
+         _al_sane_strncpy(err_str, "DDERR_UNSUPPORTEDMODE", sizeof(err_str));
          break;
 
      case DDERR_WASSTILLDRAWING:
-         _al_sane_strncpy(err_str, "DDERR_WASSTILLDRAWING", 64);
+         _al_sane_strncpy(err_str, "DDERR_WASSTILLDRAWING", sizeof(err_str));
          break;
 
       default:
-         _al_sane_strncpy(err_str, "DDERR_UNKNOWN", 64);
+         _al_sane_strncpy(err_str, "DDERR_UNKNOWN", sizeof(err_str));
          break;
    }
 
Index: src/win/wdsinput.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/win/wdsinput.c,v
retrieving revision 1.12
diff -u -p -r1.12 wdsinput.c
--- src/win/wdsinput.c	2 Jul 2004 16:25:43 -0000	1.12
+++ src/win/wdsinput.c	3 Jul 2004 09:43:25 -0000
@@ -65,39 +65,39 @@ static char *ds_err(long err)
    switch (err) {
 
       case DS_OK:
-         _al_sane_strncpy(err_str, "DS_OK", 64);
+         _al_sane_strncpy(err_str, "DS_OK", sizeof(err_str));
          break;
 
       case DSERR_ALLOCATED:
-         _al_sane_strncpy(err_str, "DSERR_ALLOCATED", 64);
+         _al_sane_strncpy(err_str, "DSERR_ALLOCATED", sizeof(err_str));
          break;
 
       case DSERR_BADFORMAT:
-         _al_sane_strncpy(err_str, "DSERR_BADFORMAT", 64);
+         _al_sane_strncpy(err_str, "DSERR_BADFORMAT", sizeof(err_str));
          break;
 
       case DSERR_INVALIDPARAM:
-         _al_sane_strncpy(err_str, "DSERR_INVALIDPARAM", 64);
+         _al_sane_strncpy(err_str, "DSERR_INVALIDPARAM", sizeof(err_str));
          break;
 
       case DSERR_NOAGGREGATION:
-         _al_sane_strncpy(err_str, "DSERR_NOAGGREGATION", 64);
+         _al_sane_strncpy(err_str, "DSERR_NOAGGREGATION", sizeof(err_str));
          break;
 
       case DSERR_OUTOFMEMORY:
-         _al_sane_strncpy(err_str, "DSERR_OUTOFMEMORY", 64);
+         _al_sane_strncpy(err_str, "DSERR_OUTOFMEMORY", sizeof(err_str));
          break;
 
       case DSERR_UNINITIALIZED:
-         _al_sane_strncpy(err_str, "DSERR_UNINITIALIZED", 64);
+         _al_sane_strncpy(err_str, "DSERR_UNINITIALIZED", sizeof(err_str));
          break;
 
       case DSERR_UNSUPPORTED:
-         _al_sane_strncpy(err_str, "DSERR_UNSUPPORTED", 64);
+         _al_sane_strncpy(err_str, "DSERR_UNSUPPORTED", sizeof(err_str));
          break;
 
       default:
-         _al_sane_strncpy(err_str, "DSERR_UNKNOWN", 64);
+         _al_sane_strncpy(err_str, "DSERR_UNKNOWN", sizeof(err_str));
          break;
    }
 
Index: src/win/wdsndmix.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/win/wdsndmix.c,v
retrieving revision 1.19
diff -u -p -r1.19 wdsndmix.c
--- src/win/wdsndmix.c	2 Jul 2004 16:25:43 -0000	1.19
+++ src/win/wdsndmix.c	3 Jul 2004 09:43:25 -0000
@@ -268,39 +268,39 @@ static char *ds_err(long err)
    switch (err) {
 
       case DS_OK:
-         _al_sane_strncpy(err_str, "DS_OK", 64);
+         _al_sane_strncpy(err_str, "DS_OK", sizeof(err_str));
          break;
 
       case DSERR_ALLOCATED:
-         _al_sane_strncpy(err_str, "DSERR_ALLOCATED", 64);
+         _al_sane_strncpy(err_str, "DSERR_ALLOCATED", sizeof(err_str));
          break;
 
       case DSERR_BADFORMAT:
-         _al_sane_strncpy(err_str, "DSERR_BADFORMAT", 64);
+         _al_sane_strncpy(err_str, "DSERR_BADFORMAT", sizeof(err_str));
          break;
 
       case DSERR_INVALIDPARAM:
-         _al_sane_strncpy(err_str, "DSERR_INVALIDPARAM", 64);
+         _al_sane_strncpy(err_str, "DSERR_INVALIDPARAM", sizeof(err_str));
          break;
 
       case DSERR_NOAGGREGATION:
-         _al_sane_strncpy(err_str, "DSERR_NOAGGREGATION", 64);
+         _al_sane_strncpy(err_str, "DSERR_NOAGGREGATION", sizeof(err_str));
          break;
 
       case DSERR_OUTOFMEMORY:
-         _al_sane_strncpy(err_str, "DSERR_OUTOFMEMORY", 64);
+         _al_sane_strncpy(err_str, "DSERR_OUTOFMEMORY", sizeof(err_str));
          break;
 
       case DSERR_UNINITIALIZED:
-         _al_sane_strncpy(err_str, "DSERR_UNINITIALIZED", 64);
+         _al_sane_strncpy(err_str, "DSERR_UNINITIALIZED", sizeof(err_str));
          break;
 
       case DSERR_UNSUPPORTED:
-         _al_sane_strncpy(err_str, "DSERR_UNSUPPORTED", 64);
+         _al_sane_strncpy(err_str, "DSERR_UNSUPPORTED", sizeof(err_str));
          break;
 
       default:
-         _al_sane_strncpy(err_str, "DSERR_UNKNOWN", 64);
+         _al_sane_strncpy(err_str, "DSERR_UNKNOWN", sizeof(err_str));
          break;
    }
 
Index: src/win/wdsound.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/win/wdsound.c,v
retrieving revision 1.41
diff -u -p -r1.41 wdsound.c
--- src/win/wdsound.c	2 Jul 2004 16:25:43 -0000	1.41
+++ src/win/wdsound.c	3 Jul 2004 09:43:26 -0000
@@ -283,39 +283,39 @@ static char *ds_err(long err)
    switch (err) {
 
       case DS_OK:
-         _al_sane_strncpy(err_str, "DS_OK", 64);
+         _al_sane_strncpy(err_str, "DS_OK", sizeof(err_str));
          break;
 
       case DSERR_ALLOCATED:
-         _al_sane_strncpy(err_str, "DSERR_ALLOCATED", 64);
+         _al_sane_strncpy(err_str, "DSERR_ALLOCATED", sizeof(err_str));
          break;
 
       case DSERR_BADFORMAT:
-         _al_sane_strncpy(err_str, "DSERR_BADFORMAT", 64);
+         _al_sane_strncpy(err_str, "DSERR_BADFORMAT", sizeof(err_str));
          break;
 
       case DSERR_INVALIDPARAM:
-         _al_sane_strncpy(err_str, "DSERR_INVALIDPARAM", 64);
+         _al_sane_strncpy(err_str, "DSERR_INVALIDPARAM", sizeof(err_str));
          break;
 
       case DSERR_NOAGGREGATION:
-         _al_sane_strncpy(err_str, "DSERR_NOAGGREGATION", 64);
+         _al_sane_strncpy(err_str, "DSERR_NOAGGREGATION", sizeof(err_str));
          break;
 
       case DSERR_OUTOFMEMORY:
-         _al_sane_strncpy(err_str, "DSERR_OUTOFMEMORY", 64);
+         _al_sane_strncpy(err_str, "DSERR_OUTOFMEMORY", sizeof(err_str));
          break;
 
       case DSERR_UNINITIALIZED:
-         _al_sane_strncpy(err_str, "DSERR_UNINITIALIZED", 64);
+         _al_sane_strncpy(err_str, "DSERR_UNINITIALIZED", sizeof(err_str));
          break;
 
       case DSERR_UNSUPPORTED:
-         _al_sane_strncpy(err_str, "DSERR_UNSUPPORTED", 64);
+         _al_sane_strncpy(err_str, "DSERR_UNSUPPORTED", sizeof(err_str));
          break;
 
       default:
-         _al_sane_strncpy(err_str, "DSERR_UNKNOWN", 64);
+         _al_sane_strncpy(err_str, "DSERR_UNKNOWN", sizeof(err_str));
          break;
    }
 
Index: src/win/wjoydx.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/win/wjoydx.c,v
retrieving revision 1.8
diff -u -p -r1.8 wjoydx.c
--- src/win/wjoydx.c	2 Jul 2004 16:25:43 -0000	1.8
+++ src/win/wjoydx.c	3 Jul 2004 09:43:27 -0000
@@ -82,23 +82,23 @@ static char* dinput_err_str(long err)
    switch (err) {
 
       case DIERR_NOTACQUIRED:
-         _al_sane_strncpy(err_str, "the device is not acquired", 64);
+         _al_sane_strncpy(err_str, "the device is not acquired", sizeof(err_str));
          break;
 
       case DIERR_INPUTLOST:
-         _al_sane_strncpy(err_str, "access to the device was not granted", 64);
+         _al_sane_strncpy(err_str, "access to the device was not granted", sizeof(err_str));
          break;
 
       case DIERR_INVALIDPARAM:
-         _al_sane_strncpy(err_str, "the device does not have a selected data format", 64);
+         _al_sane_strncpy(err_str, "the device does not have a selected data format", sizeof(err_str));
          break;
 
       case DIERR_OTHERAPPHASPRIO:
-         _al_sane_strncpy(err_str, "can't acquire the device in background", 64);
+         _al_sane_strncpy(err_str, "can't acquire the device in background", sizeof(err_str));
          break;
 
       default:
-         _al_sane_strncpy(err_str, "unknown error", 64);
+         _al_sane_strncpy(err_str, "unknown error", sizeof(err_str));
    }
 
    return err_str;
Index: src/win/wkeybd.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/win/wkeybd.c,v
retrieving revision 1.22
diff -u -p -r1.22 wkeybd.c
--- src/win/wkeybd.c	2 Jul 2004 16:25:43 -0000	1.22
+++ src/win/wkeybd.c	3 Jul 2004 09:43:27 -0000
@@ -80,26 +80,26 @@ static char* dinput_err_str(long err)
    switch (err) {
 
       case DIERR_NOTACQUIRED:
-         _al_sane_strncpy(err_str, "the device is not acquired", 64);
+         _al_sane_strncpy(err_str, "the device is not acquired", sizeof(err_str));
          break;
 
       case DIERR_INPUTLOST:
-         _al_sane_strncpy(err_str, "access to the device was lost", 64);
+         _al_sane_strncpy(err_str, "access to the device was lost", sizeof(err_str));
          break;
 
       case DIERR_INVALIDPARAM:
-         _al_sane_strncpy(err_str, "the device does not have a selected data format", 64);
+         _al_sane_strncpy(err_str, "the device does not have a selected data format", sizeof(err_str));
          break;
 
 #ifdef DIERR_OTHERAPPHASPRIO
       /* this is not a legacy DirectX 3 error code */
       case DIERR_OTHERAPPHASPRIO:
-         _al_sane_strncpy(err_str, "can't acquire the device in background", 64);
+         _al_sane_strncpy(err_str, "can't acquire the device in background", sizeof(err_str));
          break;
 #endif
 
       default:
-         _al_sane_strncpy(err_str, "unknown error", 64);
+         _al_sane_strncpy(err_str, "unknown error", sizeof(err_str));
    }
 
    return err_str;
Index: src/win/wmouse.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/win/wmouse.c,v
retrieving revision 1.33
diff -u -p -r1.33 wmouse.c
--- src/win/wmouse.c	2 Jul 2004 16:25:43 -0000	1.33
+++ src/win/wmouse.c	3 Jul 2004 09:43:29 -0000
@@ -165,30 +165,30 @@ static char* dinput_err_str(long err)
    switch (err) {
 
       case DIERR_ACQUIRED:
-         _al_sane_strncpy(err_str, "the device is acquired", 64);
+         _al_sane_strncpy(err_str, "the device is acquired", sizeof(err_str));
          break;
 
       case DIERR_NOTACQUIRED:
-         _al_sane_strncpy(err_str, "the device is not acquired", 64);
+         _al_sane_strncpy(err_str, "the device is not acquired", sizeof(err_str));
          break;
 
       case DIERR_INPUTLOST:
-         _al_sane_strncpy(err_str, "access to the device was not granted", 64);
+         _al_sane_strncpy(err_str, "access to the device was not granted", sizeof(err_str));
          break;
 
       case DIERR_INVALIDPARAM:
-         _al_sane_strncpy(err_str, "the device does not have a selected data format", 64);
+         _al_sane_strncpy(err_str, "the device does not have a selected data format", sizeof(err_str));
          break;
 
 #ifdef DIERR_OTHERAPPHASPRIO
       /* this is not a legacy DirectX 3 error code */
       case DIERR_OTHERAPPHASPRIO:
-         _al_sane_strncpy(err_str, "can't acquire the device in background", 64);
+         _al_sane_strncpy(err_str, "can't acquire the device in background", sizeof(err_str));
          break;
 #endif
 
       default:
-         _al_sane_strncpy(err_str, "unknown error", 64);
+         _al_sane_strncpy(err_str, "unknown error", sizeof(err_str));
    }
 
    return err_str;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/