[splint-discuss] Splint-3.1.2 bugs - Mudflap

John Carter john.carter at tait.co.nz
Wed Jul 30 18:46:49 PDT 2008


For something dedicated to static analysis... I find it curious that
splint is anything but "-Wall -W" warnings clean!

Particularly alarming to me are the "Function uses uninitialized
variable..." warnings.

This first patch fixes two of those, but there are many more.

The second patch fixes the bug uncovered by mudflap I mentioned in my previous mail.

The third patch fixes a preprocessor warning in osd.c

Thanks!

Index: src/cppexp.c
===================================================================
RCS file: /cvsroot/splint/splint/src/cppexp.c,v
retrieving revision 1.24
diff -u -r1.24 cppexp.c
--- src/cppexp.c	18 May 2004 19:07:46 -0000	1.24
+++ src/cppexp.c	31 Jul 2008 01:40:55 -0000
@@ -240,7 +240,7 @@
  struct operation
  cppReader_parseNumber (cppReader *pfile, char *start, int olen) /*@requires maxRead(start) >= (olen - 1) @*/
  {
-  struct operation op;
+  struct operation op = {0,0,0,0,0};
    char *p = start;
    char c;
    int i;
@@ -417,7 +417,7 @@
    char c;
    register struct token *toktab;
    enum cpp_token token;
-  struct operation op;
+  struct operation op = {0,0,0,0,0};
    char *tok_start, *tok_end;
    int old_written;

Index: src/lcllib.c
===================================================================
RCS file: /cvsroot/splint/splint/src/lcllib.c,v
retrieving revision 1.31
diff -u -r1.31 lcllib.c
--- src/lcllib.c	18 May 2004 19:07:47 -0000	1.31
+++ src/lcllib.c	31 Jul 2008 01:40:55 -0000
@@ -424,7 +424,7 @@
  }

  /*@constant int BUFLEN;@*/
-# define BUFLEN 128
+# define BUFLEN MAX_DUMP_LINE_LENGTH

  static bool
  loadLCDFile (FILE *f, cstring name)
Index: src/osd.c
===================================================================
RCS file: /cvsroot/splint/splint/src/osd.c,v
retrieving revision 1.43
diff -u -r1.43 osd.c
--- src/osd.c	10 Aug 2007 22:31:05 -0000	1.43
+++ src/osd.c	31 Jul 2008 01:40:55 -0000
@@ -862,7 +862,7 @@
  # if defined (UNIX)
    char *buf = dmalloc (sizeof (*buf) * MAXPATHLEN);
    char *cwd = getcwd (buf, MAXPATHLEN);
-#else if defined (OS2)
+#elif defined (OS2)
    char *buf = dmalloc (sizeof (*buf) * MAXPATHLEN);
    char *cwd = _getcwd2 (buf, MAXPATHLEN);
    char *slash;


John Carter                             Phone : (64)(3) 358 6639
Tait Electronics                        Fax   : (64)(3) 359 4632
PO Box 1645 Christchurch                Email : john.carter at tait.co.nz
New Zealand



More information about the splint-discuss mailing list