[hackers] [scc] Fix printf alike format strings || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Wed, 22 Jul 2015 18:16:08 +0200 (CEST)

commit 8a12777187779837b55e84a8cae473f2b41527cd
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Wed Jul 22 18:13:13 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Wed Jul 22 18:13:13 2015 +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!

diff --git a/cc1/cpp.c b/cc1/cpp.c
index f3f9002..8e9f3e5 100644
--- a/cc1/cpp.c
+++ b/cc1/cpp.c
_AT_@ -284,7 +284,7 @@ getdefs(Symbol *args[NR_MACROARG], int nargs, char *bp, size_t bufsiz)
                                         break;
                         }
                         if (argp != &args[nargs]) {
- sprintf(yytext, "_AT_%02d@", argp - args);
+ sprintf(yytext, "_AT_%02d@", (int) (argp - args));
                                 ispar = 1;
                         }
                 }
diff --git a/cc1/symbol.c b/cc1/symbol.c
index 6e38406..c581dd1 100644
--- a/cc1/symbol.c
+++ b/cc1/symbol.c
_AT_@ -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);
Received on Wed Jul 22 2015 - 18:16:08 CEST

This archive was generated by hypermail 2.3.0 : Wed Jul 22 2015 - 18:24:11 CEST