diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2020-09-08 13:59:30 +0200 |
---|---|---|
committer | cgzones <cgzones@googlemail.com> | 2020-09-18 12:28:40 +0200 |
commit | b85a31415e8d68d0d46a105b1033a92669224682 (patch) | |
tree | 61020d61c68f9772967754c2598599e6ad9d84f3 | |
parent | c3952e7c20a3108c2f16aa579f8062dfc2163bd8 (diff) |
Avoid checking of undefined macros
These feature macros are either define or not defined at all at the
configure step.
-rw-r--r-- | Action.c | 4 | ||||
-rw-r--r-- | Affinity.c | 6 | ||||
-rw-r--r-- | CRT.c | 8 | ||||
-rw-r--r-- | CRT.h | 6 | ||||
-rw-r--r-- | RichString.c | 4 | ||||
-rw-r--r-- | RichString.h | 12 |
6 files changed, 20 insertions, 20 deletions
@@ -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" }, @@ -12,12 +12,12 @@ in the source distribution for its full text. #ifdef HAVE_LIBHWLOC #include <hwloc.h> -#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 <sched.h> #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; @@ -18,7 +18,7 @@ in the source distribution for its full text. #include <string.h> #include <locale.h> #include <langinfo.h> -#if HAVE_SETUID_ENABLED +#ifdef HAVE_SETUID_ENABLED #include <unistd.h> #include <sys/types.h> #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. @@ -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 <assert.h> #ifdef HAVE_NCURSESW_CURSES_H #include <ncursesw/curses.h> -#elif HAVE_NCURSES_NCURSES_H +#elif defined(HAVE_NCURSES_NCURSES_H) #include <ncurses/ncurses.h> -#elif HAVE_NCURSES_CURSES_H +#elif defined(HAVE_NCURSES_CURSES_H) #include <ncurses/curses.h> -#elif HAVE_NCURSES_H +#elif defined(HAVE_NCURSES_H) #include <ncurses.h> -#elif HAVE_CURSES_H +#elif defined(HAVE_CURSES_H) #include <curses.h> #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); |