tools/Coverity: Audit of MISSING_BREAK defects
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 12 Feb 2015 20:08:33 +0000 (20:08 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Tue, 24 Feb 2015 15:51:04 +0000 (15:51 +0000)
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: 105546410554651055467105546810554811055482
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>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Don Koch <dkoch@verizon.com>
tools/libxl/xl_cmdimpl.c
tools/misc/gtracestat.c
tools/misc/gtraceview.c
tools/xenstat/xentop/xentop.c
tools/xenstore/xenstore_client.c

index 440db7800cda36ddbe234db388136d609a3c4999..53c16eb0c2d5616838e302758dff860e7267622b 100644 (file)
@@ -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':
index 874a043bd3adce3244b4ba62d13b599707412441..a59e5362d65b4cdfbac1d0d1b04bd6d3a280c293 100644 (file)
@@ -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;
index cf9287c794eb55927b0256325062de295f0662fd..501f86ab0f46588c1d26d569399d312437d25197 100644 (file)
@@ -1097,6 +1097,7 @@ void choose_cpus(void)
                     this->init();
                 return;
             }
+            /* fallthrough */
         case KEY_F(4):
             exit(EXIT_SUCCESS);
         }
index 3062cb54635775364f158d2ccfef7ade430d7d7c..23b57f18e35e5ea35be7dfe6401e4ed9f73ee5df 100644 (file)
@@ -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)) {
index 1054f18c71cfed926266b8c3781c611ac422207b..3d14d37e62904089e3eace9ee4ea6952833a93ab 100644 (file)
@@ -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);