Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix more format specifiers for time_t / difftime #1482

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 6 additions & 24 deletions src/dcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,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 @@ -784,10 +781,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 @@ -1839,10 +1833,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 @@ -1993,18 +1984,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 @@ -2240,10 +2225,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 @@ -528,10 +528,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 @@ -413,7 +413,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 @@ -438,8 +437,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 @@ -656,7 +654,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 @@ -679,10 +676,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