Use `#if defined()` syntax when `#elif defined()` is present

This prefers the `#if defined()` syntax over the `#ifdef` variant
whenever there's also a `#elif defined()` clause, thus making the
multiple branching structure more obvious and the overall use
more consistent.
This commit is contained in:
Benny Baumann 2021-03-20 11:21:20 +01:00 committed by cgzones
parent 1cb3aee07a
commit 57e0ce7b4f
5 changed files with 6 additions and 6 deletions

View File

@ -14,7 +14,7 @@ in the source distribution for its full text.
#include "XUtils.h" #include "XUtils.h"
#ifdef HAVE_LIBHWLOC #if defined(HAVE_LIBHWLOC)
#include <hwloc.h> #include <hwloc.h>
#include <hwloc/bitmap.h> #include <hwloc/bitmap.h>
#ifdef __linux__ #ifdef __linux__
@ -50,7 +50,7 @@ void Affinity_add(Affinity* this, unsigned int id) {
} }
#ifdef HAVE_LIBHWLOC #if defined(HAVE_LIBHWLOC)
Affinity* Affinity_get(const Process* proc, ProcessList* pl) { Affinity* Affinity_get(const Process* proc, ProcessList* pl) {
hwloc_cpuset_t cpuset = hwloc_bitmap_alloc(); hwloc_cpuset_t cpuset = hwloc_bitmap_alloc();

2
CRT.c
View File

@ -669,7 +669,7 @@ static int stderrRedirectNewFd = -1;
static int stderrRedirectBackupFd = -1; static int stderrRedirectBackupFd = -1;
static int createStderrCacheFile(void) { static int createStderrCacheFile(void) {
#ifdef HAVE_MEMFD_CREATE #if defined(HAVE_MEMFD_CREATE)
return memfd_create("htop.stderr-redirect", 0); return memfd_create("htop.stderr-redirect", 0);
#elif defined(O_TMPFILE) #elif defined(O_TMPFILE)
return open("/tmp", O_TMPFILE | O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR); return open("/tmp", O_TMPFILE | O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR);

View File

@ -120,7 +120,7 @@ DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager*
Panel_add(super, (Object*) CheckItem_newByRef("Also show CPU frequency", &(settings->showCPUFrequency))); Panel_add(super, (Object*) CheckItem_newByRef("Also show CPU frequency", &(settings->showCPUFrequency)));
#ifdef BUILD_WITH_CPU_TEMP #ifdef BUILD_WITH_CPU_TEMP
Panel_add(super, (Object*) CheckItem_newByRef( Panel_add(super, (Object*) CheckItem_newByRef(
#ifdef HTOP_LINUX #if defined(HTOP_LINUX)
"Also show CPU temperature (requires libsensors)", "Also show CPU temperature (requires libsensors)",
#elif defined(HTOP_FREEBSD) #elif defined(HTOP_FREEBSD)
"Also show CPU temperature", "Also show CPU temperature",

View File

@ -52,7 +52,7 @@
// ignore casts discarding const specifier, e.g. // ignore casts discarding const specifier, e.g.
// const char [] -> char * / void * // const char [] -> char * / void *
// const char *[2]' -> char *const * // const char *[2]' -> char *const *
#ifdef __clang__ #if defined(__clang__)
#define IGNORE_WCASTQUAL_BEGIN _Pragma("clang diagnostic push") \ #define IGNORE_WCASTQUAL_BEGIN _Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wcast-qual\"") _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
#define IGNORE_WCASTQUAL_END _Pragma("clang diagnostic pop") #define IGNORE_WCASTQUAL_END _Pragma("clang diagnostic pop")

View File

@ -48,7 +48,7 @@ in the source distribution for its full text.
#include "Settings.h" #include "Settings.h"
#include "XUtils.h" #include "XUtils.h"
#ifdef MAJOR_IN_MKDEV #if defined(MAJOR_IN_MKDEV)
#include <sys/mkdev.h> #include <sys/mkdev.h>
#elif defined(MAJOR_IN_SYSMACROS) #elif defined(MAJOR_IN_SYSMACROS)
#include <sys/sysmacros.h> #include <sys/sysmacros.h>