diff options
author | Jiří Klimeš <jklimes@redhat.com> | 2014-12-15 12:33:43 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-12-16 21:47:01 +0100 |
commit | f16bb960c998af2df4da7d4135c3e63517f5ea77 (patch) | |
tree | 163780dcb66e4a224adde5ca2c69583873b924c4 | |
parent | 1c2b75c5a003ca2b060044362884fbcdeacab4b4 (diff) | |
download | NetworkManager-f16bb960c998af2df4da7d4135c3e63517f5ea77.tar.gz |
tests: fix NEGATIVE_RETURNS (CWE-394) in tests
Error: NEGATIVE_RETURNS (CWE-394): [#def8]
NetworkManager-1.1.0/src/tests/test-general-with-expect.c:139: negative_return_fn: Function "fork()" returns a negative number.
NetworkManager-1.1.0/src/tests/test-general-with-expect.c:139: var_assign: Assigning: signed variable "pgid" = "fork".
NetworkManager-1.1.0/src/tests/test-general-with-expect.c:163: negative_returns: "pgid" is passed to a parameter that cannot be negative.
Error: NEGATIVE_RETURNS (CWE-394): [#def9]
NetworkManager-1.1.0/src/tests/test-general-with-expect.c:302: negative_returns: A negative constant "-1" is passed as an argument to a parameter that cannot be negative.
NetworkManager-1.1.0/src/tests/test-general-with-expect.c:81:2: neg_sink_parm_call: Passing "sig" to "nm_utils_kill_child_async", which cannot accept a negative number.
NetworkManager-1.1.0/src/NetworkManagerUtils.c:448:2: neg_sink_parm_call: Passing "sig" to "kill", which cannot accept a negative number.
(cherry picked from commit 5252287209f77cd43b5158d4657aea81414069c4)
-rw-r--r-- | src/tests/test-general-with-expect.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/tests/test-general-with-expect.c b/src/tests/test-general-with-expect.c index bee266f343..f5010dae4a 100644 --- a/src/tests/test-general-with-expect.c +++ b/src/tests/test-general-with-expect.c @@ -137,7 +137,10 @@ test_nm_utils_kill_child_create_and_join_pgroup (void) g_assert (err == 0); pgid = fork(); - g_assert (pgid >= 0); + if (pgid < 0) { + g_assert_not_reached (); + return pgid; + } if (pgid == 0) { /* child process... */ @@ -299,6 +302,7 @@ test_nm_utils_kill_child (void) g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, "*kill child process 'test-a-3-0' (*): unexpected error sending Unexpected signal: Invalid argument (22)"); g_test_expect_message ("NetworkManager", G_LOG_LEVEL_DEBUG, "*kill child process 'test-a-3-0' (*): invoke callback: killing child failed"); + /* coverity[negative_returns] */ test_nm_utils_kill_child_async_do ("test-a-3-0", pid3a, -1, 1000 / 2, FALSE, NULL); g_test_expect_message ("NetworkManager", G_LOG_LEVEL_DEBUG, "*kill child process 'test-a-3-1' (*): wait for process to terminate after sending SIGTERM (15) (send SIGKILL in 500 milliseconds)..."); |