All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tools/Coverity: Audit of MISSING_BREAK defects
@ 2015-02-12 20:08 Andrew Cooper
  2015-02-12 20:49 ` Don Koch
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Andrew Cooper @ 2015-02-12 20:08 UTC (permalink / raw)
  To: Xen-devel
  Cc: Andrew Cooper, Ian Jackson, Ian Campbell, Xen Coverity Team,
	Wei Liu

Coverity uses several heuristics to identify when one case statement
legitimately falls through into the next, and a comment as the final item in a
case statement is one heuristic (the assumption being that it is a
justification for the fallthrough).

Use this to perform an audit of defects and hide the legitimate fallthroughs.

There are two bugfixes identified in the audit, both minor:
 * 'n' command line handling for gtracestat
 * BKSPC handling in xentop

All other identified defaults are legitimate fallthoughs

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Coverity-IDs: 1055464, 1055465, 1055467, 1055468, 1055481, 1055482
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Xen Coverity Team <coverity@xen.org>
---
 tools/libxl/xl_cmdimpl.c         |    3 +++
 tools/misc/gtracestat.c          |    1 +
 tools/misc/gtraceview.c          |    1 +
 tools/xenstat/xentop/xentop.c    |    1 +
 tools/xenstore/xenstore_client.c |    1 +
 5 files changed, 7 insertions(+)

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 440db78..53c16eb 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -2752,11 +2752,14 @@ static int64_t parse_mem_size_kb(const char *mem)
     switch (tolower((uint8_t)*endptr)) {
     case 't':
         kbytes <<= 10;
+        /* fallthrough */
     case 'g':
         kbytes <<= 10;
+        /* fallthrough */
     case '\0':
     case 'm':
         kbytes <<= 10;
+        /* fallthrough */
     case 'k':
         break;
     case 'b':
diff --git a/tools/misc/gtracestat.c b/tools/misc/gtracestat.c
index 874a043..a59e536 100644
--- a/tools/misc/gtracestat.c
+++ b/tools/misc/gtracestat.c
@@ -167,6 +167,7 @@ int main(int argc, char *argv[])
             tsc2phase = atoll(optarg);
             if (tsc2phase <= 0)
                 tsc2phase = 55800000UL;
+            break;
         case 'd':
             is_digest = 1;
             break;
diff --git a/tools/misc/gtraceview.c b/tools/misc/gtraceview.c
index cf9287c..501f86a 100644
--- a/tools/misc/gtraceview.c
+++ b/tools/misc/gtraceview.c
@@ -1097,6 +1097,7 @@ void choose_cpus(void)
                     this->init();
                 return;
             }
+            /* fallthrough */
         case KEY_F(4):
             exit(EXIT_SUCCESS);
         }
diff --git a/tools/xenstat/xentop/xentop.c b/tools/xenstat/xentop/xentop.c
index 3062cb5..23b57f1 100644
--- a/tools/xenstat/xentop/xentop.c
+++ b/tools/xenstat/xentop/xentop.c
@@ -407,6 +407,7 @@ static int handle_key(int ch)
 		case KEY_BACKSPACE:
 			if(prompt_val_len > 0)
 				prompt_val[--prompt_val_len] = '\0';
+                        break;
 		default:
 			if((prompt_val_len+1) < PROMPT_VAL_LEN
 			   && isprint(ch)) {
diff --git a/tools/xenstore/xenstore_client.c b/tools/xenstore/xenstore_client.c
index 1054f18..3d14d37 100644
--- a/tools/xenstore/xenstore_client.c
+++ b/tools/xenstore/xenstore_client.c
@@ -87,6 +87,7 @@ usage(enum mode mode, int incl_mode, const char *progname)
 	errx(1, "Usage: %s %s[-h] [-s] [-t] key [...]", progname, mstr);
     case MODE_exists:
 	mstr = incl_mode ? "exists " : "";
+	/* fallthrough */
     case MODE_list:
 	mstr = mstr ? : incl_mode ? "list " : "";
 	errx(1, "Usage: %s %s[-h] [-p] [-s] key [...]", progname, mstr);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-02-24 16:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-12 20:08 [PATCH] tools/Coverity: Audit of MISSING_BREAK defects Andrew Cooper
2015-02-12 20:49 ` Don Koch
2015-02-13 10:51   ` Andrew Cooper
2015-02-13 10:38 ` Wei Liu
2015-02-23 10:08 ` Andrew Cooper
2015-02-24 16:45   ` Ian Campbell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.