Skip to content

Commit b1f5e54

Browse files
committed
common/common.c: hide if (strlen(EXEEXT)) from "-Wunreachable-code" [#3302]
On platforms without EXEEXT the compiler is smart enough to say this is always false. Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
1 parent fc699da commit b1f5e54

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

common/common.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4251,6 +4251,16 @@ static void proctag_cleanup(void)
42514251
char *pn = xstrdup(getmyprocbasename());
42524252
char *tn = xstrdup(proctag);
42534253

4254+
#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE
4255+
#pragma GCC diagnostic push
4256+
#endif
4257+
#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE
4258+
#pragma GCC diagnostic ignored "-Wunreachable-code"
4259+
#endif
4260+
#ifdef __clang__
4261+
#pragma clang diagnostic push
4262+
#pragma clang diagnostic ignored "-Wunreachable-code"
4263+
#endif
42544264
if (strlen(EXEEXT) > 0) {
42554265
/* TOTHINK: Generalize provided-if-missing strcasestr()? */
42564266
char *s;
@@ -4264,6 +4274,12 @@ static void proctag_cleanup(void)
42644274
if (s) *s='\0';
42654275
}
42664276
}
4277+
#ifdef __clang__
4278+
#pragma clang diagnostic pop
4279+
#endif
4280+
#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE
4281+
#pragma GCC diagnostic pop
4282+
#endif
42674283

42684284
if (pn && tn && !strcmp(pn, tn)) {
42694285
/* Avoid reporting this line as misleading "sub-process"
@@ -4327,6 +4343,16 @@ void setproctag(const char *tag)
43274343
char *tn = xstrdup(tag);
43284344
int tagged = 0;
43294345

4346+
#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE
4347+
#pragma GCC diagnostic push
4348+
#endif
4349+
#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE
4350+
#pragma GCC diagnostic ignored "-Wunreachable-code"
4351+
#endif
4352+
#ifdef __clang__
4353+
#pragma clang diagnostic push
4354+
#pragma clang diagnostic ignored "-Wunreachable-code"
4355+
#endif
43304356
if (strlen(EXEEXT) > 0) {
43314357
/* TOTHINK: Generalize provided-if-missing strcasestr()?
43324358
* One implementation is currently tucked away in
@@ -4343,6 +4369,12 @@ void setproctag(const char *tag)
43434369
if (s) *s='\0';
43444370
}
43454371
}
4372+
#ifdef __clang__
4373+
#pragma clang diagnostic pop
4374+
#endif
4375+
#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE
4376+
#pragma GCC diagnostic pop
4377+
#endif
43464378

43474379
if (pn && tn && getenv("NUT_DEBUG_PROCNAME") != NULL && strcmp(pn, tn)) {
43484380
/* Only add the process name if asked for and substantially

0 commit comments

Comments
 (0)