Skip to content

Commit 3573647

Browse files
committed
csparser: change key event for MISSING_BREAK
... in order to be consistent with Coverity's assignment of key events
1 parent 412ca86 commit 3573647

File tree

9 files changed

+38
-8
lines changed

9 files changed

+38
-8
lines changed

csparser.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ KeyEventDigger::KeyEventDigger():
241241
d->hMap["FORWARD_NULL"] .insert("var_deref_model");
242242
d->hMap["LOCK"] .insert("double_lock");
243243
d->hMap["LOCK"] .insert("double_unlock");
244+
d->hMap["MISSING_BREAK"] .insert("unterminated_case");
244245
d->hMap["NESTING_INDENT_MISMATCH"].insert("dangling_else");
245246
d->hMap["NESTING_INDENT_MISMATCH"].insert("multi_stmt_macro");
246247
d->hMap["NESTING_INDENT_MISMATCH"].insert("on_same_line");

tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ test_csgrep(csgrep "44-csparser-new-key-evts" )
154154
test_csgrep(csgrep "45-gcc-parser-clang" )
155155
test_csgrep(csgrep "46-cov-json-v2" )
156156
test_csgrep(csgrep "47-csparser-new-key-evts" )
157+
test_csgrep(csgrep "48-csparser-missing-break-key-evt")
157158
test_csparser(csparser-5.8 00)
158159
test_csparser(csparser-5.8 01)
159160
test_csparser(csparser-5.8 02)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--prune-events=0
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Error: COMPILER_WARNING:
2+
libssh2-1.8.0/example/x11.c: scope_hint: In function 'x11_send_receive'
3+
libssh2-1.8.0/example/x11.c:213:14: warning: ignoring return value of 'write', declared with attribute warn_unused_result [-Wunused-result]
4+
# write(sock, buf, rc);
5+
# ^
6+
7+
Error: MISSING_BREAK (CWE-484):
8+
libssh2-1.8.0/src/sftp.c:1287: unterminated_case: The case for value "libssh2_NB_state_idle" is not terminated by a 'break' statement.
9+
libssh2-1.8.0/src/sftp.c:1414: fallthrough: The above case falls through to this one.
10+
# 1285|
11+
# 1286| switch (sftp->read_state) {
12+
# 1287|-> case libssh2_NB_state_idle:
13+
# 1288|
14+
# 1289| /* Some data may already have been read from the server in the
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Error: COMPILER_WARNING:
2+
libssh2-1.8.0/example/x11.c:213:14: warning: ignoring return value of 'write', declared with attribute warn_unused_result [-Wunused-result]
3+
4+
Error: MISSING_BREAK (CWE-484):
5+
libssh2-1.8.0/src/sftp.c:1287: unterminated_case: The case for value "libssh2_NB_state_idle" is not terminated by a 'break' statement.

tests/diff7.0-libssh/00-add-z.err

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ Error: FORWARD_NULL:
171171
/builddir/build/BUILD/libssh-0.5.0/src/socket.c:300: var_deref_model: Passing null variable "p" to function "ssh_poll_set_events", which dereferences it.
172172
/builddir/build/BUILD/libssh-0.5.0/src/poll.c:334: deref_parm: Directly dereferencing parameter "p".
173173

174+
Error: MISSING_BREAK:
175+
/builddir/build/BUILD/libssh-0.5.0/src/client.c:556: unterminated_case: This case (value 5) is not terminated by a 'break' statement.
176+
/builddir/build/BUILD/libssh-0.5.0/src/client.c:570: fallthrough: The above case falls through to this one.
177+
174178
Error: NULL_RETURNS:
175179
/builddir/build/BUILD/libssh-0.5.0/src/messages.c:908: returned_null: Function "ssh_message_new" returns null (checked 4 out of 5 times).
176180
/builddir/build/BUILD/libssh-0.5.0/src/messages.c:65: return_null: Explicitly returning NULL.

tests/diff7.0-libssh/00-fix-z.err

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ Error: FORWARD_NULL:
6969
libssh-0.4.8/libssh/dh.c:837: var_compare_op: Comparing "session->current_crypto" to null implies that "session->current_crypto" might be null.
7070
libssh-0.4.8/libssh/dh.c:853: var_deref_op: Dereferencing null variable "session->current_crypto".
7171

72+
Error: MISSING_BREAK:
73+
libssh-0.4.8/libssh/client.c:247: unterminated_case: This case (value 0) is not terminated by a 'break' statement.
74+
libssh-0.4.8/libssh/client.c:277: fallthrough: The above case falls through to this one.
75+
7276
Error: MISSING_BREAK:
7377
libssh-0.4.8/libssh/client.c:277: unterminated_case: This case (value 1) is not terminated by a 'break' statement.
7478
libssh-0.4.8/libssh/client.c:283: fallthrough: The above case falls through to this one.

