Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint2 Add a list of functions where we usually...



details:   https://anonhg.NetBSD.org/src/rev/d9568437524c
branches:  trunk
changeset: 750793:d9568437524c
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Jan 14 16:58:27 2010 +0000

description:
Add a list of functions where we usually don't care about their return
code. Can be bypassed by -hh

diffstat:

 usr.bin/xlint/lint2/chk.c   |  47 +++++++++++++++++++++++++++++++-------------
 usr.bin/xlint/lint2/main2.c |   6 ++--
 2 files changed, 36 insertions(+), 17 deletions(-)

diffs (113 lines):

diff -r 993e204be938 -r d9568437524c usr.bin/xlint/lint2/chk.c
--- a/usr.bin/xlint/lint2/chk.c Thu Jan 14 16:27:49 2010 +0000
+++ b/usr.bin/xlint/lint2/chk.c Thu Jan 14 16:58:27 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: chk.c,v 1.20 2009/04/14 09:03:45 lukem Exp $ */
+/* $NetBSD: chk.c,v 1.21 2010/01/14 16:58:27 christos Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,10 +38,11 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: chk.c,v 1.20 2009/04/14 09:03:45 lukem Exp $");
+__RCSID("$NetBSD: chk.c,v 1.21 2010/01/14 16:58:27 christos Exp $");
 #endif
 
 #include <ctype.h>
+#include <string.h>
 #include <limits.h>
 #include <stdlib.h>
 
@@ -1045,6 +1046,19 @@
        msg(16, hte->h_name, mkpos(&call->f_pos));
 }
 
+/*
+ * List of functions where we usually don't care about their result.
+ * NB: Must be sorted.
+ */
+static const char ignorelist[][8] = {
+       "memcpy",
+       "memmove",
+       "memset",
+       "printf",
+       "strcat",
+       "strcpy",
+       "vprintf",
+};
 
 /*
  * Print warnings for return values which are used, but not returned,
@@ -1064,26 +1078,31 @@
                return;
 
        if (def->s_rval) {
+               /*
+                * XXX as soon as we are able to disable single warnings
+                * the following dependencies from hflag should be removed.
+                * but for now I do'nt want to be botherd by this warnings
+                * which are almost always useless.
+                */
+               if (hflag == 0)
+                       return;
+               if (hflag == 1 && bsearch(hte->h_name, ignorelist,
+                   __arraycount(ignorelist), sizeof(ignorelist[0]),
+                   (int (*)(const void *, const void *))strcmp) != NULL)
+                       return;
+
                /* function has return value */
                used = ignored = 0;
                for (call = hte->h_calls; call != NULL; call = call->f_nxt) {
                        used |= call->f_rused || call->f_rdisc;
                        ignored |= !call->f_rused && !call->f_rdisc;
                }
-               /*
-                * XXX as soon as we are able to disable single warnings
-                * the following dependencies from hflag should be removed.
-                * but for now I do'nt want to be botherd by this warnings
-                * which are almost always useless.
-                */
                if (!used && ignored) {
-                       if (hflag)
-                               /* %s returns value which is always ignored */
-                               msg(8, hte->h_name);
+                       /* %s returns value which is always ignored */
+                       msg(8, hte->h_name);
                } else if (used && ignored) {
-                       if (hflag)
-                               /* %s returns value which is sometimes ign. */
-                               msg(9, hte->h_name);
+                       /* %s returns value which is sometimes ign. */
+                       msg(9, hte->h_name);
                }
        } else {
                /* function has no return value */
diff -r 993e204be938 -r d9568437524c usr.bin/xlint/lint2/main2.c
--- a/usr.bin/xlint/lint2/main2.c       Thu Jan 14 16:27:49 2010 +0000
+++ b/usr.bin/xlint/lint2/main2.c       Thu Jan 14 16:58:27 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main2.c,v 1.7 2004/06/20 22:20:17 jmc Exp $    */
+/*     $NetBSD: main2.c,v 1.8 2010/01/14 16:58:27 christos Exp $       */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: main2.c,v 1.7 2004/06/20 22:20:17 jmc Exp $");
+__RCSID("$NetBSD: main2.c,v 1.8 2010/01/14 16:58:27 christos Exp $");
 #endif
 
 #include <stdio.h>
@@ -131,7 +131,7 @@
                        Hflag = 1;
                        break;
                case 'h':
-                       hflag = 1;
+                       hflag++;
                        break;
                case 'F':
                        Fflag = 1;



Home | Main Index | Thread Index | Old Index