OSDN Git Service

Fix warnings in system/extras.
authorDan Albert <danalbert@google.com>
Tue, 2 Feb 2016 23:35:33 +0000 (15:35 -0800)
committerDan Albert <danalbert@google.com>
Wed, 3 Feb 2016 00:33:01 +0000 (16:33 -0800)
Bug: http://b/26936282
Change-Id: I1b9c6c9bb06944c32abcb871279d056eea0fb11a

21 files changed:
boot_control_copy/Android.mk
boot_control_copy/bootinfo.c
ext4_utils/make_ext4fs.c
f2fs_utils/Android.mk
f2fs_utils/f2fs_ioutils.c
f2fs_utils/make_f2fs_main.c
ksmutils/ksminfo.c
latencytop/Android.mk
libpagemap/Android.mk
memtrack/memtrack.cpp
sane_schedstat/Android.mk
showslab/showslab.c
sound/Android.mk
tests/audio/alsa/pcmtest.cpp
tests/cpueater/Android.mk
tests/crypto/Android.mk
tests/framebuffer/Android.mk
tests/fstest/recovery_test.cpp
tests/pagingtest/thrashing_test.c
tests/schedtest/Android.mk
tests/uevents/Android.mk

index 6e55d05..3125d6e 100644 (file)
@@ -4,7 +4,7 @@ LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := boot_control_copy.c bootinfo.c
-LOCAL_CFLAGS := -Wall -Wno-missing-field-initializers
+LOCAL_CFLAGS := -Wall -Wno-missing-field-initializers -Wno-unused-parameter
 LOCAL_C_INCLUDES := system/core/mkbootimg bootable/recovery
 LOCAL_SHARED_LIBRARIES := libcutils
 LOCAL_STATIC_LIBRARIES := libfs_mgr
