Skip to content

Commit 832623a

Browse files
committed
tests: posix: net + barriers: mitigate codesonar issues
This change mitigates some code sonar issues (from SonarQube). 1. explicit 'U' after 0xffffffff > A cast shall not remove any const or volatile qualification from the > type of a pointer or reference c:S859 2. check return value from call to pthread_barrierattr_getpshared() > Unused assignments should be removed c:S1854 Signed-off-by: Chris Friedt <[email protected]>
1 parent 1a40a2a commit 832623a

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

tests/posix/barriers/src/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ ZTEST(posix_barriers, test_barrier)
2929
zassert_equal(ret, 0, "pthread_barrierattr_setpshared failed");
3030

3131
ret = pthread_barrierattr_getpshared(&attr, &pshared);
32+
zassert_equal(ret, 0, "pthread_barrierattr_getpshared failed");
3233
zassert_equal(pshared, PTHREAD_PROCESS_PUBLIC, "pshared attribute not retrieved correctly");
3334

3435
ret = pthread_barrierattr_setpshared(&attr, 42);

tests/posix/net/src/inet_addr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ ZTEST(net, test_inet_addr)
3939
{"1.2.3.4", htonl(0x01020304)},
4040
{"1.2.3.4 ", htonl(0x01020304)},
4141
{"0.0.0.123 a", htonl(0x0000007b)},
42-
{"255.255.255.255", htonl(0xffffffff)},
42+
{"255.255.255.255", htonl(0xffffffffU)},
4343
};
4444

4545
ARRAY_FOR_EACH_PTR(parms, p) {

tests/posix/net/src/inet_ntoa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ ZTEST(net, test_inet_ntoa)
1919
in.s_addr = htonl(0);
2020
zassert_mem_equal(inet_ntoa(in), "0.0.0.0", strlen("0.0.0.0") + 1);
2121

22-
in.s_addr = htonl(0xffffffff);
22+
in.s_addr = htonl(0xffffffffU);
2323
zassert_mem_equal(inet_ntoa(in), "255.255.255.255", strlen("255.255.255.255") + 1);
2424
}

0 commit comments

Comments
 (0)