Workaround 'struct member is never used' cppcheck style warnings
authorIvan Maidanski <ivmai@mail.ru>
Tue, 18 Oct 2016 07:59:20 +0000 (10:59 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 18 Oct 2016 08:00:37 +0000 (11:00 +0300)
* os_dep.c [OS2] (GC_register_data_segments): Assign 0 to
hdrdos.padding, hdr386.exe_format_level/os/padding1/padding2,
seg.pagemap/mapsize/reserved fields if CPPCHECK; add comment.
* os_dep.c [MPROTECT_VDB && DARWIN] (GC_mprotect_thread): Assign 0 to
the first element of reply.data, msg.data fields if CPPCHECK; add
comment.
* typd_mlc.c (TAG): Define to ad.ad_tag (instead of ld.ld_tag).

os_dep.c
typd_mlc.c

index 1394871..4bb7048 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -1464,6 +1464,16 @@ void GC_register_data_segments(void)
     struct o32_obj seg;         /* Current segment */
     int nsegs;
 
+#   if defined(CPPCHECK)
+        hdrdos.padding[0] = 0; /* to prevent "field unused" warnings */
+        hdr386.exe_format_level = 0;
+        hdr386.os = 0;
+        hdr386.padding1[0] = 0;
+        hdr386.padding2[0] = 0;
+        seg.pagemap = 0;
+        seg.mapsize = 0;
+        seg.reserved = 0;
+#   endif
     if (DosGetInfoBlocks(&ptib, &ppib) != NO_ERROR) {
         ABORT("DosGetInfoBlocks failed");
     }
@@ -3912,6 +3922,10 @@ STATIC void *GC_mprotect_thread(void *arg)
   mach_msg_id_t id;
 
   if ((word)arg == (word)-1) return 0; /* to make compiler happy */
+# if defined(CPPCHECK)
+    reply.data[0] = 0; /* to prevent "field unused" warnings */
+    msg.data[0] = 0;
+# endif
 
 # if defined(THREADS) && !defined(GC_NO_THREADS_DISCOVERY)
     GC_darwin_register_mach_handler_thread(mach_thread_self());
index 47af119..c858bb1 100644 (file)
@@ -85,7 +85,7 @@ typedef union ComplexDescriptor {
         union ComplexDescriptor * sd_second;
     } sd;
 } complex_descriptor;
-#define TAG ld.ld_tag
+#define TAG ad.ad_tag
 
 STATIC ext_descr * GC_ext_descriptors = NULL;
                                         /* Points to array of extended  */