From 1c00d46b2566e91be9268812dbb5d3abfea3c3a2 Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Wed, 30 Apr 2014 13:25:49 -0700 Subject: [PATCH 1/4] gpttool: turn on -Werror - Deal with some -Wunused issues Change-Id: If9a05ccbda862bbd401df0f5d5a1837abedd9b83 --- gpttool/Android.mk | 1 + gpttool/gpttool.c | 15 ++++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/gpttool/Android.mk b/gpttool/Android.mk index b8f9844c7..64ad945e9 100644 --- a/gpttool/Android.mk +++ b/gpttool/Android.mk @@ -5,6 +5,7 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := gpttool.c LOCAL_STATIC_LIBRARIES := libz +LOCAL_CFLAGS := -Werror LOCAL_MODULE := gpttool diff --git a/gpttool/gpttool.c b/gpttool/gpttool.c index d3f08fe14..398362f36 100644 --- a/gpttool/gpttool.c +++ b/gpttool/gpttool.c @@ -1,5 +1,4 @@ -/* system/core/gpttool/gpttool.c -** +/* ** Copyright 2011, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,18 +14,18 @@ ** limitations under the License. */ +#include #include #include -#include #include -#include +#include +#include +#include #include #include -#include - typedef unsigned char u8; typedef unsigned short u16; typedef unsigned int u32; @@ -252,11 +251,9 @@ int parse_ptn(struct ptable *ptbl, char *x) int main(int argc, char **argv) { struct ptable ptbl; - struct efi_entry *entry; struct efi_header *hdr = &ptbl.header; - struct stat s; u32 n; - u64 sz, blk; + u64 sz; int fd; const char *device; int real_disk = 0; From cc209517e45346ea30d88ce9274dbb6ff1649914 Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Wed, 30 Apr 2014 13:44:10 -0700 Subject: [PATCH 2/4] mkbootimg: turn on -Werror - Deal with signedness issues Change-Id: I61211165eb4ce0fa9a2edeebb3f97fb0ffc62d34 --- mkbootimg/Android.mk | 1 + mkbootimg/mkbootimg.c | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/mkbootimg/Android.mk b/mkbootimg/Android.mk index 2a97c26e1..0c9b0c657 100644 --- a/mkbootimg/Android.mk +++ b/mkbootimg/Android.mk @@ -4,6 +4,7 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := mkbootimg.c LOCAL_STATIC_LIBRARIES := libmincrypt +LOCAL_CFLAGS := -Werror LOCAL_MODULE := mkbootimg diff --git a/mkbootimg/mkbootimg.c b/mkbootimg/mkbootimg.c index a7daccc21..fc92b4dc3 100644 --- a/mkbootimg/mkbootimg.c +++ b/mkbootimg/mkbootimg.c @@ -77,7 +77,7 @@ static unsigned char padding[16384] = { 0, }; int write_padding(int fd, unsigned pagesize, unsigned itemsize) { unsigned pagemask = pagesize - 1; - unsigned count; + ssize_t count; if((itemsize & pagemask) == 0) { return 0; @@ -108,7 +108,7 @@ int main(int argc, char **argv) unsigned pagesize = 2048; int fd; SHA_CTX ctx; - uint8_t* sha; + const uint8_t* sha; unsigned base = 0x10000000; unsigned kernel_offset = 0x00008000; unsigned ramdisk_offset = 0x01000000; @@ -189,7 +189,7 @@ int main(int argc, char **argv) return usage(); } - strcpy(hdr.name, board); + strcpy((char *) hdr.name, board); memcpy(hdr.magic, BOOT_MAGIC, BOOT_MAGIC_SIZE); @@ -255,14 +255,14 @@ int main(int argc, char **argv) if(write(fd, &hdr, sizeof(hdr)) != sizeof(hdr)) goto fail; if(write_padding(fd, pagesize, sizeof(hdr))) goto fail; - if(write(fd, kernel_data, hdr.kernel_size) != hdr.kernel_size) goto fail; + if(write(fd, kernel_data, hdr.kernel_size) != (ssize_t) hdr.kernel_size) goto fail; if(write_padding(fd, pagesize, hdr.kernel_size)) goto fail; - if(write(fd, ramdisk_data, hdr.ramdisk_size) != hdr.ramdisk_size) goto fail; + if(write(fd, ramdisk_data, hdr.ramdisk_size) != (ssize_t) hdr.ramdisk_size) goto fail; if(write_padding(fd, pagesize, hdr.ramdisk_size)) goto fail; if(second_data) { - if(write(fd, second_data, hdr.second_size) != hdr.second_size) goto fail; + if(write(fd, second_data, hdr.second_size) != (ssize_t) hdr.second_size) goto fail; if(write_padding(fd, pagesize, hdr.second_size)) goto fail; } From c9303f317562eb1cad5dd27a99a97f85b5acf136 Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Wed, 30 Apr 2014 15:52:16 -0700 Subject: [PATCH 3/4] netcfg: turn on -Werror - resolve unused variable reference Change-Id: If725a1cb0ee645c6e379c9ce21ab8c40bc4cd554 --- netcfg/Android.mk | 1 + netcfg/netcfg.c | 13 ++++--------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/netcfg/Android.mk b/netcfg/Android.mk index 949f41728..fc01a5464 100644 --- a/netcfg/Android.mk +++ b/netcfg/Android.mk @@ -11,6 +11,7 @@ LOCAL_MODULE:= netcfg #LOCAL_STATIC_LIBRARIES := libcutils libc LOCAL_SHARED_LIBRARIES := libc libnetutils +LOCAL_CFLAGS := -Werror include $(BUILD_EXECUTABLE) endif diff --git a/netcfg/netcfg.c b/netcfg/netcfg.c index 3738f2495..2308f37b5 100644 --- a/netcfg/netcfg.c +++ b/netcfg/netcfg.c @@ -1,5 +1,4 @@ -/* system/bin/netcfg/netcfg.c -** +/* ** Copyright 2006, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,18 +14,14 @@ ** limitations under the License. */ -#include -#include #include #include #include #include - -#include #include - -static int verbose = 0; - +#include +#include +#include void die(const char *reason) { From 60299dfd6a5dca059a079bc8e11d45a1fecf02d0 Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Wed, 30 Apr 2014 09:10:31 -0700 Subject: [PATCH 4/4] adb: turn on -Werror - Deal with some -Wunused issues Change-Id: Idfd1a114e68ae637978b52fde5144d0dca0ec79f --- adb/Android.mk | 7 +++---- adb/backup_service.c | 5 +---- adb/commandline.c | 8 ++++---- adb/file_sync_client.c | 6 +++--- adb/remount_service.c | 15 +++++++-------- adb/sysdeps_win32.c | 4 ++-- adb/usb_windows.c | 4 ++-- 7 files changed, 22 insertions(+), 27 deletions(-) diff --git a/adb/Android.mk b/adb/Android.mk index 62f012cb1..f4f93db32 100644 --- a/adb/Android.mk +++ b/adb/Android.mk @@ -74,7 +74,7 @@ else LOCAL_SRC_FILES += fdevent.c endif -LOCAL_CFLAGS += -O2 -g -DADB_HOST=1 -Wall -Wno-unused-parameter +LOCAL_CFLAGS += -O2 -g -DADB_HOST=1 -Wall -Wno-unused-parameter -Werror LOCAL_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE LOCAL_MODULE := adb LOCAL_MODULE_TAGS := debug @@ -116,7 +116,7 @@ LOCAL_SRC_FILES := \ remount_service.c \ usb_linux_client.c -LOCAL_CFLAGS := -O2 -g -DADB_HOST=0 -Wall -Wno-unused-parameter +LOCAL_CFLAGS := -O2 -g -DADB_HOST=0 -Wall -Wno-unused-parameter -Werror LOCAL_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT))) @@ -162,8 +162,7 @@ LOCAL_CFLAGS := \ -g \ -DADB_HOST=1 \ -DADB_HOST_ON_TARGET=1 \ - -Wall \ - -Wno-unused-parameter \ + -Wall -Wno-unused-parameter -Werror \ -D_XOPEN_SOURCE \ -D_GNU_SOURCE diff --git a/adb/backup_service.c b/adb/backup_service.c index 669ff8623..654e0f32d 100644 --- a/adb/backup_service.c +++ b/adb/backup_service.c @@ -52,15 +52,12 @@ int backup_service(BackupOperation op, char* args) { pid_t pid; int s[2]; char* operation; - int socketnum; - // Command string and choice of stdin/stdout for the pipe depend on our invocation + // Command string depends on our invocation if (op == BACKUP) { operation = "backup"; - socketnum = STDOUT_FILENO; } else { operation = "restore"; - socketnum = STDIN_FILENO; } D("backup_service(%s, %s)\n", operation, args); diff --git a/adb/commandline.c b/adb/commandline.c index 83b568d96..241cefc5b 100644 --- a/adb/commandline.c +++ b/adb/commandline.c @@ -406,7 +406,7 @@ int adb_download_buffer(const char *service, const char *fn, const void* data, i } int opt = CHUNK_SIZE; - opt = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &opt, sizeof(opt)); + opt = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (const void *) &opt, sizeof(opt)); total = sz; ptr = data; @@ -681,10 +681,10 @@ static int logcat(transport_type transport, char* serial, int argc, char **argv) return 0; } -static int mkdirs(char *path) +static int mkdirs(const char *path) { int ret; - char *x = path + 1; + char *x = (char *)path + 1; for(;;) { x = adb_dirstart(x); @@ -727,7 +727,7 @@ static int backup(int argc, char** argv) { if (argc < 2) return usage(); adb_unlink(filename); - mkdirs((char *)filename); + mkdirs(filename); outFd = adb_creat(filename, 0640); if (outFd < 0) { fprintf(stderr, "adb: unable to open file %s\n", filename); diff --git a/adb/file_sync_client.c b/adb/file_sync_client.c index 8fad50e01..dc4e77fbc 100644 --- a/adb/file_sync_client.c +++ b/adb/file_sync_client.c @@ -456,10 +456,10 @@ fail: return -1; } -static int mkdirs(char *name) +static int mkdirs(const char *name) { int ret; - char *x = name + 1; + char *x = (char *)name + 1; for(;;) { x = adb_dirstart(x); @@ -521,7 +521,7 @@ int sync_recv(int fd, const char *rpath, const char *lpath, int show_progress) if((id == ID_DATA) || (id == ID_DONE)) { adb_unlink(lpath); - mkdirs((char *)lpath); + mkdirs(lpath); lfd = adb_creat(lpath, 0644); if(lfd < 0) { fprintf(stderr,"cannot create '%s': %s\n", lpath, strerror(errno)); diff --git a/adb/remount_service.c b/adb/remount_service.c index ad61284b6..d3a649bfb 100644 --- a/adb/remount_service.c +++ b/adb/remount_service.c @@ -14,13 +14,13 @@ * limitations under the License. */ -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include #include "sysdeps.h" @@ -35,7 +35,6 @@ static char *find_mount(const char *dir) { int fd; int res; - int size; char *token = NULL; const char delims[] = "\n"; char buf[4096]; @@ -45,7 +44,7 @@ static char *find_mount(const char *dir) return NULL; buf[sizeof(buf) - 1] = '\0'; - size = adb_read(fd, buf, sizeof(buf) - 1); + adb_read(fd, buf, sizeof(buf) - 1); adb_close(fd); token = strtok(buf, delims); diff --git a/adb/sysdeps_win32.c b/adb/sysdeps_win32.c index 2105b1687..b0cb0488d 100644 --- a/adb/sysdeps_win32.c +++ b/adb/sysdeps_win32.c @@ -956,7 +956,7 @@ bip_buffer_write( BipBuffer bip, const void* src, int len ) avail = len; memcpy( bip->buff + bip->a_end, src, avail ); - src += avail; + src = (const char *)src + avail; count += avail; len -= avail; @@ -1049,7 +1049,7 @@ bip_buffer_read( BipBuffer bip, void* dst, int len ) avail = len; memcpy( dst, bip->buff + bip->a_start, avail ); - dst += avail; + dst = (char *)dst + avail; count += avail; len -= avail; diff --git a/adb/usb_windows.c b/adb/usb_windows.c index 4936b77b6..1309a78cf 100644 --- a/adb/usb_windows.c +++ b/adb/usb_windows.c @@ -310,14 +310,14 @@ int usb_read(usb_handle *handle, void* data, int len) { int xfer = (len > 4096) ? 4096 : len; ret = AdbReadEndpointSync(handle->adb_read_pipe, - (void*)data, + data, (unsigned long)xfer, &read, time_out); int saved_errno = GetLastError(); D("usb_write got: %ld, expected: %d, errno: %d\n", read, xfer, saved_errno); if (ret) { - data += read; + data = (char *)data + read; len -= read; if (len == 0)