Skip to content

Commit

Permalink
scripts/valgrind/.valgrind.supp: update titles for libssl suppressions
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Jul 11, 2024
1 parent cce2567 commit 1fb03cd
Show file tree
Hide file tree
Showing 13 changed files with 164 additions and 141 deletions.
6 changes: 3 additions & 3 deletions scripts/valgrind/.valgrind.supp
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@
...
}
{
<libssl_init>
<libssl_init_CRYPTO>
Memcheck:Leak
...
fun:CRYPTO_*
...
}
{
<libssl_init>
<libssl_init_SSL_CTX>
Memcheck:Leak
...
fun:SSL_CTX_*
...
}
{
<libssl_init>
<libssl_init_OPENSSL>
Memcheck:Leak
...
fun:OPENSSL_*
Expand Down
2 changes: 1 addition & 1 deletion tools/nut-scanner/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ libnutscan_la_LDFLAGS += -version-info 2:5:2
# copies of "nut_debug_level" making fun of our debug-logging attempts.
# One solution to tackle if needed for those cases would be to make some
# dynamic/shared libnutcommon (etc.)
libnutscan_la_LDFLAGS += -export-symbols-regex '^(nutscan_|nut_debug_level|s_upsdebug|fatalx|xcalloc|snprintfcat|max_threads|curr_threads|nut_report_config_flags|upsdebugx_report_search_paths|nut_prepare_search_paths)'
libnutscan_la_LDFLAGS += -export-symbols-regex '^(nutscan_|nut_debug_level|s_upsdebug|fatalx|fatal_with_errno|xcalloc|snprintfcat|max_threads|curr_threads|nut_report_config_flags|upsdebugx_report_search_paths|nut_prepare_search_paths)'
libnutscan_la_CFLAGS = -I$(top_srcdir)/clients -I$(top_srcdir)/include \
$(LIBLTDL_CFLAGS) -I$(top_srcdir)/drivers

Expand Down
29 changes: 14 additions & 15 deletions tools/nut-scanner/nut-scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ static void handle_arg_cidr(const char *arg_addr, int *auto_nets_ptr)
* `-m auto4/X` and `-m auto6/Y` requests?
*/
if (auto_nets_ptr && *auto_nets_ptr) {
fprintf(stderr, "Duplicate request for connected subnet scan ignored\n");
upsdebugx(0, "Duplicate request for connected subnet scan ignored");
return;
}

Expand Down Expand Up @@ -437,9 +437,8 @@ static void handle_arg_cidr(const char *arg_addr, int *auto_nets_ptr)
if (getifaddrs(&ifap) < 0 || !ifap) {
if (ifap)
freeifaddrs(ifap);
fatalx(EXIT_FAILURE,
"Failed to getifaddrs() for connected subnet scan: %s\n",
strerror(errno));
fatal_with_errno(EXIT_FAILURE,
"Failed to getifaddrs() for connected subnet scan");
/* TOTHINK: Non-fatal, just return / goto finish?
* Either way, do not proceed with code below! */
}
Expand Down Expand Up @@ -1175,7 +1174,7 @@ int main(int argc, char *argv[])
/* Get max number of files. */
if (getrlimit(RLIMIT_NOFILE, &nofile_limit) != 0) {
/* Report error, keep hardcoded default */
fprintf(stderr, "getrlimit() failed with errno=%d, keeping default job limits\n", errno);
upsdebug_with_errno(0, "getrlimit() failed, keeping default job limits");
nofile_limit.rlim_cur = 0;
nofile_limit.rlim_max = 0;
} else {
Expand Down Expand Up @@ -1249,8 +1248,8 @@ int main(int argc, char *argv[])
if (errno_saved || (s && *s != '\0') || l <= 0) {
/* TODO: Any max limit? At least,
* max(useconds_t)/1000000 ? */
fprintf(stderr,
"Illegal timeout value, using default %ds\n",
upsdebugx(0,
"Illegal timeout value, using default %ds",
DEFAULT_NETWORK_TIMEOUT);
timeout = DEFAULT_NETWORK_TIMEOUT * 1000 * 1000;
} else {
Expand Down Expand Up @@ -1404,8 +1403,8 @@ int main(int argc, char *argv[])
ipmi_sec.authentication_type = IPMI_AUTHENTICATION_TYPE_MD5;
}
else {
fprintf(stderr,
"Unknown authentication type (%s). Defaulting to MD5\n",
upsdebugx(0,
"Unknown authentication type (%s). Defaulting to MD5",
optarg);
}
break;
Expand Down Expand Up @@ -1449,27 +1448,27 @@ int main(int argc, char *argv[])
max_threads -= RESERVE_FD_COUNT;
}

fprintf(stderr,
upsdebugx(0,
"WARNING: Requested max scanning "
"thread count %s (%ld) exceeds the "
"current file descriptor count limit "
"(minus reservation), constraining "
"to %" PRIuSIZE "\n",
"to %" PRIuSIZE,
optarg, val, max_threads);
} else
# endif /* HAVE_SYS_RESOURCE_H */
max_threads = (size_t)val;
} else {
fprintf(stderr,
upsdebugx(0,
"WARNING: Requested max scanning "
"thread count %s (%ld) is out of range, "
"using default %" PRIuSIZE "\n",
"using default %" PRIuSIZE,
optarg, val, max_threads);
}
#else
fprintf(stderr,
upsdebugx(0,
"WARNING: Max scanning thread count option "
"is not supported in this build, ignored\n");
"is not supported in this build, ignored");
#endif /* HAVE_PTHREAD && ways to limit the thread count */
}
break;
Expand Down
4 changes: 2 additions & 2 deletions tools/nut-scanner/nutscan-display.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void nutscan_display_sanity_check_serial(nutscan_device_t * device)
/* Reserve enough slots for all-unique serials */
map = calloc(listlen, sizeof(keyval_strings_t));
if (map == NULL) {
fprintf(stderr, "%s: Memory allocation error, skipped\n", __func__);
upsdebugx(0, "%s: Memory allocation error, skipped", __func__);
return;
}

Expand Down Expand Up @@ -317,7 +317,7 @@ void nutscan_display_sanity_check_serial(nutscan_device_t * device)
count++;
if (count != (i + 1) || count > listlen) {
/* Should never get here, but just in case... */
fprintf(stderr, "%s: Loop overflow, skipped\n", __func__);
upsdebugx(0, "%s: Loop overflow, skipped", __func__);
upsdebugx(3, "%s: count=%" PRIuSIZE " i=%" PRIuSIZE " listlen%" PRIuSIZE,
__func__, count, i, listlen);
goto exit;
Expand Down
9 changes: 6 additions & 3 deletions tools/nut-scanner/nutscan-ip.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@ char * nutscan_ip_iter_init(nutscan_ip_iter_t * ip, const char * startIP, const
ip->type = IPv6;
hints.ai_family = AF_INET6;
if (getaddrinfo(startIP, NULL, &hints, &res) != 0) {
fprintf(stderr, "Invalid address : %s\n", startIP);
upsdebugx(0, "WARNING: %s: Invalid address : %s",
__func__, startIP);
return NULL;
}

Expand All @@ -388,7 +389,8 @@ char * nutscan_ip_iter_init(nutscan_ip_iter_t * ip, const char * startIP, const
if (ip->type == IPv4) {
hints.ai_family = AF_INET;
if (getaddrinfo(stopIP, NULL, &hints, &res) != 0) {
fprintf(stderr, "Invalid address : %s\n", stopIP);
upsdebugx(0, "WARNING: %s: Invalid address : %s",
__func__, stopIP);
return NULL;
}

Expand All @@ -399,7 +401,8 @@ char * nutscan_ip_iter_init(nutscan_ip_iter_t * ip, const char * startIP, const
else {
hints.ai_family = AF_INET6;
if (getaddrinfo(stopIP, NULL, &hints, &res) != 0) {
fprintf(stderr, "Invalid address : %s\n", stopIP);
upsdebugx(0, "WARNING: %s: Invalid address : %s",
__func__, stopIP);
return NULL;
}
memcpy(s_in6, res->ai_addr, sizeof(struct sockaddr_in6));
Expand Down
8 changes: 4 additions & 4 deletions tools/nut-scanner/nutscan-serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#define SERIAL_PORT_PREFIX "/dev/tty"
#endif

#define ERR_OUT_OF_BOUND "Serial port range out of bound (must be 0 to 9 or a to z depending on your system)\n"
#define ERR_OUT_OF_BOUND "Serial port range out of bound (must be 0 to 9 or a to z depending on your system)"

typedef struct {
char * name;
Expand Down Expand Up @@ -108,7 +108,7 @@ static char ** add_port(char ** list, char * port)
/*+1 for the terminal NULL */
res = realloc(list, sizeof(char*) * (count + 1 + 1));
if (res == NULL) {
upsdebugx(1, "%s: Failed to realloc port list", __func__);
upsdebugx(0, "%s: Failed to realloc port list", __func__);
return list;
}
res[count] = strdup(port);
Expand Down Expand Up @@ -146,15 +146,15 @@ char ** nutscan_get_serial_ports_list(const char *ports_range)
if ((list_sep_ptr = strchr(range, '-')) != NULL) {
tok = strtok_r(range, "-", &saveptr);
if (tok[1] != 0) {
fprintf(stderr, ERR_OUT_OF_BOUND);
upsdebugx(0, "%s", ERR_OUT_OF_BOUND);
free(range);
return NULL;
}
start_port = tok[0];
tok = strtok_r(NULL, "-", &saveptr);
if (tok != NULL) {
if (tok[1] != 0) {
fprintf(stderr, ERR_OUT_OF_BOUND);
upsdebugx(0, "%s", ERR_OUT_OF_BOUND);
free(range);
return NULL;
}
Expand Down
53 changes: 29 additions & 24 deletions tools/nut-scanner/scan_avahi.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ int nutscan_load_avahi_library(const char *libname_path)
}

if (libname_path == NULL) {
fprintf(stderr, "AVAHI client library not found. AVAHI search disabled.\n");
upsdebugx(0, "AVAHI client library not found. AVAHI search disabled.");
return 0;
}

if (lt_dlinit() != 0) {
fprintf(stderr, "Error initializing lt_init\n");
upsdebugx(0, "%s: Error initializing lt_dlinit", __func__);
return 0;
}

Expand Down Expand Up @@ -231,9 +231,10 @@ int nutscan_load_avahi_library(const char *libname_path)
dl_saved_libname = xstrdup(libname_path);

return 1;

err:
fprintf(stderr,
"Cannot load AVAHI library (%s) : %s. AVAHI search disabled.\n",
upsdebugx(0,
"Cannot load AVAHI library (%s) : %s. AVAHI search disabled.",
libname_path, dl_error);
dl_handle = (void *)1;
lt_dlexit();
Expand Down Expand Up @@ -407,23 +408,23 @@ static void resolve_callback(

switch (event) {
case AVAHI_RESOLVER_FAILURE:
fprintf(stderr,
"(Resolver) Failed to resolve service '%s' of type '%s' in domain '%s': %s\n",
name, type, domain,
upsdebugx(0, "%s: "
"(Resolver) Failed to resolve service '%s' of type '%s' in domain '%s': %s",
__func__, name, type, domain,
(*nut_avahi_strerror)((*nut_avahi_client_errno)((*nut_avahi_service_resolver_get_client)(r))));
break;

case AVAHI_RESOLVER_FOUND: {
char a[AVAHI_ADDRESS_STR_MAX], *t;

/* fprintf(stderr, "Service '%s' of type '%s' in domain '%s':\n", name, type, domain); */
/* upsdebugx(1, "%s: Service '%s' of type '%s' in domain '%s':", __func__, name, type, domain); */

(*nut_avahi_address_snprint)(a, sizeof(a), address);
t = (*nut_avahi_string_list_to_string)(txt);

NUT_UNUSED_VARIABLE(flags);
/*
fprintf(stderr,
upsdebugx(1,
"\t%s:%u (%s)\n"
"\tTXT=%s\n"
"\tcookie is %u\n"
Expand Down Expand Up @@ -471,14 +472,14 @@ static void browse_callback(
switch (event) {
case AVAHI_BROWSER_FAILURE:

fprintf(stderr,
"(Browser) %s\n",
upsdebugx(0, "%s: (Browser) %s",
__func__,
(*nut_avahi_strerror)((*nut_avahi_client_errno)((*nut_avahi_service_browser_get_client)(b))));
(*nut_avahi_simple_poll_quit)(simple_poll);
return;

case AVAHI_BROWSER_NEW:
/* fprintf(stderr, "(Browser) NEW: service '%s' of type '%s' in domain '%s'\n", name, type, domain); */
/* upsdebugx(1, "%s: "(Browser) NEW: service '%s' of type '%s' in domain '%s'", __func__, name, type, domain); */

/* We ignore the returned resolver object. In the callback
function we free it. If the server is terminated before
Expand All @@ -498,14 +499,15 @@ static void browse_callback(
#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ASSIGN_ENUM)
# pragma GCC diagnostic pop
#endif
fprintf(stderr,
"Failed to resolve service '%s': %s\n",
upsdebugx(0, "%s: "
"Failed to resolve service '%s': %s",
__func__,
name, (*nut_avahi_strerror)((*nut_avahi_client_errno)(c)));

break;

case AVAHI_BROWSER_REMOVE:
fprintf(stderr, "(Browser) REMOVE: service '%s' of type '%s' in domain '%s'\n", name, type, domain);
upsdebugx(0, "%s: (Browser) REMOVE: service '%s' of type '%s' in domain '%s'", __func__, name, type, domain);
break;

case AVAHI_BROWSER_ALL_FOR_NOW:
Expand All @@ -514,7 +516,7 @@ static void browse_callback(

case AVAHI_BROWSER_CACHE_EXHAUSTED:
fallthrough_AVAHI_BROWSER_CACHE_EXHAUSTED:
/* fprintf(stderr, "(Browser) %s\n", event == AVAHI_BROWSER_CACHE_EXHAUSTED ? "CACHE_EXHAUSTED" : "ALL_FOR_NOW"); */
/* upsdebugx(1, "%s: (Browser) %s", __func__, event == AVAHI_BROWSER_CACHE_EXHAUSTED ? "CACHE_EXHAUSTED" : "ALL_FOR_NOW"); */
break;
}
}
Expand All @@ -526,8 +528,9 @@ static void client_callback(AvahiClient *c, AvahiClientState state, void * userd
/* Called whenever the client or server state changes */

if (state == AVAHI_CLIENT_FAILURE) {
fprintf(stderr,
"Server connection failure: %s\n",
upsdebugx(0, "%s: "
"Server connection failure: %s",
__func__,
(*nut_avahi_strerror)((*nut_avahi_client_errno)(c)));
(*nut_avahi_simple_poll_quit)(simple_poll);
}
Expand Down Expand Up @@ -568,7 +571,8 @@ nutscan_device_t * nutscan_scan_avahi(useconds_t usec_timeout)

/* Allocate main loop object */
if (!(simple_poll = (*nut_avahi_simple_poll_new)())) {
fprintf(stderr, "Failed to create Avahi simple poll object.\n");
upsdebugx(0, "%s: Failed to create Avahi simple poll object.",
__func__);
goto fail;
}

Expand All @@ -577,9 +581,9 @@ nutscan_device_t * nutscan_scan_avahi(useconds_t usec_timeout)

/* Check wether creating the client object succeeded */
if (!client) {
fprintf(stderr,
"Failed to create Avahi client: %s\n",
(*nut_avahi_strerror)(error));
upsdebugx(0, "%s: "
"Failed to create Avahi client: %s",
__func__, (*nut_avahi_strerror)(error));
goto fail;
}

Expand All @@ -596,8 +600,9 @@ nutscan_device_t * nutscan_scan_avahi(useconds_t usec_timeout)
#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ASSIGN_ENUM)
# pragma GCC diagnostic pop
#endif
fprintf(stderr,
"Failed to create Avahi service browser: %s\n",
upsdebugx(0, "%s: "
"Failed to create Avahi service browser: %s",
__func__,
(*nut_avahi_strerror)((*nut_avahi_client_errno)(client)));
goto fail;
}
Expand Down
Loading

0 comments on commit 1fb03cd

Please sign in to comment.