Adjustments and annotations as per splint and flawfinder reports.

This commit is contained in:
Andrew Wood
2023-08-14 23:07:37 +01:00
parent b2989efd5c
commit 4cd28b23f0
5 changed files with 22 additions and 12 deletions
+2 -2
View File
@@ -115,8 +115,8 @@ extern void pv_state_size_set(pvstate_t, unsigned long long);
extern void pv_state_interval_set(pvstate_t, double);
extern void pv_state_width_set(pvstate_t, unsigned int);
extern void pv_state_height_set(pvstate_t, unsigned int);
extern void pv_state_name_set(pvstate_t, const char *);
extern void pv_state_format_string_set(pvstate_t, const char *);
extern void pv_state_name_set(pvstate_t, /*@null@*/ const char *);
extern void pv_state_format_string_set(pvstate_t, /*@null@*/ const char *);
extern void pv_state_watch_pid_set(pvstate_t, unsigned int);
extern void pv_state_watch_fd_set(pvstate_t, int);
extern void pv_state_average_rate_window_set(pvstate_t, unsigned int);
+2 -7
View File
@@ -216,13 +216,8 @@ int main(int argc, char **argv)
pv_state_target_buffer_size_set(state, opts->buffer_size);
pv_state_no_splice_set(state, opts->no_splice);
pv_state_size_set(state, opts->size);
if (NULL != opts->name)
pv_state_name_set(state, opts->name);
if (NULL != opts->format)
pv_state_format_string_set(state, opts->format);
pv_state_name_set(state, opts->name);
pv_state_format_string_set(state, opts->format);
pv_state_watch_pid_set(state, opts->watch_pid);
pv_state_watch_fd_set(state, opts->watch_fd);
pv_state_average_rate_window_set(state, opts->average_rate_window);
+1 -1
View File
@@ -130,7 +130,7 @@ bool opts_add_file(opts_t opts, const char *filename)
* aren't copied anywhere, just the pointers are copied, so make sure the
* command line data isn't overwritten or argv[1] free()d or whatever.
*/
/*@null@ *//*@only@ */
/*@null@ *//*@only@ */
opts_t opts_parse(unsigned int argc, char **argv)
{
#ifdef HAVE_GETOPT_LONG
+15
View File
@@ -64,7 +64,9 @@ static key_t remote__genkey(void)
uid_t uid;
key_t key;
/*@-type@ *//* splint doesn't like uid_t */
uid = geteuid();
/*@+type@ */
key = ftok("/tmp", (int) 'P') | uid;
@@ -79,7 +81,9 @@ static key_t remote__genkey(void)
static int remote__msgget(void)
{
/* Catch SIGSYS in case msgget() raises it, so we get ENOSYS */
/*@-unrecog@ *//* splint doesn't see SIGSYS */
(void) signal(SIGSYS, SIG_IGN);
/*@+unrecog@ */
return msgget(remote__genkey(), IPC_CREAT | 0600);
}
@@ -177,7 +181,9 @@ int pv_remote_set(opts_t opts)
memset(&tv, 0, sizeof(tv));
tv.tv_sec = 0;
tv.tv_usec = 10000;
/*@-nullpass@ *//* splint: NULL is OK with select() */
(void) select(0, NULL, NULL, NULL, &tv);
/*@+nullpass@ */
timeout -= 10000;
/*
@@ -212,8 +218,15 @@ int pv_remote_set(opts_t opts)
}
}
/*@-mustfreefresh@ */
/*
* splint note: the gettext calls made by _() cause memory leak
* warnings, but in this case it's unavoidable, and mitigated by the
* fact we only translate each string once.
*/
fprintf(stderr, "%s: %u: %s\n", opts->program_name, opts->remote, _("message not received"));
return 1;
/*@+mustfreefresh @ */
}
@@ -239,9 +252,11 @@ void pv_remote_check(pvstate_t state)
/*
* If our queue had been deleted, re-create it.
*/
/*@-unrecog@ *//* splint doesn't see ENOMSG */
if (errno != EAGAIN && errno != ENOMSG) {
remote__msgid = remote__msgget();
}
/*@+unrecog@ */
}
if (got < 1)
return;
+2 -2
View File
@@ -241,12 +241,12 @@ void pv_state_height_set(pvstate_t state, unsigned int val)
state->height = val;
};
void pv_state_name_set(pvstate_t state, const char *val)
void pv_state_name_set(pvstate_t state, /*@null@ */ const char *val)
{
state->name = val;
};
void pv_state_format_string_set(pvstate_t state, const char *val)
void pv_state_format_string_set(pvstate_t state, /*@null@ */ const char *val)
{
state->format_string = val;
};