scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 8a12777187779837b55e84a8cae473f2b41527cd
parent 6b911721fbe864d1966a471c6b0f111ea5083aaf
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 22 Jul 2015 18:13:13 +0200

Fix printf alike format strings

Pointer substraction generates ptrdiff_t values, which maybe
are equal to int or maybe no. In this case we now for sure
the values will smaller than 32768, so we can safely cast it
to int.
Thanks to pancake who reported it!

Diffstat:
Mcc1/cpp.c | 2+-
Mcc1/symbol.c | 2+-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/cc1/cpp.c b/cc1/cpp.c @@ -284,7 +284,7 @@ getdefs(Symbol *args[NR_MACROARG], int nargs, char *bp, size_t bufsiz) break; } if (argp != &args[nargs]) { - sprintf(yytext, "@%02d@", argp - args); + sprintf(yytext, "@%02d@", (int) (argp - args)); ispar = 1; } } diff --git a/cc1/symbol.c b/cc1/symbol.c @@ -27,7 +27,7 @@ dumpstab(char *msg) for (bp = htab; bp < &htab[NR_SYM_HASH]; ++bp) { if (*bp == NULL) continue; - fprintf(stderr, "%d", bp - htab); + fprintf(stderr, "%d", (int) (bp - htab)); for (sym = *bp; sym; sym = sym->hash) fprintf(stderr, "->%d:%s", sym->ns, sym->name); putc('\n', stderr);