index e3c2412..396dd81 100644 (file)
@@ -180,7 +180,6 @@ bool boot_info_validate(BrilloBootInfo* info)
 
 void boot_info_reset(BrilloBootInfo* info)
 {
-  size_t n;
   memset(info, '\0', sizeof(BrilloBootInfo));
   info->magic[0] = 'B';
   info->magic[1] = 'C';
index b4ebbce..1ba415b 100644 (file)
 /* These match the Linux definitions of these flags.
    L_xx is defined to avoid conflicting with the win32 versions.
 */
+#undef S_IRWXU
+#undef S_IRGRP
+#undef S_IWGRP
+#undef S_IXGRP
+#undef S_IRWXG
+#undef S_IROTH
+#undef S_IWOTH
+#undef S_IXOTH
+#undef S_IRWXO
+#undef S_ISUID
+#undef S_ISGID
+#undef S_ISVTX
+
 #define L_S_IRUSR 00400
 #define L_S_IWUSR 00200
 #define L_S_IXUSR 00100
index 2bc190f..647c390 100644 (file)
@@ -11,11 +11,13 @@ LOCAL_STATIC_LIBRARIES := \
     libsparse_host \
     libz
 LOCAL_C_INCLUDES := external/f2fs-tools/include external/f2fs-tools/mkfs
+LOCAL_CFLAGS := -Wno-unused-parameter
 include $(BUILD_HOST_STATIC_LIBRARY)
 
 include $(CLEAR_VARS)
 LOCAL_SRC_FILES := f2fs_ioutils.c
 LOCAL_C_INCLUDES := external/f2fs-tools/include external/f2fs-tools/mkfs
+LOCAL_CFLAGS := -Wno-unused-parameter
 LOCAL_STATIC_LIBRARIES := \
     libselinux \
     libsparse_host \
@@ -64,6 +66,7 @@ include $(CLEAR_VARS)
 LOCAL_MODULE := libf2fs_utils_static
 LOCAL_SRC_FILES := f2fs_utils.c
 LOCAL_C_INCLUDES := external/f2fs-tools/include external/f2fs-tools/mkfs
+LOCAL_CFLAGS := -Wno-unused-parameter
 LOCAL_STATIC_LIBRARIES := \
     libsparse_static
 include $(BUILD_STATIC_LIBRARY)
index a050cf8..01efd53 100644 (file)
 
 #define _LARGEFILE64_SOURCE
 
+#include <assert.h>
 #include <asm/types.h>
+#include <dlfcn.h>
 #include <errno.h>
+#include <fcntl.h>
 #include <linux/fs.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/param.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <fcntl.h>
-#include <dlfcn.h>
-
-#include <assert.h>
+#include <unistd.h>
 
 #include <f2fs_fs.h>
 #include <f2fs_format_utils.h>
@@ -98,7 +98,10 @@ static int dev_write_fd(void *buf, __u64 offset, size_t len)
 {
        if (lseek64(config.fd, (off64_t)offset, SEEK_SET) < 0)
                return -1;
-       if (write(config.fd, buf, len) != len)
+       ssize_t written = write(config.fd, buf, len);
+       if (written == -1)
+               return -1;
+       if ((size_t)written != len)
                return -1;
        return 0;
 }
index 8404266..1e0dd87 100644 (file)
@@ -17,8 +17,9 @@
 #include <fcntl.h>
 #include <libgen.h>
 #include <stdio.h>
-#include <unistd.h>
 #include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
 
 #if defined(__linux__)
 #include <linux/fs.h>
@@ -26,6 +27,8 @@
 #include <sys/disk.h>
 #endif
 
+#include "make_f2fs.h"
+
 #ifndef USE_MINGW /* O_BINARY is windows-specific flag */
 #define O_BINARY 0
 #endif
index 4ac39bc..278692f 100644 (file)
@@ -189,7 +189,6 @@ exit:
 
 static int read_pages(struct ksm_pages *kp, pm_map_t **maps, size_t num_maps, uint8_t pr_flags) {
     size_t i, j, k;
-    size_t len;
     uint64_t *pagemap;
     size_t map_len;
     uint64_t flags;
@@ -251,7 +250,7 @@ static int read_pages(struct ksm_pages *kp, pm_map_t **maps, size_t num_maps, ui
                 fprintf(stderr, "warning: could not lseek to 0x%08lx\n", vaddr);
                 continue;
             }
-            len = read(fd, data, pm_kernel_pagesize(ker));
+            ssize_t len = read(fd, data, pm_kernel_pagesize(ker));
             if (len != pm_kernel_pagesize(ker)) {
                 fprintf(stderr, "warning: could not read page at 0x%08lx\n", vaddr);
                 continue;
index 2c96672..220f4e3 100644 (file)
@@ -23,4 +23,6 @@ LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
 
 LOCAL_MODULE_TAGS := debug
 
+LOCAL_CFLAGS := -Wno-unused-parameter
+
 include $(BUILD_EXECUTABLE)
index 05e6f01..65d466c 100644 (file)
@@ -25,6 +25,7 @@ LOCAL_MODULE := libpagemap
 LOCAL_MODULE_TAGS := debug
 LOCAL_SRC_FILES := $(pagemap_src_files)
 LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
+LOCAL_CFLAGS := -Wno-unused-parameter
 LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
 include $(BUILD_SHARED_LIBRARY)
 
index a451d5c..2c4d7c0 100644 (file)
@@ -248,7 +248,7 @@ void ProcessInfo::dumpToLog() {
   for (std::vector<const process_info_t *>::const_iterator it = list_.begin();
        it != list_.end(); ++it) {
     ALOGI("  Name: %s", (*it)->name.c_str());
-    ALOGI("    Max running processes: %d", (*it)->max_num_pids);
+    ALOGI("    Max running processes: %zu", (*it)->max_num_pids);
     if ((*it)->pids.size() > 0) {
       ALOGI("    Currently running pids:");
       for (std::vector<int>::const_iterator pid_it = (*it)->pids.begin();
index 5843c43..c984b9f 100644 (file)
@@ -7,5 +7,6 @@ LOCAL_SRC_FILES := sane_schedstat.c
 LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
 LOCAL_MODULE_TAGS := debug
 LOCAL_MODULE := sane_schedstat
+LOCAL_CFLAGS := -Wno-unused-parameter
 
 include $(BUILD_EXECUTABLE)
index 9c9e60e..08acbf8 100644 (file)
@@ -243,7 +243,7 @@ BUILD_SORT_FUNC(nr_pages)
  * set_sort_func - return the slab_sort_func that matches the given key.
  * On unrecognizable key, the call returns NULL.
  */
-static void * set_sort_func(char key)
+static sort_t set_sort_func(char key)
 {
        switch (tolower(key)) {
        case 'a':
index 62174cc..a08c437 100644 (file)
@@ -3,6 +3,6 @@ LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
 LOCAL_MODULE := sound
 LOCAL_SRC_FILES := playwav.c
-LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS := -Wno-unused-parameter
 include $(BUILD_EXECUTABLE)
 
index b8bc5f2..7233e10 100644 (file)
@@ -53,7 +53,7 @@ static unsigned int cards;
 static unsigned int mixers;
 static unsigned int timers;
 
-int getPcmNodes(void)
+unsigned int getPcmNodes(void)
 {
     DIR *d;
     struct dirent *de;
@@ -165,7 +165,7 @@ int getPcmParams(unsigned int i)
 
 TEST(pcmtest, CheckAudioDir) {
     pcms = getPcmNodes();
-    ASSERT_GT(pcms, 0);
+    ASSERT_GT(pcms, 0U);
 }
 
 TEST(pcmtest, GetSoundDevs) {
@@ -176,24 +176,24 @@ TEST(pcmtest, GetSoundDevs) {
 }
 
 TEST(pcmtest, CheckPcmSanity0) {
-    ASSERT_NE(0, pcms);
+    ASSERT_NE(0U, pcms);
 }
 
 TEST(pcmtest, CheckPcmSanity1) {
-    EXPECT_NE(1, pcms % 2);
+    EXPECT_NE(1U, pcms % 2);
 }
 
 TEST(pcmtests, CheckMixerSanity) {
-    ASSERT_NE(0, mixers);
+    ASSERT_NE(0U, mixers);
     ASSERT_EQ(mixers, cards);
 }
 
 TEST(pcmtest, CheckTimesSanity0) {
-    ASSERT_NE(0, timers);
+    ASSERT_NE(0U, timers);
 }
 
 TEST(pcmtest, CheckTimesSanity1) {
-    EXPECT_EQ(1, timers);
+    EXPECT_EQ(1U, timers);
 }
 
 TEST(pcmtest, CheckPcmDevices) {
index 733c67a..0bb08d9 100644 (file)
@@ -20,6 +20,7 @@ LOCAL_MODULE := cpueater
 LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
 LOCAL_MODULE_TAGS := eng
 LOCAL_SRC_FILES := cpueater.c
+LOCAL_CFLAGS := -Wno-unused-parameter
 include $(BUILD_EXECUTABLE)
 
 include $(CLEAR_VARS)
index 737e000..e118e5d 100644 (file)
@@ -7,5 +7,5 @@ include $(CLEAR_VARS)
 LOCAL_SRC_FILES:= get_dm_versions.c
 LOCAL_MODULE:= get_dm_versions
 LOCAL_MODULE_TAGS := optional
-LOCAL_CFLAGS :=
+LOCAL_CFLAGS := -Wno-unused-parameter
 include $(BUILD_EXECUTABLE)
index 75a9f75..7f4c712 100644 (file)
@@ -9,7 +9,7 @@ LOCAL_SHARED_LIBRARIES := \
 
 LOCAL_MODULE:= test-fb-refresh
 
-LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS := -Wno-unused-parameter
 
 include $(BUILD_EXECUTABLE)
 
@@ -18,7 +18,7 @@ include $(BUILD_EXECUTABLE)
 include $(CLEAR_VARS)
 LOCAL_SRC_FILES := fb_test.c
 LOCAL_MODULE = test-fb-simple
-LOCAL_MODULE_TAGS := optional
 LOCAL_FORCE_STATIC_EXECUTABLE := true
 LOCAL_STATIC_LIBRARIES := libc
+LOCAL_CFLAGS := -Wno-unused-parameter
 include $(BUILD_EXECUTABLE)
index f8d41c3..b93de83 100644 (file)
@@ -39,8 +39,8 @@
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
 #define FSTAB_PREFIX "/fstab."
 #define SB_OFFSET 1024
-#define UMOUNT_BIN "/system/bin/umount"
-#define VDC_BIN "/system/bin/vdc"
+static char UMOUNT_BIN[] = "/system/bin/umount";
+static char VDC_BIN[] = "/system/bin/vdc";
 
 enum Fs_Type { FS_UNKNOWN, FS_EXT4, FS_F2FS };
 
@@ -216,9 +216,10 @@ class FsRecoveryTest : public ::testing::Test {
   }
 
   bool unmountCache() {
+    char cache_str[] = "/cache";
     char *umount_argv[] = {
       UMOUNT_BIN,
-      "/cache"
+      cache_str,
     };
     int status;
     return android_fork_execvp_ext(ARRAY_SIZE(umount_argv), umount_argv,
@@ -227,10 +228,12 @@ class FsRecoveryTest : public ::testing::Test {
   }
 
   bool mountAll() {
+    char storage_str[] = "storage";
+    char mountall_str[] = "mountall";
     char *mountall_argv[] = {
       VDC_BIN,
-      "storage",
-      "mountall"
+      storage_str,
+      mountall_str,
     };
     int status;
     return android_fork_execvp_ext(ARRAY_SIZE(mountall_argv), mountall_argv,
index 165cd99..7ecd3ad 100644 (file)
@@ -14,7 +14,6 @@ int thrashing_test(int test_runs) {
     int fds[4] = {-1, -1, -1, -1};
     char tmpnames[4][17] = { "thrashing1XXXXXX", "thrashing2XXXXXX", "thrashing3XXXXXX", "thrashing4XXXXXX" };
     volatile char *bufs[4] = {0};
-    unsigned i, j;
     long long k;
     int ret = -1;
     struct timeval begin_time, end_time, elapsed_time, total_time;
@@ -33,14 +32,14 @@ int thrashing_test(int test_runs) {
 
     filesize = num_pages * pagesize / (ARRAY_SIZE(fds) - 1);
 
-    for (i = 0; i < ARRAY_SIZE(fds); i++) {
+    for (size_t i = 0; i < ARRAY_SIZE(fds); i++) {
         fds[i] = create_tmp_file(tmpnames[i], filesize);
         if (fds[i] < 0) {
             goto err_fd;
         }
     }
 
-    for (i = 0; i < ARRAY_SIZE(fds); i++) {
+    for (size_t i = 0; i < ARRAY_SIZE(fds); i++) {
         bufs[i] = mmap(NULL, filesize, PROT_READ, MAP_PRIVATE, fds[i], 0);
         if (bufs[i] == ((void *)-1)) {
             fprintf(stderr, "Failed to mmap file: %s\n", strerror(errno));
@@ -48,8 +47,8 @@ int thrashing_test(int test_runs) {
         }
     }
 
-    for (i = 0; i < test_runs; i++) {
-        for (j = 0; j < ARRAY_SIZE(fds); j++) {
+    for (int i = 0; i < test_runs; i++) {
+        for (size_t j = 0; j < ARRAY_SIZE(fds); j++) {
             gettimeofday(&begin_time, NULL);
             //Unfortunately when under memory pressure, fadvise and madvise stop working...
             //Read backwards to prevent mmap prefetching
@@ -69,11 +68,11 @@ int thrashing_test(int test_runs) {
     ret = 0;
 
 err:
-    for (i = 0; i < ARRAY_SIZE(bufs) && bufs[i] != NULL; i++) {
+    for (size_t i = 0; i < ARRAY_SIZE(bufs) && bufs[i] != NULL; i++) {
         munmap((void *)bufs[i], filesize);
     }
 err_fd:
-    for (i = 0; i < ARRAY_SIZE(fds) && fds[i] >= 0; i++) {
+    for (size_t i = 0; i < ARRAY_SIZE(fds) && fds[i] >= 0; i++) {
         close(fds[i]);
     }
     return ret;
index 58e8d62..036c9fe 100644 (file)
@@ -6,5 +6,6 @@ LOCAL_SRC_FILES := \
        schedtest.c
 
 LOCAL_MODULE := schedtest
+LOCAL_CFLAGS := -Wno-unused-parameter
 
 include $(BUILD_EXECUTABLE)
index f04b211..fb8a851 100644 (file)
@@ -6,6 +6,6 @@ LOCAL_SRC_FILES := uevents.c
 LOCAL_SHARED_LIBRARIES += libcutils
 LOCAL_MODULE:= uevents
 
-LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS := -Wno-unused-parameter
 
 include $(BUILD_EXECUTABLE)