From: Matthew Fernandez Date: Mon, 9 May 2022 02:30:23 +0000 (-0700) Subject: mm2gv: squash -Wconversion warnings for 'tolower' usage X-Git-Tag: 4.0.0~38^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6c29170f9f29466374fbc6e8e62a1b6916c6bc59;p=graphviz mm2gv: squash -Wconversion warnings for 'tolower' usage For historical reasons, C functions/macros like `tolower` are specified to take and return an `int`. This means sometimes one set of pedantic compilers (MinGW with -Wconversion) complains about passing `char` values into these ctype.h interfaces and another set of pedantic compilers (GCC with -Wconversion) complains about coercing the result into a `char`. This change suppresses both of these false positives. --- diff --git a/cmd/tools/mmio.c b/cmd/tools/mmio.c index effb523be..89627e736 100644 --- a/cmd/tools/mmio.c +++ b/cmd/tools/mmio.c @@ -44,10 +44,11 @@ int mm_read_banner(FILE * f, MM_typecode * matcode) storage_scheme) != 5) return MM_PREMATURE_EOF; - for (p = mtx; *p != '\0'; *p = tolower(*p), p++); /* convert to lower case */ - for (p = crd; *p != '\0'; *p = tolower(*p), p++); - for (p = data_type; *p != '\0'; *p = tolower(*p), p++); - for (p = storage_scheme; *p != '\0'; *p = tolower(*p), p++); + // convert to lower case + for (p = mtx; *p != '\0'; *p = (char)tolower((int)*p), p++); + for (p = crd; *p != '\0'; *p = (char)tolower((int)*p), p++); + for (p = data_type; *p != '\0'; *p = (char)tolower((int)*p), p++); + for (p = storage_scheme; *p != '\0'; *p = (char)tolower((int)*p), p++); /* check for banner */ if (strncmp(banner, MatrixMarketBanner, strlen(MatrixMarketBanner)) !=