From b85a31415e8d68d0d46a105b1033a92669224682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Tue, 8 Sep 2020 13:59:30 +0200 Subject: [PATCH] Avoid checking of undefined macros These feature macros are either define or not defined at all at the configure step. --- Action.c | 4 ++-- Affinity.c | 6 +++--- CRT.c | 8 ++++---- CRT.h | 6 +++--- RichString.c | 4 ++-- RichString.h | 12 ++++++------ 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Action.c b/Action.c index 33320caf..79a4225d 100644 --- a/Action.c +++ b/Action.c @@ -279,7 +279,7 @@ static Htop_Reaction actionQuit(ATTR_UNUSED State* st) { static Htop_Reaction actionSetAffinity(State* st) { if (st->pl->cpuCount == 1) return HTOP_OK; -#if (HAVE_LIBHWLOC || HAVE_LINUX_AFFINITY) +#if (defined(HAVE_LIBHWLOC) || defined(HAVE_LINUX_AFFINITY)) Panel* panel = st->panel; Process* p = (Process*) Panel_getSelected(panel); @@ -416,7 +416,7 @@ static const struct { const char* key; const char* info; } helpRight[] = { { .key = " F9 k: ", .info = "kill process/tagged processes" }, { .key = " F7 ]: ", .info = "higher priority (root only)" }, { .key = " F8 [: ", .info = "lower priority (+ nice)" }, -#if (HAVE_LIBHWLOC || HAVE_LINUX_AFFINITY) +#if (defined(HAVE_LIBHWLOC) || defined(HAVE_LINUX_AFFINITY)) { .key = " a: ", .info = "set CPU affinity" }, #endif { .key = " e: ", .info = "show process environment" }, diff --git a/Affinity.c b/Affinity.c index 3ea45a9b..098e5c16 100644 --- a/Affinity.c +++ b/Affinity.c @@ -12,12 +12,12 @@ in the source distribution for its full text. #ifdef HAVE_LIBHWLOC #include -#if __linux__ +#ifdef __linux__ #define HTOP_HWLOC_CPUBIND_FLAG HWLOC_CPUBIND_THREAD #else #define HTOP_HWLOC_CPUBIND_FLAG HWLOC_CPUBIND_PROCESS #endif -#elif HAVE_LINUX_AFFINITY +#elif defined(HAVE_LINUX_AFFINITY) #include #endif @@ -79,7 +79,7 @@ bool Affinity_set(Process* proc, Arg arg) { return ok; } -#elif HAVE_LINUX_AFFINITY +#elif defined(HAVE_LINUX_AFFINITY) Affinity* Affinity_get(Process* proc, ProcessList* pl) { cpu_set_t cpuset; diff --git a/CRT.c b/CRT.c index 16f0e957..d6390ab6 100644 --- a/CRT.c +++ b/CRT.c @@ -18,7 +18,7 @@ in the source distribution for its full text. #include #include #include -#if HAVE_SETUID_ENABLED +#ifdef HAVE_SETUID_ENABLED #include #include #endif @@ -519,7 +519,7 @@ static void CRT_handleSIGTERM(int sgn) { exit(0); } -#if HAVE_SETUID_ENABLED +#ifdef HAVE_SETUID_ENABLED static int CRT_euid = -1; @@ -550,11 +550,11 @@ void CRT_restorePrivileges() { } } -#else +#else /* HAVE_SETUID_ENABLED */ // In this case, the setuid operations are defined as macros in CRT.h -#endif +#endif /* HAVE_SETUID_ENABLED */ // TODO: pass an instance of Settings instead. diff --git a/CRT.h b/CRT.h index 20ef283e..a2cfd8a9 100644 --- a/CRT.h +++ b/CRT.h @@ -147,13 +147,13 @@ extern int CRT_colorScheme; extern void *backtraceArray[128]; -#if HAVE_SETUID_ENABLED +#ifdef HAVE_SETUID_ENABLED void CRT_dropPrivileges(void); void CRT_restorePrivileges(void); -#else +#else /* HAVE_SETUID_ENABLED */ /* Turn setuid operations into NOPs */ @@ -162,7 +162,7 @@ void CRT_restorePrivileges(void); #define CRT_restorePrivileges() #endif -#endif +#endif /* HAVE_SETUID_ENABLED */ void CRT_init(int delay, int colorScheme, bool allowUnicode); diff --git a/RichString.c b/RichString.c index b97e34e5..661b765d 100644 --- a/RichString.c +++ b/RichString.c @@ -70,7 +70,7 @@ int RichString_findChar(RichString* this, char c, int start) { return -1; } -#else +#else /* HAVE_LIBNCURSESW */ static inline void RichString_writeFrom(RichString* this, int attrs, const char* data_c, int from, int len) { int newLen = from + len; @@ -99,7 +99,7 @@ int RichString_findChar(RichString* this, char c, int start) { return -1; } -#endif +#endif /* HAVE_LIBNCURSESW */ void RichString_prune(RichString* this) { if (this->chlen > RICHSTRING_MAXLEN) diff --git a/RichString.h b/RichString.h index e6fb4c32..6b626d40 100644 --- a/RichString.h +++ b/RichString.h @@ -14,13 +14,13 @@ in the source distribution for its full text. #include #ifdef HAVE_NCURSESW_CURSES_H #include -#elif HAVE_NCURSES_NCURSES_H +#elif defined(HAVE_NCURSES_NCURSES_H) #include -#elif HAVE_NCURSES_CURSES_H +#elif defined(HAVE_NCURSES_CURSES_H) #include -#elif HAVE_NCURSES_H +#elif defined(HAVE_NCURSES_H) #include -#elif HAVE_CURSES_H +#elif defined(HAVE_CURSES_H) #include #endif @@ -63,13 +63,13 @@ void RichString_setAttrn(RichString* this, int attrs, int start, int finish); int RichString_findChar(RichString* this, char c, int start); -#else +#else /* HAVE_LIBNCURSESW */ void RichString_setAttrn(RichString* this, int attrs, int start, int finish); int RichString_findChar(RichString* this, char c, int start); -#endif +#endif /* HAVE_LIBNCURSESW */ void RichString_prune(RichString* this);