From fcad060a1d83aa5e0b4ad38cf342d10f1922878d Mon Sep 17 00:00:00 2001
From: Aurimas Liutikas <aurimas@google.com>
Date: Tue, 10 May 2016 19:16:10 -0700
Subject: [PATCH] Fix all warnings and enable -Werror for gptfdisk.

Bug: 26936282
Change-Id: Id7e9ec5e769e1abedc1d2e36bff2c5488b1c4b3e
---
 Android.mk     | 2 ++
 attributes.cc  | 2 ++
 basicmbr.cc    | 2 ++
 bsd.cc         | 2 ++
 crc32.cc       | 2 +-
 diskio-unix.cc | 2 ++
 diskio.cc      | 2 ++
 gpt.cc         | 2 ++
 gptcl.cc       | 2 +-
 gptpart.cc     | 2 ++
 guid.cc        | 2 ++
 mbr.cc         | 2 ++
 mbrpart.cc     | 2 ++
 parttypes.cc   | 2 ++
 support.cc     | 2 ++
 15 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/Android.mk b/Android.mk
index 58885ad..245bd78 100644
--- a/Android.mk
+++ b/Android.mk
@@ -24,6 +24,7 @@ LOCAL_CPP_EXTENSION := .cc
 
 LOCAL_C_INCLUDES := $(LOCAL_PATH) external/e2fsprogs/lib
 LOCAL_SRC_FILES := $(sgdisk_src_files)
+LOCAL_CFLAGS += -Wno-unused-parameter -Werror
 
 LOCAL_SHARED_LIBRARIES := libext2_uuid
 
@@ -41,6 +42,7 @@ endif
 
 LOCAL_C_INCLUDES := $(LOCAL_PATH) external/e2fsprogs/lib
 LOCAL_SRC_FILES := $(sgdisk_src_files)
+LOCAL_CFLAGS += -Wno-unused-parameter -Werror
 
 LOCAL_SHARED_LIBRARIES := libext2_uuid-host
 
diff --git a/attributes.cc b/attributes.cc
index f3cd585..bbd5aad 100644
--- a/attributes.cc
+++ b/attributes.cc
@@ -7,7 +7,9 @@
   under the terms of the GNU GPL version 2, as detailed in the COPYING file. */
 
 #define __STDC_LIMIT_MACROS
+#ifndef __STDC_CONSTANT_MACROS
 #define __STDC_CONSTANT_MACROS
+#endif
 
 #include <stdint.h>
 #include <stdio.h>
diff --git a/basicmbr.cc b/basicmbr.cc
index 5661487..c3c0653 100644
--- a/basicmbr.cc
+++ b/basicmbr.cc
@@ -7,7 +7,9 @@
   under the terms of the GNU GPL version 2, as detailed in the COPYING file. */
 
 #define __STDC_LIMIT_MACROS
+#ifndef __STDC_CONSTANT_MACROS
 #define __STDC_CONSTANT_MACROS
+#endif
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/bsd.cc b/bsd.cc
index f487f18..59557c2 100644
--- a/bsd.cc
+++ b/bsd.cc
@@ -7,7 +7,9 @@
   under the terms of the GNU GPL version 2, as detailed in the COPYING file. */
 
 #define __STDC_LIMIT_MACROS
+#ifndef __STDC_CONSTANT_MACROS
 #define __STDC_CONSTANT_MACROS
+#endif
 
 #include <stdio.h>
 //#include <unistd.h>