tests/diff7.0-virtuoso-opensource/00-add-z.err

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -594,12 +594,12 @@ Error: MISSING_BREAK:
594594
/builddir/build/BUILD/virtuoso-opensource-6.1.3/libsrc/Dk/Dkbox.c:1193: fallthrough: The above case falls through to this one.
595595

596596
Error: MISSING_BREAK:
597-
/builddir/build/BUILD/virtuoso-opensource-6.1.3/libsrc/Wi/sparql2sql.c:1133: unterminated_case: This case (value 1011) is not terminated by a 'break' statement.
598-
/builddir/build/BUILD/virtuoso-opensource-6.1.3/libsrc/Wi/sparql2sql.c:1167: fallthrough: The above case falls through to this one.
597+
/builddir/build/BUILD/virtuoso-opensource-6.1.3/libsrc/Wi/sqlbif.c:8968: unterminated_case: This case (value 238) is not terminated by a 'break' statement.
598+
/builddir/build/BUILD/virtuoso-opensource-6.1.3/libsrc/Wi/sqlbif.c:8970: fallthrough: The above case falls through to this one.
599599

600600
Error: MISSING_BREAK:
601-
/builddir/build/BUILD/virtuoso-opensource-6.1.3/libsrc/Wi/sqlbif.c:6872: unterminated_case: This case (value 212) is not terminated by a 'break' statement.
602-
/builddir/build/BUILD/virtuoso-opensource-6.1.3/libsrc/Wi/sqlbif.c:6883: fallthrough: The above case falls through to this one.
601+
/builddir/build/BUILD/virtuoso-opensource-6.1.3/libsrc/Wi/sparql2sql.c:1133: unterminated_case: This case (value 1011) is not terminated by a 'break' statement.
602+
/builddir/build/BUILD/virtuoso-opensource-6.1.3/libsrc/Wi/sparql2sql.c:1167: fallthrough: The above case falls through to this one.
603603

604604
Error: NO_EFFECT:
605605
/builddir/build/BUILD/virtuoso-opensource-6.1.3/libsrc/Wi/sparul2sql.c:491: self_assign: Assignment operation "sc_ret[0]->sc_super = sc_ret[0]->sc_super" has no effect.

tests/diff7.0-virtuoso-opensource/00-add.err

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -594,12 +594,12 @@ Error: MISSING_BREAK:
594594
/builddir/build/BUILD/virtuoso-opensource-6.1.3/libsrc/Dk/Dkbox.c:1193: fallthrough: The above case falls through to this one.
595595

596596
Error: MISSING_BREAK:
597-
/builddir/build/BUILD/virtuoso-opensource-6.1.3/libsrc/Wi/sparql2sql.c:1133: unterminated_case: This case (value 1011) is not terminated by a 'break' statement.
598-
/builddir/build/BUILD/virtuoso-opensource-6.1.3/libsrc/Wi/sparql2sql.c:1167: fallthrough: The above case falls through to this one.
597+
/builddir/build/BUILD/virtuoso-opensource-6.1.3/libsrc/Wi/sqlbif.c:8968: unterminated_case: This case (value 238) is not terminated by a 'break' statement.
598+
/builddir/build/BUILD/virtuoso-opensource-6.1.3/libsrc/Wi/sqlbif.c:8970: fallthrough: The above case falls through to this one.
599599

600600
Error: MISSING_BREAK:
601-
/builddir/build/BUILD/virtuoso-opensource-6.1.3/libsrc/Wi/sqlbif.c:6872: unterminated_case: This case (value 212) is not terminated by a 'break' statement.
602-
/builddir/build/BUILD/virtuoso-opensource-6.1.3/libsrc/Wi/sqlbif.c:6883: fallthrough: The above case falls through to this one.
601+
/builddir/build/BUILD/virtuoso-opensource-6.1.3/libsrc/Wi/sparql2sql.c:1133: unterminated_case: This case (value 1011) is not terminated by a 'break' statement.
602+
/builddir/build/BUILD/virtuoso-opensource-6.1.3/libsrc/Wi/sparql2sql.c:1167: fallthrough: The above case falls through to this one.
603603

604604
Error: NO_EFFECT:
605605
/builddir/build/BUILD/virtuoso-opensource-6.1.3/libsrc/Wi/sparul2sql.c:491: self_assign: Assignment operation "sc_ret[0]->sc_super = sc_ret[0]->sc_super" has no effect.

0 commit comments

Comments
 (0)