Skip to content

Commit

Permalink
tools/nut-scanner/scan_ipmi.c, tools/nut-scanner/scan_avahi.c, script…
Browse files Browse the repository at this point in the history
…s/valgrind/.valgrind.supp: constrain warnings about library methods [networkupstools#2511]

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Jul 10, 2024
1 parent 28343c9 commit ed87ed0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
14 changes: 14 additions & 0 deletions scripts/valgrind/.valgrind.supp
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,17 @@
fun:init_snmp_once
...
}
{
<nut-scanner-ipmi-ctxinit>
Memcheck:Leak
...
fun:wrap_nut_ipmi_ctx_create
...
}
{
<nut-scanner-avahi-clientinit>
Memcheck:Leak
...
fun:wrap_nut_avahi_client_new
...
}
7 changes: 6 additions & 1 deletion tools/nut-scanner/scan_avahi.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,11 @@ static void client_callback(AvahiClient *c, AvahiClientState state, void * userd
}
}

static AvahiClient* wrap_nut_avahi_client_new(int *error)
{
return (*nut_avahi_client_new)((*nut_avahi_simple_poll_get)(simple_poll), 0, client_callback, NULL, error);
}

nutscan_device_t * nutscan_scan_avahi(useconds_t usec_timeout)
{
/* Example service publication
Expand Down Expand Up @@ -561,7 +566,7 @@ nutscan_device_t * nutscan_scan_avahi(useconds_t usec_timeout)
* but lacks a value in that enum for lack of flags (unconstrained
* lookup). So we have to silence a warning here...
*/
client = (*nut_avahi_client_new)((*nut_avahi_simple_poll_get)(simple_poll), 0, client_callback, NULL, &error);
client = wrap_nut_avahi_client_new(&error);
#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ASSIGN_ENUM)
# pragma GCC diagnostic pop
#endif
Expand Down
7 changes: 6 additions & 1 deletion tools/nut-scanner/scan_ipmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,11 @@ static int is_ipmi_device_supported(ipmi_ctx_t ipmi_ctx, int ipmi_id)
return 0;
}

static ipmi_ctx_t wrap_nut_ipmi_ctx_create(void)
{
return (*nut_ipmi_ctx_create) ();
}

/* Check for IPMI support on a specific (local or remote) system
* Return NULL on error, or a valid nutscan_device_t otherwise */
nutscan_device_t * nutscan_scan_ipmi_device(const char * IPaddr, nutscan_ipmi_t * ipmi_sec)
Expand All @@ -437,7 +442,7 @@ nutscan_device_t * nutscan_scan_ipmi_device(const char * IPaddr, nutscan_ipmi_t
}

/* Initialize the FreeIPMI library. */
if (!(ipmi_ctx = (*nut_ipmi_ctx_create) ()))
if (!(ipmi_ctx = wrap_nut_ipmi_ctx_create()))
{
/* we have to force cleanup, since exit handler is not yet installed */
fprintf(stderr, "Failed to ipmi_ctx_create\n");
Expand Down

0 comments on commit ed87ed0

Please sign in to comment.