diff --git a/libknet/tests/api_knet_handle_free.c b/libknet/tests/api_knet_handle_free.c index 1ceba443..83b46aa6 100644 --- a/libknet/tests/api_knet_handle_free.c +++ b/libknet/tests/api_knet_handle_free.c @@ -1,61 +1,62 @@ /* * Copyright (C) 2016-2025 Red Hat, Inc. All rights reserved. * * Authors: Fabio M. Di Nitto * * This software licensed under GPL-2.0+ */ #include "config.h" #include #include #include #include #include #include "libknet.h" #include "internals.h" #include "test-common.h" #define TESTNODES 1 static void test(void) { knet_handle_t knet_h1, knet_h[2]; int logfds[2]; int res; setup_logpipes(logfds); printf("Test knet_handle_free with invalid knet_h (part 1)\n"); if ((!knet_handle_free(NULL)) || (errno != EINVAL)) { printf("knet_handle_free failed to detect invalid parameter\n"); exit(FAIL); } knet_h1 = knet_handle_start(logfds, KNET_LOG_DEBUG, knet_h); printf("Test knet_handle_free with one host configured\n"); FAIL_ON_ERR(knet_host_add(knet_h1, 1)); if ((!knet_handle_free(knet_h1)) || (errno != EBUSY)) { CLEAN_EXIT(FAIL); } FAIL_ON_ERR(knet_host_remove(knet_h1, 1)); printf("Test knet_handle_free with invalid knet_h (part 2)\n"); + // coverity[BAD_FREE:SUPPRESS] - deliberate bad handle FAIL_ON_SUCCESS(knet_handle_free(knet_h1 + 1), EINVAL); FAIL_ON_ERR(knet_handle_free(knet_h1)); CLEAN_EXIT(CONTINUE); } int main(int argc, char *argv[]) { test(); return PASS; } diff --git a/libknet/tests/api_knet_handle_set_transport_reconnect_interval.c b/libknet/tests/api_knet_handle_set_transport_reconnect_interval.c index f0c6b2f3..1d2cdc96 100644 --- a/libknet/tests/api_knet_handle_set_transport_reconnect_interval.c +++ b/libknet/tests/api_knet_handle_set_transport_reconnect_interval.c @@ -1,58 +1,59 @@ /* * Copyright (C) 2016-2025 Red Hat, Inc. All rights reserved. * * Authors: Fabio M. Di Nitto * * This software licensed under GPL-2.0+ */ #include "config.h" #include #include #include #include #include #include "libknet.h" #include "internals.h" #include "test-common.h" static void test(void) { knet_handle_t knet_h1, knet_h[2]; int res; int logfds[2]; printf("Test knet_handle_set_transport_reconnect_interval with incorrect knet_h\n"); if ((!knet_handle_set_transport_reconnect_interval(NULL, 1000)) || (errno != EINVAL)) { printf("knet_handle_set_transport_reconnect_interval accepted invalid knet_h or returned incorrect error: %s\n", strerror(errno)); exit(FAIL); } setup_logpipes(logfds); knet_h1 = knet_handle_start(logfds, KNET_LOG_DEBUG, knet_h); printf("Test knet_handle_set_transport_reconnect_interval with incorrect msecs\n"); FAIL_ON_SUCCESS(knet_handle_set_transport_reconnect_interval(knet_h1, 0), EINVAL); printf("Test knet_handle_set_transport_reconnect_interval with correct values\n"); FAIL_ON_ERR(knet_handle_set_transport_reconnect_interval(knet_h1, 2000)); + // coverity[MISSING_LOCK:SUPPRESS] use out of the main library is 'OK' here. ish if (knet_h1->reconnect_int != 2000) { printf("knet_handle_set_transport_reconnect_interval failed to set correct value\n"); CLEAN_EXIT(FAIL); } CLEAN_EXIT(CONTINUE); } int main(int argc, char *argv[]) { test(); return PASS; }