Skip to content

Commit

Permalink
Fix format specifiers for time_t / difftime
Browse files Browse the repository at this point in the history
Found by: michaelortmann
Patch by: michaelortmann
  • Loading branch information
michaelortmann authored Feb 23, 2025
1 parent 1b9bb3d commit 8835a0e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 41 deletions.
30 changes: 6 additions & 24 deletions src/dcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,7 @@ static void timeout_dcc_bot_new(int idx)

static void display_dcc_bot_new(int idx, char *buf)
{
long tv;

tv = now - dcc[idx].timeval;
sprintf(buf, "bot* waited %lis", tv);
sprintf(buf, "bot* waited %" PRId64 "s", (int64_t) (now - dcc[idx].timeval));
}

static int expmem_dcc_bot_(void *x)
Expand Down Expand Up @@ -794,10 +791,7 @@ static void tout_dcc_chat_pass(int idx)

static void display_dcc_chat_pass(int idx, char *buf)
{
long tv;

tv = now - dcc[idx].timeval;
sprintf(buf, "pass waited %lis", tv);
sprintf(buf, "pass waited %" PRId64 "s", (int64_t) (now - dcc[idx].timeval));
}

static int expmem_dcc_general(void *x)
Expand Down Expand Up @@ -1858,10 +1852,7 @@ static void timeout_dcc_telnet_id(int idx)

static void display_dcc_telnet_id(int idx, char *buf)
{
long tv;

tv = now - dcc[idx].timeval;
sprintf(buf, "t-in waited %lis", tv);
sprintf(buf, "t-in waited %" PRId64 "s", (int64_t) (now - dcc[idx].timeval));
}

struct dcc_table DCC_TELNET_ID = {
Expand Down Expand Up @@ -2012,18 +2003,12 @@ static void tout_dcc_telnet_pw(int idx)

static void display_dcc_telnet_new(int idx, char *buf)
{
long tv;

tv = now - dcc[idx].timeval;
sprintf(buf, "new waited %lis", tv);
sprintf(buf, "new waited %" PRId64 "s", (int64_t) (now - dcc[idx].timeval));
}

static void display_dcc_telnet_pw(int idx, char *buf)
{
long tv;

tv = now - dcc[idx].timeval;
sprintf(buf, "newp waited %lis", tv);
sprintf(buf, "newp waited %" PRId64 "s", (int64_t) (now - dcc[idx].timeval));
}

struct dcc_table DCC_TELNET_NEW = {
Expand Down Expand Up @@ -2259,10 +2244,7 @@ void eof_dcc_identwait(int idx)

static void display_dcc_identwait(int idx, char *buf)
{
long tv;

tv = now - dcc[idx].timeval;
sprintf(buf, "idtw waited %lis", tv);
sprintf(buf, "idtw waited %" PRId64 "s", (int64_t) (now - dcc[idx].timeval));
}

struct dcc_table DCC_IDENTWAIT = {
Expand Down
5 changes: 1 addition & 4 deletions src/mod/filesys.mod/filesys.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,10 +524,7 @@ static void disp_dcc_files(int idx, char *buf)

static void disp_dcc_files_pass(int idx, char *buf)
{
long tv;

tv = now - dcc[idx].timeval;
sprintf(buf, "fpas waited %lis", tv);
sprintf(buf, "fpas waited %" PRId64 "s", (int64_t) (now - dcc[idx].timeval));
}

static void kill_dcc_files(int idx, void *x)
Expand Down
8 changes: 2 additions & 6 deletions src/userent.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,13 +422,11 @@ static int laston_unpack(struct userrec *u, struct user_entry *e)
static int laston_pack(struct userrec *u, struct user_entry *e)
{
char work[1024];
long tv;
struct laston_info *li;
int l;

li = (struct laston_info *) e->u.extra;
tv = li->laston;
l = sprintf(work, "%lu %s", tv, li->lastonplace);
l = sprintf(work, "%" PRId64 " %s", (int64_t) li->laston, li->lastonplace);
e->u.list = user_malloc(sizeof(struct list_type));
e->u.list->next = NULL;
e->u.list->extra = user_malloc(l + 1);
Expand All @@ -441,11 +439,9 @@ static int laston_pack(struct userrec *u, struct user_entry *e)
static int laston_write_userfile(FILE *f, struct userrec *u,
struct user_entry *e)
{
long tv;
struct laston_info *li = (struct laston_info *) e->u.extra;

tv = li->laston;
if (fprintf(f, "--LASTON %lu %s\n", tv,
if (fprintf(f, "--LASTON %" PRId64 " %s\n", (int64_t) li->laston,
li->lastonplace ? li->lastonplace : "") == EOF)
return 0;
return 1;
Expand Down
10 changes: 3 additions & 7 deletions src/userrec.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,6 @@ int u_pass_match(struct userrec *u, char *pass)
int write_user(struct userrec *u, FILE *f, int idx)
{
char s[181];
long tv;
struct chanuserrec *ch;
struct chanset_t *cst;
struct user_entry *ue;
Expand All @@ -510,8 +509,7 @@ int write_user(struct userrec *u, FILE *f, int idx)
fr.chan = ch->flags;
fr.udef_chan = ch->flags_udef;
build_flags(s, &fr, NULL);
tv = ch->laston;
if (fprintf(f, "! %-20s %lu %-10s %s\n", ch->channel, tv, s,
if (fprintf(f, "! %-20s %" PRId64 " %-10s %s\n", ch->channel, (int64_t) ch->laston, s,
(((idx < 0) || share_greet) && ch->info) ? ch->info : "") == EOF)
return 0;
}
Expand Down Expand Up @@ -728,7 +726,6 @@ struct userrec *adduser(struct userrec *bu, char *handle, char *host,
struct userrec *u, *x;
struct xtra_key *xk;
int oldshare = noshare;
time_t tv;

noshare = 1;
u = nmalloc(sizeof *u);
Expand All @@ -751,10 +748,9 @@ struct userrec *adduser(struct userrec *bu, char *handle, char *host,
xk = nmalloc(sizeof *xk);
xk->key = nmalloc(8);
strcpy(xk->key, "created");
tv = now;
l = snprintf(NULL, 0, "%" PRId64, (int64_t) tv);
l = snprintf(NULL, 0, "%" PRId64, (int64_t) now);
xk->data = nmalloc(l + 1);
sprintf(xk->data, "%" PRId64, (int64_t) tv);
sprintf(xk->data, "%" PRId64, (int64_t) now);
set_user(&USERENTRY_XTRA, u, xk);
}
/* Strip out commas -- they're illegal */
Expand Down

0 comments on commit 8835a0e

Please sign in to comment.