From a7f392e3c3f34f7dc87a8e8d108775ea85d33c45 Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Sun, 27 Jul 2025 21:34:46 +0100 Subject: [PATCH] Address splint warnings about setting and clearing state->control.name (#165). --- src/include/pv-internal.h | 2 +- src/pv/loop.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/include/pv-internal.h b/src/include/pv-internal.h index 4c38807..78312ce 100644 --- a/src/include/pv-internal.h +++ b/src/include/pv-internal.h @@ -494,7 +494,7 @@ struct pvwatchfd_s { char file_fd[PV_SIZEOF_FILE_FD]; /* path to /proc fd symlink */ #endif char file_fdpath[PV_SIZEOF_FILE_FDPATH]; /* path to file that was opened */ - char display_name[PV_SIZEOF_DISPLAY_NAME]; /* name to show on progress bar */ + /*@keep@ */ char display_name[PV_SIZEOF_DISPLAY_NAME]; /* name to show on progress bar */ struct stat sb_fd; /* stat of fd symlink */ struct stat sb_fd_link; /* lstat of fd symlink */ off_t size; /* size of whole file, 0 if unknown */ diff --git a/src/pv/loop.c b/src/pv/loop.c index e4d1916..cbacb8b 100644 --- a/src/pv/loop.c +++ b/src/pv/loop.c @@ -1003,7 +1003,14 @@ int pv_watchpid_loop(pvstate_t state) &(state->control), &(info_array[idx].state->flags), &(info_array[idx].state->transfer), &(info_array[idx].state->calc), &(state->cursor), &(info_array[idx].state->display), NULL, false); + /*@-mustfreeonly@ */ state->control.name = NULL; + /* + * splint warns of a memory leak, but we'd + * set name to be an alias of display_name, + * so nothing is lost here. + */ + /*@+mustfreeonly@ */ displayed_lines++; } }