From 92616429093e16f938aeca92e1045174835c2a8d Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 24 Sep 2026 13:28:05 -0400 Subject: [PATCH] Suppress -Wshadow=local warnings in REG_DEBUG code. Our Solaris-camp buildfarm animals (billbug, hake, pollock, so far) are complaining about dumpcolors()'s local variables in the wake of 3ee0edb91. This is unsurprising on one level, since that code clearly violates the new expectation; but AFAICS these animals aren't explicitly enabling -DREG_DEBUG, so how are they reaching the now-faulty code? Do Solaris' headers #define that? In any case, the fix is simple enough, just narrow the declaration scopes of this function's loop variables. (I could have done that only to "c", but thought it best to maintain a consistent style in this function.) I don't see any need to back-patch this. --- src/backend/regex/regc_color.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/backend/regex/regc_color.c b/src/backend/regex/regc_color.c index 1587f452ea3..98e4b8b9d6f 100644 --- a/src/backend/regex/regc_color.c +++ b/src/backend/regex/regc_color.c @@ -1127,7 +1127,6 @@ dumpcolors(struct colormap *cm, struct colordesc *cd; struct colordesc *end; color co; - chr c; fprintf(f, "max %ld\n", (long) cm->max); end = CDEND(cm); @@ -1144,7 +1143,7 @@ dumpcolors(struct colormap *cm, /* * Unfortunately, it's hard to do this next bit more efficiently. */ - for (c = CHR_MIN; c <= MAX_SIMPLE_CHR; c++) + for (chr c = CHR_MIN; c <= MAX_SIMPLE_CHR; c++) if (GETCOLOR(cm, c) == co) dumpchr(c, f); fprintf(f, "\n"); @@ -1153,24 +1152,22 @@ dumpcolors(struct colormap *cm, /* dump the high colormap if it contains anything interesting */ if (cm->hiarrayrows > 1 || cm->hiarraycols > 1) { - int r, - c; - const color *rowptr; - fprintf(f, "other:\t"); - for (c = 0; c < cm->hiarraycols; c++) + for (int c = 0; c < cm->hiarraycols; c++) { fprintf(f, "\t%ld", (long) cm->hicolormap[c]); } fprintf(f, "\n"); - for (r = 0; r < cm->numcmranges; r++) + for (int r = 0; r < cm->numcmranges; r++) { + const color *rowptr; + dumpchr(cm->cmranges[r].cmin, f); fprintf(f, ".."); dumpchr(cm->cmranges[r].cmax, f); fprintf(f, ":"); rowptr = &cm->hicolormap[cm->cmranges[r].rownum * cm->hiarraycols]; - for (c = 0; c < cm->hiarraycols; c++) + for (int c = 0; c < cm->hiarraycols; c++) { fprintf(f, "\t%ld", (long) rowptr[c]); }