From dc567e2ccd9657eab52cac801e2e825fe8301c65 Mon Sep 17 00:00:00 2001 From: Michal Bloch Date: Mon, 25 Nov 2024 16:21:35 +0100 Subject: [PATCH] Solve some static analysis type complaints --- tests/kdbus/test-benchmark.c | 6 +++--- tests/kdbus/test-metadata-ns.c | 2 +- tests/kdbus/test-policy-priv.c | 11 ++++++++--- tests/logger/logger.c | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/tests/kdbus/test-benchmark.c b/tests/kdbus/test-benchmark.c index 0681496..3aa6567 100644 --- a/tests/kdbus/test-benchmark.c +++ b/tests/kdbus/test-benchmark.c @@ -71,7 +71,7 @@ static void dump_stats(bool is_uds) (unsigned long long) stats.latency_low, (unsigned long long) stats.latency_high, (unsigned long long) stats.latency_avg, - sqrt(stats.latency_ssquares / stats.count)); + sqrt((double)stats.latency_ssquares / stats.count)); } else { kdbus_printf("*** no packets received. bus stuck?\n"); } @@ -508,7 +508,7 @@ static wur int benchmark_bandwidth(struct kdbus_test_env *env) stress_payload = malloc(env->payload); ASSERT_NONZERO(stress_payload); - for (int i = 0; i < env->payload; i++) + for (size_t i = 0; i < env->payload; i++) stress_payload[i] = i; // A pair consists of a reader and a sender @@ -546,7 +546,7 @@ static wur int benchmark_latency_mt(struct kdbus_test_env *env) stress_payload = malloc(env->payload); ASSERT_NONZERO(stress_payload); - for (int i = 0; i < env->payload; i++) + for (size_t i = 0; i < env->payload; i++) stress_payload[i] = i; bandwidth_sender_thread(&(struct bandwidth_worker_data){ .i = 0, .env = env }); diff --git a/tests/kdbus/test-metadata-ns.c b/tests/kdbus/test-metadata-ns.c index b243448..12bd86f 100644 --- a/tests/kdbus/test-metadata-ns.c +++ b/tests/kdbus/test-metadata-ns.c @@ -82,7 +82,7 @@ static wur int __kdbus_clone_userns_test(const char *bus, int ret; struct kdbus_msg *msg = NULL; const struct kdbus_item *item; - uint64_t cookie = time(NULL) ^ 0xdeadbeef; + uint64_t cookie = ((uint64_t) time(NULL)) ^ 0xdeadbeef; struct kdbus_conn *unpriv_conn = NULL; struct kdbus_pids parent_pids = { .pid = getppid(), diff --git a/tests/kdbus/test-policy-priv.c b/tests/kdbus/test-policy-priv.c index 025cdb0..abd18ba 100644 --- a/tests/kdbus/test-policy-priv.c +++ b/tests/kdbus/test-policy-priv.c @@ -15,12 +15,17 @@ #include "kdbus-util.h" #include "kdbus-enum.h" +static wur uint64_t generate_cookie() +{ + return ((uint64_t) time(NULL)) ^ 0xdeadbeef; +} + static wur int test_policy_priv_by_id(const char *bus, struct kdbus_conn *conn_dst, int parent_status, int child_status) { - uint64_t expected_cookie = time(NULL) ^ 0xdeadbeef; + uint64_t expected_cookie = generate_cookie(); #ifdef TIZEN parent_status = child_status = 0; @@ -50,7 +55,7 @@ static wur int test_policy_priv_by_broadcast(const char *bus, uid_t second_uid = UNPRIV_UID; gid_t second_gid = UNPRIV_GID; struct kdbus_conn *child_2 = conn_dst; - uint64_t expected_cookie = time(NULL) ^ 0xdeadbeef; + uint64_t expected_cookie = generate_cookie(); #ifdef TIZEN child_status = 0; @@ -242,7 +247,7 @@ static wur int test_broadcast_after_policy_upload(struct kdbus_test_env *env) struct kdbus_conn *owner_a, *owner_b; struct kdbus_conn *holder_a, *holder_b; struct kdbus_policy_access access = {}; - uint64_t expected_cookie = time(NULL) ^ 0xdeadbeef; + uint64_t expected_cookie = generate_cookie(); ASSERT_NONZERO(owner_a = kdbus_hello(env->buspath, 0, NULL, 0)); diff --git a/tests/logger/logger.c b/tests/logger/logger.c index d2c4231..dc3002a 100644 --- a/tests/logger/logger.c +++ b/tests/logger/logger.c @@ -98,7 +98,7 @@ int dump_logger(const char *device, bool clear) } if (e->hdr_size != sizeof(struct logger_entry)) { - fprintf(stderr, "%d != %d\n", e->hdr_size, sizeof(struct logger_entry)); + fprintf(stderr, "%d != %zu\n", (int) e->hdr_size, sizeof(struct logger_entry)); fprintf(stderr, "read: Invalid data\n"); ret = EXIT_FAILURE; break; -- 2.34.1