From: Matthew Fernandez Date: Sun, 16 Oct 2022 03:46:03 +0000 (-0700) Subject: cgraph storeFileName: squash warnings when dealing with buffer lengths X-Git-Tag: 7.0.0~2^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b89294846e123f62d1377a160b1b4f3836f82da2;p=graphviz cgraph storeFileName: squash warnings when dealing with buffer lengths 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++; | ~^~ --- 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)); } } }