diff --git a/crc32.cc b/crc32.cc
index d253dd9..5eca100 100644
--- a/crc32.cc
+++ b/crc32.cc
@@ -31,7 +31,7 @@ uint32_t crc_tab[256];
  */
 uint32_t chksum_crc32 (unsigned char *block, unsigned int length)
 {
-   register unsigned long crc;
+   unsigned long crc;
    unsigned long i;
 
    crc = 0xFFFFFFFF;
diff --git a/diskio-unix.cc b/diskio-unix.cc
index af71cdb..75fad2e 100644
--- a/diskio-unix.cc
+++ b/diskio-unix.cc
@@ -13,7 +13,9 @@
 // under the terms of the GNU GPL version 2, as detailed in the COPYING file.
 
 #define __STDC_LIMIT_MACROS
+#ifndef __STDC_CONSTANT_MACROS
 #define __STDC_CONSTANT_MACROS
+#endif
 
 #include <sys/ioctl.h>
 #include <string.h>
diff --git a/diskio.cc b/diskio.cc
index baf235b..f65011d 100644
--- a/diskio.cc
+++ b/diskio.cc
@@ -13,7 +13,9 @@
 // under the terms of the GNU GPL version 2, as detailed in the COPYING file.
 
 #define __STDC_LIMIT_MACROS
+#ifndef __STDC_CONSTANT_MACROS
 #define __STDC_CONSTANT_MACROS
+#endif
 
 #ifdef _WIN32
 #include <windows.h>
diff --git a/gpt.cc b/gpt.cc
index d0a46c6..038e4f3 100644
--- a/gpt.cc
+++ b/gpt.cc
@@ -7,7 +7,9 @@
   under the terms of the GNU GPL version 2, as detailed in the COPYING file. */
 
 #define __STDC_LIMIT_MACROS
+#ifndef __STDC_CONSTANT_MACROS
 #define __STDC_CONSTANT_MACROS
+#endif
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/gptcl.cc b/gptcl.cc
index 7c1d5cf..bdb4693 100644
--- a/gptcl.cc
+++ b/gptcl.cc
@@ -109,7 +109,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
       {"version", 'V', POPT_ARG_NONE, NULL, 'V', "display version information", ""},
       {"zap", 'z', POPT_ARG_NONE, NULL, 'z', "zap (destroy) GPT (but not MBR) data structures", ""},
       {"zap-all", 'Z', POPT_ARG_NONE, NULL, 'Z', "zap (destroy) GPT and MBR data structures", ""},
-      POPT_AUTOHELP { NULL, 0, 0, NULL, 0 }
+      POPT_AUTOHELP { NULL, 0, 0, NULL, 0, NULL, NULL }
    };
 
    // Create popt context...
diff --git a/gptpart.cc b/gptpart.cc
index 17d6f15..7e89909 100644
--- a/gptpart.cc
+++ b/gptpart.cc
@@ -13,7 +13,9 @@
 // under the terms of the GNU GPL version 2, as detailed in the COPYING file.
 
 #define __STDC_LIMIT_MACROS
+#ifndef __STDC_CONSTANT_MACROS
 #define __STDC_CONSTANT_MACROS
+#endif
 
 #ifdef USE_UTF16
 #include <unicode/ustdio.h>
diff --git a/guid.cc b/guid.cc
index 1e73ab7..e3e495c 100644
--- a/guid.cc
+++ b/guid.cc
@@ -12,7 +12,9 @@
 //
 
 #define __STDC_LIMIT_MACROS
+#ifndef __STDC_CONSTANT_MACROS
 #define __STDC_CONSTANT_MACROS
+#endif
 
 #include <stdio.h>
 #include <time.h>
diff --git a/mbr.cc b/mbr.cc
index 08c61be..d317f52 100644
--- a/mbr.cc
+++ b/mbr.cc
@@ -7,7 +7,9 @@
   under the terms of the GNU GPL version 2, as detailed in the COPYING file. */
 
 #define __STDC_LIMIT_MACROS
+#ifndef __STDC_CONSTANT_MACROS
 #define __STDC_CONSTANT_MACROS
+#endif
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/mbrpart.cc b/mbrpart.cc
index 0ca5814..c805d75 100644
--- a/mbrpart.cc
+++ b/mbrpart.cc
@@ -18,7 +18,9 @@
 */
 
 #define __STDC_LIMIT_MACROS
+#ifndef __STDC_CONSTANT_MACROS
 #define __STDC_CONSTANT_MACROS
+#endif
 
 #include <stddef.h>
 #include <stdint.h>
diff --git a/parttypes.cc b/parttypes.cc
index 175aca5..47c0f72 100644
--- a/parttypes.cc
+++ b/parttypes.cc
@@ -6,7 +6,9 @@
   under the terms of the GNU GPL version 2, as detailed in the COPYING file. */
 
 #define __STDC_LIMIT_MACROS
+#ifndef __STDC_CONSTANT_MACROS
 #define __STDC_CONSTANT_MACROS
+#endif
 
 #include <string.h>
 #include <stdint.h>
diff --git a/support.cc b/support.cc
index 0ff3485..a7242f6 100644
--- a/support.cc
+++ b/support.cc
@@ -7,7 +7,9 @@
   under the terms of the GNU GPL version 2, as detailed in the COPYING file. */
 
 #define __STDC_LIMIT_MACROS
+#ifndef __STDC_CONSTANT_MACROS
 #define __STDC_CONSTANT_MACROS
+#endif
 
 #include <stdio.h>
 #include <stdint.h>
-- 
GitLab