From ca123fb72492b9445731d9d5b65d602577a2ed20 Mon Sep 17 00:00:00 2001 From: heinzel Date: Tue, 9 Oct 2012 10:34:47 +0200 Subject: [PATCH] Some minor fixes and improvments: 1. Fixed compiler warnings about incompatible usage of time_t in snprintf and fprintf format strings (Line 85 and 102). 2. Fixed usage of wronge time variable in failsafe error message (Line 102). 3. Clearified error message about wrong timestamp format. It now says integer instead of numeric (Line 87). --- unixtime.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/unixtime.c b/unixtime.c index 0a3cc46..b813a64 100644 --- a/unixtime.c +++ b/unixtime.c @@ -82,16 +82,16 @@ int main(int argc, char** argv) { t = atol(argv[i]); l = strlen(argv[i]); if((p = malloc(l + 1)) != NULL) { - snprintf(p, l + 1, "%d", t); + snprintf(p, l + 1, "%ld", t); if(strcmp(argv[i], p)) { - fprintf(stderr, "%s: not numeric: %s\n", progname, + fprintf(stderr, "%s: not integer: %s\n", progname, argv[i]); exit(EX_DATAERR); } free(p); } else { fprintf(stderr, "%s: Warning: cannot allocate memory" - " to do numeric test on input.\n", progname); + " to do integer test on input.\n", progname); } break; } @@ -99,7 +99,7 @@ int main(int argc, char** argv) { p = ctime((& t)); if(p == NULL) { - fprintf(stderr, "%s: unrecognized date '%d'.\n", progname, time); + fprintf(stderr, "%s: unrecognized date '%ld'.\n", progname, t); exit(EX_DATAERR); } fputs(p, stdout);