Skip to content

Commit

Permalink
randomenv: use ifdef over if
Browse files Browse the repository at this point in the history
randomenv.cpp:48:5: warning: 'HAVE_VM_VM_PARAM_H' is not defined, evaluates to 0 [-Wundef]

randomenv.cpp:51:5: warning: 'HAVE_SYS_RESOURCES_H' is not defined, evaluates to 0 [-Wundef]

randomenv.cpp:424:5: error: 'HAVE_SYSCTL' is not defined, evaluates to 0 [-Werror,-Wundef]
  • Loading branch information
fanquake committed Jun 21, 2024
1 parent 7839503 commit 40cd758
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/randomenv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@
#if HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS
#include <ifaddrs.h>
#endif
#if HAVE_SYSCTL
#ifdef HAVE_SYSCTL
#include <sys/sysctl.h>
#if HAVE_VM_VM_PARAM_H
#ifdef HAVE_VM_VM_PARAM_H
#include <vm/vm_param.h>
#endif
#if HAVE_SYS_RESOURCES_H
#ifdef HAVE_SYS_RESOURCES_H
#include <sys/resources.h>
#endif
#if HAVE_SYS_VMMETER_H
#ifdef HAVE_SYS_VMMETER_H
#include <sys/vmmeter.h>
#endif
#endif
Expand Down Expand Up @@ -162,7 +162,7 @@ void AddPath(CSHA512& hasher, const char *path)
}
#endif

#if HAVE_SYSCTL
#ifdef HAVE_SYSCTL
template<int... S>
void AddSysctl(CSHA512& hasher)
{
Expand Down Expand Up @@ -274,7 +274,7 @@ void RandAddDynamicEnv(CSHA512& hasher)
AddFile(hasher, "/proc/self/status");
#endif

#if HAVE_SYSCTL
#ifdef HAVE_SYSCTL
# ifdef CTL_KERN
# if defined(KERN_PROC) && defined(KERN_PROC_ALL)
AddSysctl<CTL_KERN, KERN_PROC, KERN_PROC_ALL>(hasher);
Expand Down Expand Up @@ -419,7 +419,7 @@ void RandAddStaticEnv(CSHA512& hasher)

// For MacOS/BSDs, gather data through sysctl instead of /proc. Not all of these
// will exist on every system.
#if HAVE_SYSCTL
#ifdef HAVE_SYSCTL
# ifdef CTL_HW
# ifdef HW_MACHINE
AddSysctl<CTL_HW, HW_MACHINE>(hasher);
Expand Down

0 comments on commit 40cd758

Please sign in to comment.