Merge pull request #380 from marckleinebudde/fix-fname-scope

candump: main(): fix scope of fname
pull/387/head
Marc Kleine-Budde 2022-09-29 12:50:05 +02:00 committed by GitHub
commit 71a0156bd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -317,7 +317,8 @@ int main(int argc, char **argv)
struct timeval tv, last_tv;
int timeout_ms = -1; /* default to no timeout */
FILE *logfile = NULL;
char *logname = NULL;
char fname[83]; /* suggested by -Wformat-overflow= */
const char *logname = NULL;
signal(SIGTERM, sigterm);
signal(SIGHUP, sigterm);
@ -669,7 +670,6 @@ int main(int argc, char **argv)
if (!logname) {
time_t currtime;
struct tm now;
char fname[83]; /* suggested by -Wformat-overflow= */
if (time(&currtime) == (time_t)-1) {
perror("time");
@ -678,7 +678,7 @@ int main(int argc, char **argv)
localtime_r(&currtime, &now);
sprintf(fname, "candump-%04d-%02d-%02d_%02d%02d%02d.log",
snprintf(fname, sizeof(fname), "candump-%04d-%02d-%02d_%02d%02d%02d.log",
now.tm_year + 1900,
now.tm_mon + 1,
now.tm_mday,