Skip to content

Commit 8835a0e

Browse files
Fix format specifiers for time_t / difftime
Found by: michaelortmann Patch by: michaelortmann
1 parent 1b9bb3d commit 8835a0e

File tree

4 files changed

+12
-41
lines changed

4 files changed

+12
-41
lines changed

src/dcc.c

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -431,10 +431,7 @@ static void timeout_dcc_bot_new(int idx)
431431

432432
static void display_dcc_bot_new(int idx, char *buf)
433433
{
434-
long tv;
435-
436-
tv = now - dcc[idx].timeval;
437-
sprintf(buf, "bot* waited %lis", tv);
434+
sprintf(buf, "bot* waited %" PRId64 "s", (int64_t) (now - dcc[idx].timeval));
438435
}
439436

440437
static int expmem_dcc_bot_(void *x)
@@ -794,10 +791,7 @@ static void tout_dcc_chat_pass(int idx)
794791

795792
static void display_dcc_chat_pass(int idx, char *buf)
796793
{
797-
long tv;
798-
799-
tv = now - dcc[idx].timeval;
800-
sprintf(buf, "pass waited %lis", tv);
794+
sprintf(buf, "pass waited %" PRId64 "s", (int64_t) (now - dcc[idx].timeval));
801795
}
802796

803797
static int expmem_dcc_general(void *x)
@@ -1858,10 +1852,7 @@ static void timeout_dcc_telnet_id(int idx)
18581852

18591853
static void display_dcc_telnet_id(int idx, char *buf)
18601854
{
1861-
long tv;
1862-
1863-
tv = now - dcc[idx].timeval;
1864-
sprintf(buf, "t-in waited %lis", tv);
1855+
sprintf(buf, "t-in waited %" PRId64 "s", (int64_t) (now - dcc[idx].timeval));
18651856
}
18661857

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

20132004
static void display_dcc_telnet_new(int idx, char *buf)
20142005
{
2015-
long tv;
2016-
2017-
tv = now - dcc[idx].timeval;
2018-
sprintf(buf, "new waited %lis", tv);
2006+
sprintf(buf, "new waited %" PRId64 "s", (int64_t) (now - dcc[idx].timeval));
20192007
}
20202008

20212009
static void display_dcc_telnet_pw(int idx, char *buf)
20222010
{
2023-
long tv;
2024-
2025-
tv = now - dcc[idx].timeval;
2026-
sprintf(buf, "newp waited %lis", tv);
2011+
sprintf(buf, "newp waited %" PRId64 "s", (int64_t) (now - dcc[idx].timeval));
20272012
}
20282013

20292014
struct dcc_table DCC_TELNET_NEW = {
@@ -2259,10 +2244,7 @@ void eof_dcc_identwait(int idx)
22592244

22602245
static void display_dcc_identwait(int idx, char *buf)
22612246
{
2262-
long tv;
2263-
2264-
tv = now - dcc[idx].timeval;
2265-
sprintf(buf, "idtw waited %lis", tv);
2247+
sprintf(buf, "idtw waited %" PRId64 "s", (int64_t) (now - dcc[idx].timeval));
22662248
}
22672249

22682250
struct dcc_table DCC_IDENTWAIT = {

src/mod/filesys.mod/filesys.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -524,10 +524,7 @@ static void disp_dcc_files(int idx, char *buf)
524524

525525
static void disp_dcc_files_pass(int idx, char *buf)
526526
{
527-
long tv;
528-
529-
tv = now - dcc[idx].timeval;
530-
sprintf(buf, "fpas waited %lis", tv);
527+
sprintf(buf, "fpas waited %" PRId64 "s", (int64_t) (now - dcc[idx].timeval));
531528
}
532529

533530
static void kill_dcc_files(int idx, void *x)

src/userent.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -422,13 +422,11 @@ static int laston_unpack(struct userrec *u, struct user_entry *e)
422422
static int laston_pack(struct userrec *u, struct user_entry *e)
423423
{
424424
char work[1024];
425-
long tv;
426425
struct laston_info *li;
427426
int l;
428427

429428
li = (struct laston_info *) e->u.extra;
430-
tv = li->laston;
431-
l = sprintf(work, "%lu %s", tv, li->lastonplace);
429+
l = sprintf(work, "%" PRId64 " %s", (int64_t) li->laston, li->lastonplace);
432430
e->u.list = user_malloc(sizeof(struct list_type));
433431
e->u.list->next = NULL;
434432
e->u.list->extra = user_malloc(l + 1);
@@ -441,11 +439,9 @@ static int laston_pack(struct userrec *u, struct user_entry *e)
441439
static int laston_write_userfile(FILE *f, struct userrec *u,
442440
struct user_entry *e)
443441
{
444-
long tv;
445442
struct laston_info *li = (struct laston_info *) e->u.extra;
446443

447-
tv = li->laston;
448-
if (fprintf(f, "--LASTON %lu %s\n", tv,
444+
if (fprintf(f, "--LASTON %" PRId64 " %s\n", (int64_t) li->laston,
449445
li->lastonplace ? li->lastonplace : "") == EOF)
450446
return 0;
451447
return 1;

src/userrec.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,6 @@ int u_pass_match(struct userrec *u, char *pass)
485485
int write_user(struct userrec *u, FILE *f, int idx)
486486
{
487487
char s[181];
488-
long tv;
489488
struct chanuserrec *ch;
490489
struct chanset_t *cst;
491490
struct user_entry *ue;
@@ -510,8 +509,7 @@ int write_user(struct userrec *u, FILE *f, int idx)
510509
fr.chan = ch->flags;
511510
fr.udef_chan = ch->flags_udef;
512511
build_flags(s, &fr, NULL);
513-
tv = ch->laston;
514-
if (fprintf(f, "! %-20s %lu %-10s %s\n", ch->channel, tv, s,
512+
if (fprintf(f, "! %-20s %" PRId64 " %-10s %s\n", ch->channel, (int64_t) ch->laston, s,
515513
(((idx < 0) || share_greet) && ch->info) ? ch->info : "") == EOF)
516514
return 0;
517515
}
@@ -728,7 +726,6 @@ struct userrec *adduser(struct userrec *bu, char *handle, char *host,
728726
struct userrec *u, *x;
729727
struct xtra_key *xk;
730728
int oldshare = noshare;
731-
time_t tv;
732729

733730
noshare = 1;
734731
u = nmalloc(sizeof *u);
@@ -751,10 +748,9 @@ struct userrec *adduser(struct userrec *bu, char *handle, char *host,
751748
xk = nmalloc(sizeof *xk);
752749
xk->key = nmalloc(8);
753750
strcpy(xk->key, "created");
754-
tv = now;
755-
l = snprintf(NULL, 0, "%" PRId64, (int64_t) tv);
751+
l = snprintf(NULL, 0, "%" PRId64, (int64_t) now);
756752
xk->data = nmalloc(l + 1);
757-
sprintf(xk->data, "%" PRId64, (int64_t) tv);
753+
sprintf(xk->data, "%" PRId64, (int64_t) now);
758754
set_user(&USERENTRY_XTRA, u, xk);
759755
}
760756
/* Strip out commas -- they're illegal */

0 commit comments

Comments
 (0)