mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 20:30:08 +01:00
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 5252287209)
This commit is contained in:
parent
1c2b75c5a0
commit
f16bb960c9
1 changed files with 5 additions and 1 deletions
|
|
@ -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)...");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue