script: add __format__ attribute

Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2021-06-18 16:55:40 +02:00
parent c7da267442
commit 94e4a41406
1 changed files with 7 additions and 5 deletions

View File

@ -147,7 +147,8 @@ struct script_control {
isterm:1; /* is child process running as terminal */ isterm:1; /* is child process running as terminal */
}; };
static ssize_t log_info(struct script_control *ctl, const char *name, const char *msgfmt, ...); static ssize_t log_info(struct script_control *ctl, const char *name, const char *msgfmt, ...)
__attribute__((__format__ (__printf__, 3, 4)));
static void script_init_debug(void) static void script_init_debug(void)
{ {
@ -519,7 +520,8 @@ static ssize_t log_stream_activity(
return outsz; return outsz;
} }
static ssize_t log_signal(struct script_control *ctl, int signum, char *msgfmt, ...) static ssize_t __attribute__ ((__format__ (__printf__, 3, 4)))
log_signal(struct script_control *ctl, int signum, const char *msgfmt, ...)
{ {
struct script_log *log; struct script_log *log;
struct timeval now, delta; struct timeval now, delta;
@ -998,12 +1000,12 @@ int main(int argc, char **argv)
time_t tvec = script_time((time_t *)NULL); time_t tvec = script_time((time_t *)NULL);
strtime_iso(&tvec, ISO_TIMESTAMP, buf, sizeof(buf)); strtime_iso(&tvec, ISO_TIMESTAMP, buf, sizeof(buf));
log_info(&ctl, "START_TIME", buf); log_info(&ctl, "START_TIME", "%s", buf);
if (ctl.isterm) { if (ctl.isterm) {
init_terminal_info(&ctl); init_terminal_info(&ctl);
log_info(&ctl, "TERM", ctl.ttytype); log_info(&ctl, "TERM", "%s", ctl.ttytype);
log_info(&ctl, "TTY", ctl.ttyname); log_info(&ctl, "TTY", "%s", ctl.ttyname);
log_info(&ctl, "COLUMNS", "%d", ctl.ttycols); log_info(&ctl, "COLUMNS", "%d", ctl.ttycols);
log_info(&ctl, "LINES", "%d", ctl.ttylines); log_info(&ctl, "LINES", "%d", ctl.ttylines);
} }