]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Warning cleanup: make sure that either macros are defined or use #ifdef rather than #if
authorPaul Floyd <pjfloyd@wanadoo.fr>
Fri, 29 May 2026 06:31:39 +0000 (08:31 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Fri, 29 May 2026 06:31:39 +0000 (08:31 +0200)
A comment in https://bugs.kde.org/show_bug.cgi?id=519604 about correctly checking
for DARWIN_VERS led me to doing some builds with -Wundef. We still get quite a few
warnings from mips and LZO. I'll repeat the exercise on illumos Darwin and Linux amd64.

coregrind/m_aspacemgr/aspacemgr-common.c
coregrind/m_aspacemgr/aspacemgr-linux.c
coregrind/m_debuginfo/debuginfo.c
coregrind/m_debuginfo/minilzo-inl.c
coregrind/m_debuginfo/priv_storage.h
coregrind/m_gdbserver/remote-utils.c
coregrind/m_syswrap/syswrap-generic.c
include/vki/vki-amd64-freebsd.h
include/vki/vki-arm64-freebsd.h
include/vki/vki-x86-freebsd.h

index 95473ff6a6cc654e72bc6405d6ddd30eb32c1903..a1301fe4e3de893108cfe980db08ecee7e2ee1fe 100644 (file)
@@ -212,7 +212,7 @@ SysRes ML_(am_do_munmap_NO_NOTIFY)(Addr start, SizeT length)
    return VG_(do_syscall2)(__NR_munmap, (UWord)start, length );
 }
 
-#if HAVE_MREMAP
+#ifdef HAVE_MREMAP
 /* The following are used only to implement mremap(). */
 
 SysRes ML_(am_do_extend_mapping_NO_NOTIFY)( 
index 4bc27fec256309238dbb9ebb5f5720e6b3d145ca..6ede41a0151fcb4a9c4d1f5f3ab165502e95fba7 100644 (file)
@@ -3617,7 +3617,7 @@ const NSegment *VG_(am_extend_into_adjacent_reservation_client)( Addr addr,
 
 /* --- --- --- resizing/move a mapping --- --- --- */
 
-#if HAVE_MREMAP
+#ifdef HAVE_MREMAP
 
 /* This function grows a client mapping in place into an adjacent free segment.
    ADDR is the client mapping's start address and DELTA, which must be page
index 6f3c281e1dd4f2af766142fd62258e6685988cac..484f92140a37c9a85a888a5b53e28ef086a99ef2 100644 (file)
@@ -326,7 +326,7 @@ DebugInfo* alloc_DebugInfo( const HChar* filename )
       di->ddump_frames = VG_(clo_debug_dump_frames);
    }
 
-#if DARWIN_VERS >= DARWIN_11_00
+#if defined(VGO_darwin) && (DARWIN_VERS >= DARWIN_11_00)
    di->from_memory = False;
 #endif
 
index 939e929d92fc09592e77315d53ef2858b8560452..b1f6c08e1940f1ae0d16306603b4fe36b7214763 100644 (file)
@@ -2017,6 +2017,24 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp))
 #  undef HAVE_MEMSET
 #endif
 
+// despite all of the above macro nastiness the code that
+// uses these macros still mixes up undefined and defined to 0
+#if !defined(HAVE_MEMCMP)
+#define HAVE_MEMCMP 0
+#endif
+
+#if !defined(HAVE_MEMCPY)
+#define HAVE_MEMCPY 0
+#endif
+
+#if !defined(HAVE_MEMMOVE)
+#define HAVE_MEMMOVE 0
+#endif
+
+#if !defined(HAVE_MEMSET)
+#define HAVE_MEMSET 0
+#endif
+
 #if !(HAVE_MEMCMP)
 #  undef memcmp
 #  define memcmp(a,b,c)         lzo_memcmp(a,b,c)
index cd1ac3431e9b30235a009408c93d2324d97e9748..ca19ea7f0a9976df914ac252b8e388f61df228fa 100644 (file)
@@ -1095,7 +1095,7 @@ struct _DebugInfo {
       easily be invoked hundreds of thousands of times. */
    DebugInfoMapping* last_rx_map;
 
-#if DARWIN_VERS >= DARWIN_11_00
+#if defined(VGO_darwin) && (DARWIN_VERS >= DARWIN_11_00)
    /* Indicate that this debug info was loaded from memory (i.e. DSC)
       instead than from a file. This means that some data might be missing (e.g. rw data). */
    Bool from_memory;
index de0991c79bf25299e4949de7581a4422f6e7a208..23fe999e0b727d2649bd769607e0984347db4a76 100644 (file)
@@ -664,7 +664,7 @@ void decode_address (CORE_ADDR *addrp, const char *start, int len)
    Useful for register and int image */
 char* heximage (char *buf, const char *bin, int count)
 {
-#if (VKI_LITTLE_ENDIAN)
+#if defined(VKI_LITTLE_ENDIAN)
    char rev[count]; 
    /* note: no need for trailing \0, length is known with count */
    int i;
index e3f4bf55fe468bdb3edee84c5fd9442fbd85f406..4452137a8b4a135bc180bb00192e75dc65caf0d1 100644 (file)
@@ -285,7 +285,7 @@ ML_(notify_core_and_tool_of_madv_guard) ( Addr a, SizeT len, Bool install )
 }
 #endif
 
-#if HAVE_MREMAP
+#ifdef HAVE_MREMAP
 /* Expand (or shrink) an existing mapping, potentially moving it at
    the same time (controlled by the MREMAP_MAYMOVE flag).  Nightmare.
 */
@@ -3143,7 +3143,7 @@ POST(sys_madvise)
 }
 #endif
 
-#if HAVE_MREMAP
+#ifdef HAVE_MREMAP
 PRE(sys_mremap)
 {
    // Nb: this is different to the glibc version described in the man pages,
index f52b4eaed27963af0ee93639480bf7a4fee5cc58..e3bee60ed0defdc06c4ca42cc77c8c6d51dc833f 100644 (file)
@@ -26,6 +26,8 @@
 #ifndef VKI_AMD64_FREEBSD_H
 #define VKI_AMD64_FREEBSD_H
 
+#define VKI_LITTLE_ENDIAN  1
+
 /* PAGE_SHIFT determines the page size. */
 #define VKI_PAGE_SHIFT  12UL
 #define VKI_PAGE_SIZE   (1UL << VKI_PAGE_SHIFT)
index 406b0d87ca28b9fbee8603ccfccf531875fc80bf..4d44b8e8fda48ef46880406d0a45f72d40609088 100644 (file)
@@ -24,6 +24,8 @@
 #ifndef VKI_ARM64_FREEBSD_H
 #define VKI_ARM64_FREEBSD_H
 
+#define VKI_LITTLE_ENDIAN  1
+
 //----------------------------------------------------------------------
 // arm/param.h
 //----------------------------------------------------------------------
index 26db5203c0f71c5c2d690a3d9d1b04e106639076..57c110c18e8c6f1c09f3546ad0fa0969e8e90587 100644 (file)
@@ -33,6 +33,8 @@
 #ifndef VKI_X86_FREEBSD_H
 #define VKI_X86_FREEBSD_H
 
+#define VKI_LITTLE_ENDIAN  1
+
 //----------------------------------------------------------------------
 // From somewhere
 //----------------------------------------------------------------------