Skip to content

Commit 8797850

Browse files
committed
Fix warnings in system/extras.
Bug: http://b/26936282 Change-Id: I1b9c6c9bb06944c32abcb871279d056eea0fb11a
1 parent dd681db commit 8797850

File tree

21 files changed

+64
-36
lines changed

21 files changed

+64
-36
lines changed

boot_control_copy/Android.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ LOCAL_PATH := $(call my-dir)
44
include $(CLEAR_VARS)
55

66
LOCAL_SRC_FILES := boot_control_copy.c bootinfo.c
7-
LOCAL_CFLAGS := -Wall -Wno-missing-field-initializers
7+
LOCAL_CFLAGS := -Wall -Wno-missing-field-initializers -Wno-unused-parameter
88
LOCAL_C_INCLUDES := system/core/mkbootimg bootable/recovery
99
LOCAL_SHARED_LIBRARIES := libcutils
1010
LOCAL_STATIC_LIBRARIES := libfs_mgr

boot_control_copy/bootinfo.c

-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ bool boot_info_validate(BrilloBootInfo* info)
180180

181181
void boot_info_reset(BrilloBootInfo* info)
182182
{
183-
size_t n;
184183
memset(info, '\0', sizeof(BrilloBootInfo));
185184
info->magic[0] = 'B';
186185
info->magic[1] = 'C';

ext4_utils/make_ext4fs.c

+13
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@
4141
/* These match the Linux definitions of these flags.
4242
L_xx is defined to avoid conflicting with the win32 versions.
4343
*/
44+
#undef S_IRWXU
45+
#undef S_IRGRP
46+
#undef S_IWGRP
47+
#undef S_IXGRP
48+
#undef S_IRWXG
49+
#undef S_IROTH
50+
#undef S_IWOTH
51+
#undef S_IXOTH
52+
#undef S_IRWXO
53+
#undef S_ISUID
54+
#undef S_ISGID
55+
#undef S_ISVTX
56+
4457
#define L_S_IRUSR 00400
4558
#define L_S_IWUSR 00200
4659
#define L_S_IXUSR 00100

f2fs_utils/Android.mk

+3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ LOCAL_STATIC_LIBRARIES := \
1111
libsparse_host \
1212
libz
1313
LOCAL_C_INCLUDES := external/f2fs-tools/include external/f2fs-tools/mkfs
14+
LOCAL_CFLAGS := -Wno-unused-parameter
1415
include $(BUILD_HOST_STATIC_LIBRARY)
1516

1617
include $(CLEAR_VARS)
1718
LOCAL_SRC_FILES := f2fs_ioutils.c
1819
LOCAL_C_INCLUDES := external/f2fs-tools/include external/f2fs-tools/mkfs
20+
LOCAL_CFLAGS := -Wno-unused-parameter
1921
LOCAL_STATIC_LIBRARIES := \
2022
libselinux \
2123
libsparse_host \
@@ -64,6 +66,7 @@ include $(CLEAR_VARS)
6466
LOCAL_MODULE := libf2fs_utils_static
6567
LOCAL_SRC_FILES := f2fs_utils.c
6668
LOCAL_C_INCLUDES := external/f2fs-tools/include external/f2fs-tools/mkfs
69+
LOCAL_CFLAGS := -Wno-unused-parameter
6770
LOCAL_STATIC_LIBRARIES := \
6871
libsparse_static
6972
include $(BUILD_STATIC_LIBRARY)

f2fs_utils/f2fs_ioutils.c

+8-5
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@
2828

2929
#define _LARGEFILE64_SOURCE
3030

31+
#include <assert.h>
3132
#include <asm/types.h>
33+
#include <dlfcn.h>
3234
#include <errno.h>
35+
#include <fcntl.h>
3336
#include <linux/fs.h>
3437
#include <stdio.h>
3538
#include <stdlib.h>
3639
#include <string.h> /* memset() */
3740
#include <sys/param.h>
3841
#include <sys/stat.h>
3942
#include <sys/types.h>
40-
#include <fcntl.h>
41-
#include <dlfcn.h>
42-
43-
#include <assert.h>
43+
#include <unistd.h>
4444

4545
#include <f2fs_fs.h>
4646
#include <f2fs_format_utils.h>
@@ -98,7 +98,10 @@ static int dev_write_fd(void *buf, __u64 offset, size_t len)
9898
{
9999
if (lseek64(config.fd, (off64_t)offset, SEEK_SET) < 0)
100100
return -1;
101-
if (write(config.fd, buf, len) != len)
101+
ssize_t written = write(config.fd, buf, len);
102+
if (written == -1)
103+
return -1;
104+
if ((size_t)written != len)
102105
return -1;
103106
return 0;
104107
}

f2fs_utils/make_f2fs_main.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,18 @@
1717
#include <fcntl.h>
1818
#include <libgen.h>
1919
#include <stdio.h>
20-
#include <unistd.h>
2120
#include <stdlib.h>
21+
#include <string.h>
22+
#include <unistd.h>
2223

2324
#if defined(__linux__)
2425
#include <linux/fs.h>
2526
#elif defined(__APPLE__) && defined(__MACH__)
2627
#include <sys/disk.h>
2728
#endif
2829

30+
#include "make_f2fs.h"
31+
2932
#ifndef USE_MINGW /* O_BINARY is windows-specific flag */
3033
#define O_BINARY 0
3134
#endif

ksmutils/ksminfo.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ int main(int argc, char *argv[]) {
189189

190190
static int read_pages(struct ksm_pages *kp, pm_map_t **maps, size_t num_maps, uint8_t pr_flags) {
191191
size_t i, j, k;
192-
size_t len;
193192
uint64_t *pagemap;
194193
size_t map_len;
195194
uint64_t flags;
@@ -251,7 +250,7 @@ static int read_pages(struct ksm_pages *kp, pm_map_t **maps, size_t num_maps, ui
251250
fprintf(stderr, "warning: could not lseek to 0x%08lx\n", vaddr);
252251
continue;
253252
}
254-
len = read(fd, data, pm_kernel_pagesize(ker));
253+
ssize_t len = read(fd, data, pm_kernel_pagesize(ker));
255254
if (len != pm_kernel_pagesize(ker)) {
256255
fprintf(stderr, "warning: could not read page at 0x%08lx\n", vaddr);
257256
continue;

latencytop/Android.mk

+2
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
2323

2424
LOCAL_MODULE_TAGS := debug
2525

26+
LOCAL_CFLAGS := -Wno-unused-parameter
27+
2628
include $(BUILD_EXECUTABLE)

libpagemap/Android.mk

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ LOCAL_MODULE := libpagemap
2525
LOCAL_MODULE_TAGS := debug
2626
LOCAL_SRC_FILES := $(pagemap_src_files)
2727
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
28+
LOCAL_CFLAGS := -Wno-unused-parameter
2829
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
2930
include $(BUILD_SHARED_LIBRARY)
3031

memtrack/memtrack.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ void ProcessInfo::dumpToLog() {
248248
for (std::vector<const process_info_t *>::const_iterator it = list_.begin();
249249
it != list_.end(); ++it) {
250250
ALOGI(" Name: %s", (*it)->name.c_str());
251-
ALOGI(" Max running processes: %d", (*it)->max_num_pids);
251+
ALOGI(" Max running processes: %zu", (*it)->max_num_pids);
252252
if ((*it)->pids.size() > 0) {
253253
ALOGI(" Currently running pids:");
254254
for (std::vector<int>::const_iterator pid_it = (*it)->pids.begin();

sane_schedstat/Android.mk

+1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ LOCAL_SRC_FILES := sane_schedstat.c
77
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
88
LOCAL_MODULE_TAGS := debug
99
LOCAL_MODULE := sane_schedstat
10+
LOCAL_CFLAGS := -Wno-unused-parameter
1011

1112
include $(BUILD_EXECUTABLE)

showslab/showslab.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ BUILD_SORT_FUNC(nr_pages)
243243
* set_sort_func - return the slab_sort_func that matches the given key.
244244
* On unrecognizable key, the call returns NULL.
245245
*/
246-
static void * set_sort_func(char key)
246+
static sort_t set_sort_func(char key)
247247
{
248248
switch (tolower(key)) {
249249
case 'a':

sound/Android.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ LOCAL_PATH := $(call my-dir)
33
include $(CLEAR_VARS)
44
LOCAL_MODULE := sound
55
LOCAL_SRC_FILES := playwav.c
6-
LOCAL_MODULE_TAGS := optional
6+
LOCAL_CFLAGS := -Wno-unused-parameter
77
include $(BUILD_EXECUTABLE)
88

tests/audio/alsa/pcmtest.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static unsigned int cards;
5353
static unsigned int mixers;
5454
static unsigned int timers;
5555

56-
int getPcmNodes(void)
56+
unsigned int getPcmNodes(void)
5757
{
5858
DIR *d;
5959
struct dirent *de;
@@ -165,7 +165,7 @@ int getPcmParams(unsigned int i)
165165

166166
TEST(pcmtest, CheckAudioDir) {
167167
pcms = getPcmNodes();
168-
ASSERT_GT(pcms, 0);
168+
ASSERT_GT(pcms, 0U);
169169
}
170170

171171
TEST(pcmtest, GetSoundDevs) {
@@ -176,24 +176,24 @@ TEST(pcmtest, GetSoundDevs) {
176176
}
177177

178178
TEST(pcmtest, CheckPcmSanity0) {
179-
ASSERT_NE(0, pcms);
179+
ASSERT_NE(0U, pcms);
180180
}
181181

182182
TEST(pcmtest, CheckPcmSanity1) {
183-
EXPECT_NE(1, pcms % 2);
183+
EXPECT_NE(1U, pcms % 2);
184184
}
185185

186186
TEST(pcmtests, CheckMixerSanity) {
187-
ASSERT_NE(0, mixers);
187+
ASSERT_NE(0U, mixers);
188188
ASSERT_EQ(mixers, cards);
189189
}
190190

191191
TEST(pcmtest, CheckTimesSanity0) {
192-
ASSERT_NE(0, timers);
192+
ASSERT_NE(0U, timers);
193193
}
194194

195195
TEST(pcmtest, CheckTimesSanity1) {
196-
EXPECT_EQ(1, timers);
196+
EXPECT_EQ(1U, timers);
197197
}
198198

199199
TEST(pcmtest, CheckPcmDevices) {

tests/cpueater/Android.mk

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ LOCAL_MODULE := cpueater
2020
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
2121
LOCAL_MODULE_TAGS := eng
2222
LOCAL_SRC_FILES := cpueater.c
23+
LOCAL_CFLAGS := -Wno-unused-parameter
2324
include $(BUILD_EXECUTABLE)
2425

2526
include $(CLEAR_VARS)

tests/crypto/Android.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ include $(CLEAR_VARS)
77
LOCAL_SRC_FILES:= get_dm_versions.c
88
LOCAL_MODULE:= get_dm_versions
99
LOCAL_MODULE_TAGS := optional
10-
LOCAL_CFLAGS :=
10+
LOCAL_CFLAGS := -Wno-unused-parameter
1111
include $(BUILD_EXECUTABLE)

tests/framebuffer/Android.mk

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LOCAL_SHARED_LIBRARIES := \
99

1010
LOCAL_MODULE:= test-fb-refresh
1111

12-
LOCAL_MODULE_TAGS := optional
12+
LOCAL_CFLAGS := -Wno-unused-parameter
1313

1414
include $(BUILD_EXECUTABLE)
1515

@@ -18,7 +18,7 @@ include $(BUILD_EXECUTABLE)
1818
include $(CLEAR_VARS)
1919
LOCAL_SRC_FILES := fb_test.c
2020
LOCAL_MODULE = test-fb-simple
21-
LOCAL_MODULE_TAGS := optional
2221
LOCAL_FORCE_STATIC_EXECUTABLE := true
2322
LOCAL_STATIC_LIBRARIES := libc
23+
LOCAL_CFLAGS := -Wno-unused-parameter
2424
include $(BUILD_EXECUTABLE)

tests/fstest/recovery_test.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
4040
#define FSTAB_PREFIX "/fstab."
4141
#define SB_OFFSET 1024
42-
#define UMOUNT_BIN "/system/bin/umount"
43-
#define VDC_BIN "/system/bin/vdc"
42+
static char UMOUNT_BIN[] = "/system/bin/umount";
43+
static char VDC_BIN[] = "/system/bin/vdc";
4444

4545
enum Fs_Type { FS_UNKNOWN, FS_EXT4, FS_F2FS };
4646

@@ -216,9 +216,10 @@ class FsRecoveryTest : public ::testing::Test {
216216
}
217217

218218
bool unmountCache() {
219+
char cache_str[] = "/cache";
219220
char *umount_argv[] = {
220221
UMOUNT_BIN,
221-
"/cache"
222+
cache_str,
222223
};
223224
int status;
224225
return android_fork_execvp_ext(ARRAY_SIZE(umount_argv), umount_argv,
@@ -227,10 +228,12 @@ class FsRecoveryTest : public ::testing::Test {
227228
}
228229

229230
bool mountAll() {
231+
char storage_str[] = "storage";
232+
char mountall_str[] = "mountall";
230233
char *mountall_argv[] = {
231234
VDC_BIN,
232-
"storage",
233-
"mountall"
235+
storage_str,
236+
mountall_str,
234237
};
235238
int status;
236239
return android_fork_execvp_ext(ARRAY_SIZE(mountall_argv), mountall_argv,

tests/pagingtest/thrashing_test.c

+6-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ int thrashing_test(int test_runs) {
1414
int fds[4] = {-1, -1, -1, -1};
1515
char tmpnames[4][17] = { "thrashing1XXXXXX", "thrashing2XXXXXX", "thrashing3XXXXXX", "thrashing4XXXXXX" };
1616
volatile char *bufs[4] = {0};
17-
unsigned i, j;
1817
long long k;
1918
int ret = -1;
2019
struct timeval begin_time, end_time, elapsed_time, total_time;
@@ -33,23 +32,23 @@ int thrashing_test(int test_runs) {
3332

3433
filesize = num_pages * pagesize / (ARRAY_SIZE(fds) - 1);
3534

36-
for (i = 0; i < ARRAY_SIZE(fds); i++) {
35+
for (size_t i = 0; i < ARRAY_SIZE(fds); i++) {
3736
fds[i] = create_tmp_file(tmpnames[i], filesize);
3837
if (fds[i] < 0) {
3938
goto err_fd;
4039
}
4140
}
4241

43-
for (i = 0; i < ARRAY_SIZE(fds); i++) {
42+
for (size_t i = 0; i < ARRAY_SIZE(fds); i++) {
4443
bufs[i] = mmap(NULL, filesize, PROT_READ, MAP_PRIVATE, fds[i], 0);
4544
if (bufs[i] == ((void *)-1)) {
4645
fprintf(stderr, "Failed to mmap file: %s\n", strerror(errno));
4746
goto err;
4847
}
4948
}
5049

51-
for (i = 0; i < test_runs; i++) {
52-
for (j = 0; j < ARRAY_SIZE(fds); j++) {
50+
for (int i = 0; i < test_runs; i++) {
51+
for (size_t j = 0; j < ARRAY_SIZE(fds); j++) {
5352
gettimeofday(&begin_time, NULL);
5453
//Unfortunately when under memory pressure, fadvise and madvise stop working...
5554
//Read backwards to prevent mmap prefetching
@@ -69,11 +68,11 @@ int thrashing_test(int test_runs) {
6968
ret = 0;
7069

7170
err:
72-
for (i = 0; i < ARRAY_SIZE(bufs) && bufs[i] != NULL; i++) {
71+
for (size_t i = 0; i < ARRAY_SIZE(bufs) && bufs[i] != NULL; i++) {
7372
munmap((void *)bufs[i], filesize);
7473
}
7574
err_fd:
76-
for (i = 0; i < ARRAY_SIZE(fds) && fds[i] >= 0; i++) {
75+
for (size_t i = 0; i < ARRAY_SIZE(fds) && fds[i] >= 0; i++) {
7776
close(fds[i]);
7877
}
7978
return ret;

tests/schedtest/Android.mk

+1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ LOCAL_SRC_FILES := \
66
schedtest.c
77

88
LOCAL_MODULE := schedtest
9+
LOCAL_CFLAGS := -Wno-unused-parameter
910

1011
include $(BUILD_EXECUTABLE)

tests/uevents/Android.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ LOCAL_SRC_FILES := uevents.c
66
LOCAL_SHARED_LIBRARIES += libcutils
77
LOCAL_MODULE:= uevents
88

9-
LOCAL_MODULE_TAGS := optional
9+
LOCAL_CFLAGS := -Wno-unused-parameter
1010

1111
include $(BUILD_EXECUTABLE)

0 commit comments

Comments
 (0)