From 9225fa6cf16faf59ca9344d21a5d7439adee2755 Mon Sep 17 00:00:00 2001 From: "Darryl L. Miles" Date: Fri, 4 Oct 2024 17:13:24 +0100 Subject: [PATCH] 4 x warning: suggest explicit braces to avoid ambiguous 'else' Give compiler the extra braces it recommends. DBio.c edited as my original change was caught out by the incorrect indention of the 'else' keyword and my modification would have caused a NULL deref. Exactly the kind of issue this warning is trying to prevent. CmdTZ.c:417:20: warning: suggest explicit braces to avoid ambiguous 'else' DBio.c:1422:12: warning: suggest explicit braces to avoid ambiguous 'else' DBpaint2.c:285:12: warning: suggest explicit braces to avoid ambiguous 'else' DBpaint2.c:384:12: warning: suggest explicit braces to avoid ambiguous 'else' GCC14 -Wall cleanup series [-Wdangling-else] --- commands/CmdTZ.c | 2 ++ database/DBio.c | 5 +++-- database/DBpaint2.c | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/commands/CmdTZ.c b/commands/CmdTZ.c index 56fa95b3..8f8681ef 100644 --- a/commands/CmdTZ.c +++ b/commands/CmdTZ.c @@ -415,10 +415,12 @@ CmdTech(w, cmd) for (ctype = TT_TECHDEPBASE; ctype < DBNumUserLayers; ctype++) if (DBIsContact(ctype)) + { if (TTMaskHasType(&DBActiveLayerBits, ctype)) DBUnlockContact(ctype); else DBLockContact(ctype); + } for (ctype = DBNumUserLayers; ctype < DBNumTypes; ctype++) { diff --git a/database/DBio.c b/database/DBio.c index be3f11f0..bf663bac 100644 --- a/database/DBio.c +++ b/database/DBio.c @@ -1420,9 +1420,10 @@ dbReadOpen(cellDef, setFileName, dereference, errptr) pptr = strrchr(sptr, '.'); if (pptr != NULL) + { if (strcmp(pptr, DBSuffix)) pptr = NULL; - else - *pptr = '\0'; + else *pptr = '\0'; + } /* If dereferencing, then use search paths first */ if (!dereference) diff --git a/database/DBpaint2.c b/database/DBpaint2.c index de3a1cbe..aa82305b 100644 --- a/database/DBpaint2.c +++ b/database/DBpaint2.c @@ -283,6 +283,7 @@ DBPaintValid(cellDef, rect, mask, dinfo) for (t = TT_SELECTBASE; t < DBNumUserLayers; t++) if (TTMaskHasType(&mmask, t)) + { if (DBIsContact(t)) { tMask = DBResidueMask(t); @@ -310,6 +311,7 @@ DBPaintValid(cellDef, rect, mask, dinfo) (t << 14) : t) : t); DBPaint(cellDef, rect, tloc); } + } } /* @@ -382,6 +384,7 @@ DBEraseValid(cellDef, rect, mask, dinfo) for (t = TT_SELECTBASE; t < DBNumUserLayers; t++) if (TTMaskHasType(&mmask, t)) + { if (DBIsContact(t)) { tMask = DBResidueMask(t); @@ -409,4 +412,5 @@ DBEraseValid(cellDef, rect, mask, dinfo) (t << 14) : t) : t); DBErase(cellDef, rect, tloc); } + } }