From db4719f0396854dfca4018487a6ed1580426f7ff Mon Sep 17 00:00:00 2001 From: Martin Roth Date: Sat, 13 Feb 2021 23:19:51 -0700 Subject: [PATCH] util/bincfg: Fix all issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the following issues: bincfg.l: In function ‘parsehex’: error: declaration of ‘val’ shadows a global declaration bincfg.y: In function ‘generate_binary_with_gbe_checksum’: error: comparison of integer expressions of different signedness bincfg.y: In function ‘yyerror’: bincfg.y:408:28: error: unused parameter ‘fp’ bincfg.y: In function ‘main’: bincfg.y:452:15: error: unused variable ‘pos’ bincfg.y:451:16: error: unused variable ‘c’ BUG=None TEST=Build outputs and make sure they're identical. Signed-off-by: Martin Roth Change-Id: I60039b741c226a6b6ba53306f6fa293da89e5355 Reviewed-on: https://review.coreboot.org/c/coreboot/+/50653 Tested-by: build bot (Jenkins) Reviewed-by: Arthur Heymans --- util/bincfg/bincfg.l | 6 +++--- util/bincfg/bincfg.y | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/util/bincfg/bincfg.l b/util/bincfg/bincfg.l index ca935476481e..e55d6c609a10 100644 --- a/util/bincfg/bincfg.l +++ b/util/bincfg/bincfg.l @@ -11,7 +11,7 @@ extern struct blob binary; unsigned int parsehex (char *s) { - unsigned int i, nib, val = 0; + unsigned int i, nib, retval = 0; unsigned int nibs = strlen(s) - 2; for (i = 2; i < nibs + 2; i++) { @@ -24,9 +24,9 @@ unsigned int parsehex (char *s) } else { return 0; } - val |= nib << (((nibs - 1) - (i - 2)) * 4); + retval |= nib << (((nibs - 1) - (i - 2)) * 4); } - return val; + return retval; } char* stripquotes (char *string) diff --git a/util/bincfg/bincfg.y b/util/bincfg/bincfg.y index 0aaf13af2876..43b3a00e0df2 100644 --- a/util/bincfg/bincfg.y +++ b/util/bincfg/bincfg.y @@ -223,7 +223,7 @@ static void generate_setter_bitfields(FILE* fp, unsigned char *bin) static void generate_binary_with_gbe_checksum(FILE* fp) { - int i; + unsigned int i; unsigned short checksum; /* traverse spec, push to blob and add up for checksum */ @@ -407,6 +407,7 @@ setpair: /* Called by yyparse on error. */ static void yyerror (FILE* fp, char const *s) { + (void)fp; fprintf (stderr, "yyerror: %s\n", s); } @@ -448,8 +449,6 @@ int main (int argc, char *argv[]) { unsigned int lenspec; unsigned char *parsestring; - unsigned char c; - unsigned int pos = 0; int ret = 0; FILE* fp;