commit 16d61a8bc15dd706c6e8ca85bbbbd91d774352ce from: Markus Uhlin date: Mon Aug 4 17:57:15 2025 UTC Stored the scan format in a var commit - 36cf1d984f751bad1e27981382a674f2ce5da0a4 commit + 16d61a8bc15dd706c6e8ca85bbbbd91d774352ce blob - 301c305863054d393f81669a78e84314a4e28db4 blob + bf69bf0adcbe8d7ed33329cf08594e5b0b57e5d1 --- FICS/command.c +++ FICS/command.c @@ -722,6 +722,7 @@ rscan_news(FILE *fp, int p, time_t lc) char count[10] = { '\0' }; char junk[MAX_LINE_SIZE] = { '\0' }; char *junkp = NULL; + const char *scan_fmt = "%" SCNd64 " " "%9s"; int64_t lval = 0; time_t crtime = 0; @@ -731,7 +732,7 @@ rscan_news(FILE *fp, int p, time_t lc) _Static_assert(ARRAY_SIZE(count) > 9, "Unexpected array size"); - if (sscanf(junk, ("%" SCNd64 " " "%9s"), &lval, count) != 2) { + if (sscanf(junk, scan_fmt, &lval, count) != 2) { warnx("%s: sscanf() error: too few items", __func__); return; } @@ -755,12 +756,12 @@ rscan_news(FILE *fp, int p, time_t lc) PRIVATE void check_news(int p, int admin) { -#define SCAN_JUNK ("%" SCNd64 " " "%9s") FILE *fp = NULL; char count[10] = { '\0' }; char filename[MAX_FILENAME_SIZE] = { '\0' }; char junk[MAX_LINE_SIZE] = { '\0' }; char *junkp = NULL; + const char *v_scan_fmt = "%" SCNd64 " " "%9s"; int64_t lval = 0; time_t crtime = 0; time_t lc = player_lastconnect(p); @@ -791,7 +792,7 @@ check_news(int p, int admin) warnx("%s: fgets() error", __func__); fclose(fp); return; - } else if (sscanf(junk, SCAN_JUNK, &lval, count) != 2) { + } else if (sscanf(junk, v_scan_fmt, &lval, count) != 2) { warnx("%s: sscanf() error", __func__); fclose(fp); return; @@ -841,7 +842,7 @@ check_news(int p, int admin) warnx("%s: fgets() error", __func__); fclose(fp); return; - } else if (sscanf(junk, SCAN_JUNK, &lval, count) != 2) { + } else if (sscanf(junk, v_scan_fmt, &lval, count) != 2) { warnx("%s: sscanf() error", __func__); fclose(fp); return;