Permalink
Browse files

Fix 2 Wformat-truncation compile warnings

Patch by: michaelortmann
  • Loading branch information...
michaelortmann authored and vanosg committed Nov 2, 2018
1 parent daf06b0 commit d58ad3cc788f56c4a1206704434e86133140182f
Showing with 9 additions and 17 deletions.
  1. +1 −2 src/main.c
  2. +7 −13 src/tclhash.c
  3. +1 −2 src/tclhash.h
@@ -725,8 +725,7 @@ static void core_secondly()
static void core_minutely()
{
check_tcl_time(&nowtm);
check_tcl_cron(&nowtm);
check_tcl_time_and_cron(&nowtm);
do_check_timers(&timer);
if (quick_logs != 0) {
flushlogs();
@@ -1182,16 +1182,21 @@ void check_tcl_away(const char *bot, int idx, const char *msg)
MATCH_MASK | BIND_STACKABLE);
}
void check_tcl_time(struct tm *tm)
void check_tcl_time_and_cron(struct tm *tm)
{
char y[18];
/* Undersized due to sane assumption that struct tm is sane and at the same
* time oversized to silence a gcc format-truncation warning */
char y[24];
egg_snprintf(y, sizeof y, "%02d", tm->tm_min);
Tcl_SetVar(interp, "_time1", (char *) y, 0);
Tcl_SetVar(interp, "_cron1", (char *) y, 0);
egg_snprintf(y, sizeof y, "%02d", tm->tm_hour);
Tcl_SetVar(interp, "_time2", (char *) y, 0);
Tcl_SetVar(interp, "_cron2", (char *) y, 0);
egg_snprintf(y, sizeof y, "%02d", tm->tm_mday);
Tcl_SetVar(interp, "_time3", (char *) y, 0);
Tcl_SetVar(interp, "_cron3", (char *) y, 0);
egg_snprintf(y, sizeof y, "%02d", tm->tm_mon);
Tcl_SetVar(interp, "_time4", (char *) y, 0);
egg_snprintf(y, sizeof y, "%04d", tm->tm_year + 1900);
@@ -1201,18 +1206,7 @@ void check_tcl_time(struct tm *tm)
check_tcl_bind(H_time, y, 0,
" $_time1 $_time2 $_time3 $_time4 $_time5",
MATCH_MASK | BIND_STACKABLE);
}
void check_tcl_cron(struct tm *tm)
{
char y[15];
egg_snprintf(y, sizeof y, "%02d", tm->tm_min);
Tcl_SetVar(interp, "_cron1", (char *) y, 0);
egg_snprintf(y, sizeof y, "%02d", tm->tm_hour);
Tcl_SetVar(interp, "_cron2", (char *) y, 0);
egg_snprintf(y, sizeof y, "%02d", tm->tm_mday);
Tcl_SetVar(interp, "_cron3", (char *) y, 0);
egg_snprintf(y, sizeof y, "%02d", tm->tm_mon + 1);
Tcl_SetVar(interp, "_cron4", (char *) y, 0);
egg_snprintf(y, sizeof y, "%02d", tm->tm_wday);
@@ -95,8 +95,7 @@ void check_tcl_disc(const char *);
const char *check_tcl_filt(int, const char *);
int check_tcl_note(const char *, const char *, const char *);
void check_tcl_listen(const char *, int);
void check_tcl_time(struct tm *);
void check_tcl_cron(struct tm *);
void check_tcl_time_and_cron(struct tm *);
void tell_binds(int, char *);
void check_tcl_nkch(const char *, const char *);
void check_tcl_away(const char *, int, const char *);

0 comments on commit d58ad3c

Please sign in to comment.