From b89294846e123f62d1377a160b1b4f3836f82da2 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 15 Oct 2022 20:46:03 -0700 Subject: [PATCH] cgraph storeFileName: squash warnings when dealing with buffer lengths MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This removes the following compiler warnings which were particularly problematic as they were pointing to the wrong source lines. It is unclear whether this is due to a Flex bug or the way we are calling Flex. ../../lib/cgraph/scan.l: In function ‘storeFileName’: ../../lib/cgraph/scan.l:98:28: warning: conversion to ‘size_t’ {aka ‘long unsigned int’} from ‘int’ may change the sign of the result [-Wsign-conversion] 98 | static char* buf; | ^ ../../lib/cgraph/scan.l:98:37: warning: conversion to ‘size_t’ {aka ‘long unsigned int’} from ‘int’ may change the sign of the result [-Wsign-conversion] 98 | static char* buf; | ^ ../../lib/cgraph/scan.l: In function ‘ppDirective’: ../../lib/cgraph/scan.l:125:29: warning: conversion from ‘long int’ to ‘int’ may change value [-Wconversion] 125 | while (*e && *e != '"') e++; | ~^~ --- lib/cgraph/scan.l | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/cgraph/scan.l b/lib/cgraph/scan.l index 32c394bef..ee8e60f0c 100644 --- a/lib/cgraph/scan.l +++ b/lib/cgraph/scan.l @@ -91,10 +91,8 @@ static void endstr_html(void) { aaglval.str = agstrdup_html(Ag_G_global, agxbuse(&Sbuf)); } -static void -storeFileName (char* fname, int len) -{ - static int cnt; +static void storeFileName(char* fname, size_t len) { + static size_t cnt; static char* buf; if (len > cnt) { @@ -125,7 +123,7 @@ static void ppDirective (void) while (*e && *e != '"') e++; if (e != p && *e == '"') { *e = '\0'; - storeFileName (p, e-p); + storeFileName(p, (size_t)(e - p)); } } } -- 2.40.0