]> Zhao Yanbai Git Server - minix.git/commitdiff
IS: resolve Coverity warnings
authorDavid van Moolenbroek <david@minix3.org>
Tue, 7 Aug 2012 11:09:09 +0000 (13:09 +0200)
committerDavid van Moolenbroek <david@minix3.org>
Wed, 8 Aug 2012 22:16:35 +0000 (00:16 +0200)
servers/is/dmp.c
servers/is/dmp_fs.c
servers/is/dmp_kernel.c

index a33b7d07717d19e4c3d16393090648d1c78476c9..bbae0f81c1389c2ca057df43432ab4c0c8c97b5b 100644 (file)
@@ -99,11 +99,11 @@ static char *key_name(int key)
        static char name[15];
 
        if(key >= F1 && key <= F12)
-               sprintf(name, " F%d", key - F1 + 1);
+               snprintf(name, sizeof(name), " F%d", key - F1 + 1);
        else if(key >= SF1 && key <= SF12)
-               sprintf(name, "Shift+F%d", key - SF1 + 1);
+               snprintf(name, sizeof(name), "Shift+F%d", key - SF1 + 1);
        else
-               sprintf(name, "?");
+               strlcpy(name, "?", sizeof(name));
        return name;
 }
 
index 4fe27d57181a891ee09358c5c6fcfe4fccec594b..ee486c99d60e34f191a1993517be3f6071b39369 100644 (file)
@@ -62,7 +62,7 @@ void fproc_dmp()
 static char * dmap_flags(int flags)
 {
        static char fl[10];
-       strcpy(fl, "-----");
+       strlcpy(fl, "-----", sizeof(fl));
        if(flags & DRV_FORCED)  fl[0] = 'F';
        return fl;
 }
@@ -72,18 +72,15 @@ static char * dmap_flags(int flags)
  *===========================================================================*/
 static char * dmap_style(int dev_style)
 {
-       static char str[16];
        switch(dev_style) {
-       case STYLE_DEV:    strcpy(str, "STYLE_DEV"); break;
-       case STYLE_DEVA:   strcpy(str, "STYLE_DEVA"); break;
-       case STYLE_TTY:    strcpy(str, "STYLE_TTY"); break;
-       case STYLE_CTTY:   strcpy(str, "STYLE_CTTY"); break;
-       case STYLE_CLONE:  strcpy(str, "STYLE_CLONE"); break;
-       case STYLE_CLONE_A:  strcpy(str, "STYLE_CLONE_A"); break;
-       default:           strcpy(str, "UNKNOWN"); break;
+       case STYLE_DEV:      return "STYLE_DEV";
+       case STYLE_DEVA:     return "STYLE_DEVA";
+       case STYLE_TTY:      return "STYLE_TTY";
+       case STYLE_CTTY:     return "STYLE_CTTY";
+       case STYLE_CLONE:    return "STYLE_CLONE";
+       case STYLE_CLONE_A:  return "STYLE_CLONE_A";
+       default:             return "UNKNOWN";
        }
-
-       return str;
 }
 
 /*===========================================================================*
index bf8234f1ce7c8296dcdd6e87e7028b086e26dd9c..830bcb8cd038f4de783b0fcd20b5ba28ac27efc7 100644 (file)
@@ -63,7 +63,7 @@ extern struct minix_kerninfo *_minix_kerninfo;
 void kmessages_dmp()
 {
   struct kmessages *kmess;             /* get copy of kernel messages */
-  char print_buf[_KMESS_BUF_SIZE+1];   /* this one is used to print */
+  static char print_buf[_KMESS_BUF_SIZE+1]; /* this one is used to print */
   int start;                           /* calculate start of messages */
   int r;
   int size;