diff options
author | Jiří Klimeš <jklimes@redhat.com> | 2014-12-15 12:33:43 +0100 |
---|---|---|
committer | Jiří Klimeš <jklimes@redhat.com> | 2014-12-15 14:11:03 +0100 |
commit | e0d22c9788dba9db29ac6cfa86be9a6561688231 (patch) | |
tree | 12883a707c67be24f41106912c0e8c4466d449a1 | |
parent | 09180fa4e70bbef01e4519f17f1720cac5e62f47 (diff) | |
download | NetworkManager-jk/coverity2.tar.gz |
tests: fix NEGATIVE_RETURNS (CWE-394) in testsjk/coverity2
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.
-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)..."); |