diff options
author | Mark Salyzyn <salyzyn@google.com> | 2014-05-21 10:07:55 -0700 |
---|---|---|
committer | Mark Salyzyn <salyzyn@google.com> | 2014-05-21 10:07:55 -0700 |
commit | 6cd488e95a658b23cf503febd9c5201837d45ec7 (patch) | |
tree | d7c0485adb8c6108aadc40685d81b5cb40ff18bb /toolbox | |
parent | f1b21c5c735e9150c8f29bdb52db2f3eb3ffc469 (diff) | |
parent | faf845290bb78824502d007209134c8dbfa296a2 (diff) | |
download | system_core-6cd488e95a658b23cf503febd9c5201837d45ec7.zip system_core-6cd488e95a658b23cf503febd9c5201837d45ec7.tar.gz system_core-6cd488e95a658b23cf503febd9c5201837d45ec7.tar.bz2 |
resolved conflicts for merge of faf84529 to master
Change-Id: Idbb7fae527bad4ae1447f95662a9ec5d5294d771
Diffstat (limited to 'toolbox')
-rw-r--r-- | toolbox/Android.mk | 2 | ||||
-rw-r--r-- | toolbox/cp/cp.c | 2 | ||||
-rw-r--r-- | toolbox/cp/utils.c | 17 | ||||
-rw-r--r-- | toolbox/date.c | 13 | ||||
-rw-r--r-- | toolbox/dd.c | 22 | ||||
-rw-r--r-- | toolbox/du.c | 2 | ||||
-rw-r--r-- | toolbox/getevent.c | 5 | ||||
-rw-r--r-- | toolbox/getevent.h | 2 | ||||
-rw-r--r-- | toolbox/getprop.c | 2 | ||||
-rw-r--r-- | toolbox/grep/file.c | 2 | ||||
-rw-r--r-- | toolbox/grep/grep.c | 10 | ||||
-rw-r--r-- | toolbox/hd.c | 1 | ||||
-rw-r--r-- | toolbox/ioctl.c | 6 | ||||
-rw-r--r-- | toolbox/load_policy.c | 2 | ||||
-rw-r--r-- | toolbox/ls.c | 1 | ||||
-rw-r--r-- | toolbox/lsof.c | 3 | ||||
-rw-r--r-- | toolbox/mkdir.c | 1 | ||||
-rw-r--r-- | toolbox/newfs_msdos.c | 12 | ||||
-rw-r--r-- | toolbox/ps.c | 7 | ||||
-rw-r--r-- | toolbox/rmdir.c | 1 | ||||
-rw-r--r-- | toolbox/schedtop.c | 4 | ||||
-rw-r--r-- | toolbox/sendevent.c | 5 | ||||
-rw-r--r-- | toolbox/start.c | 2 | ||||
-rw-r--r-- | toolbox/stop.c | 2 | ||||
-rw-r--r-- | toolbox/top.c | 10 | ||||
-rw-r--r-- | toolbox/umount.c | 1 | ||||
-rw-r--r-- | toolbox/watchprops.c | 6 |
27 files changed, 58 insertions, 85 deletions
diff --git a/toolbox/Android.mk b/toolbox/Android.mk index 26bb17b..78adf1e 100644 --- a/toolbox/Android.mk +++ b/toolbox/Android.mk @@ -98,7 +98,7 @@ LOCAL_C_INCLUDES := bionic/libc/bionic LOCAL_CFLAGS += \ -std=gnu99 \ - -Wno-unused-parameter \ + -Werror -Wno-unused-parameter \ -include bsd-compatibility.h \ LOCAL_SHARED_LIBRARIES := \ diff --git a/toolbox/cp/cp.c b/toolbox/cp/cp.c index bd3c70e..e666453 100644 --- a/toolbox/cp/cp.c +++ b/toolbox/cp/cp.c @@ -95,12 +95,14 @@ enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE }; static int copy(char *[], enum op, int); +#ifndef ANDROID static void progress(int sig __unused) { pinfo++; } +#endif int cp_main(int argc, char *argv[]) diff --git a/toolbox/cp/utils.c b/toolbox/cp/utils.c index b682bbe..9d0390f 100644 --- a/toolbox/cp/utils.c +++ b/toolbox/cp/utils.c @@ -380,10 +380,11 @@ copy_special(struct stat *from_stat, int exists) int setfile(struct stat *fs, int fd) { - int rval, islink; + int rval = 0; +#ifndef ANDROID + int islink = S_ISLNK(fs->st_mode); +#endif - rval = 0; - islink = S_ISLNK(fs->st_mode); fs->st_mode &= S_ISUID | S_ISGID | S_IRWXU | S_IRWXG | S_IRWXO; /* @@ -401,13 +402,13 @@ setfile(struct stat *fs, int fd) fs->st_mode &= ~(S_ISUID | S_ISGID); } #ifdef ANDROID - if (fd ? fchmod(fd, fs->st_mode) : chmod(to.p_path, fs->st_mode)) { + if (fd ? fchmod(fd, fs->st_mode) : chmod(to.p_path, fs->st_mode)) { #else - if (fd ? fchmod(fd, fs->st_mode) : lchmod(to.p_path, fs->st_mode)) { + if (fd ? fchmod(fd, fs->st_mode) : lchmod(to.p_path, fs->st_mode)) { #endif - warn("chmod: %s", to.p_path); - rval = 1; - } + warn("chmod: %s", to.p_path); + rval = 1; + } #ifndef ANDROID if (!islink && !Nflag) { diff --git a/toolbox/date.c b/toolbox/date.c index aa3b72e..70ce1d5 100644 --- a/toolbox/date.c +++ b/toolbox/date.c @@ -140,14 +140,12 @@ static char *parse_time(const char *str, struct timeval *ts) { int date_main(int argc, char *argv[]) { - int c; + int c; int res; - struct tm tm; - time_t t; - struct timeval tv; - struct timespec ts; - char strbuf[260]; - int fd; + struct tm tm; + time_t t; + struct timeval tv; + char strbuf[260]; int useutc = 0; @@ -177,7 +175,6 @@ int date_main(int argc, char *argv[]) int hasfmt = argc == optind + 1 && argv[optind][0] == '+'; if(optind == argc || hasfmt) { - char buf[2000]; time(&t); if (useutc) { gmtime_r(&t, &tm); diff --git a/toolbox/dd.c b/toolbox/dd.c index 6b61ffb..408a496 100644 --- a/toolbox/dd.c +++ b/toolbox/dd.c @@ -356,7 +356,7 @@ dd_in(void) ++st.in_full; /* Handle full input blocks. */ - } else if (n == in.dbsz) { + } else if (n == (int64_t)in.dbsz) { in.dbcnt += in.dbrcnt = n; ++st.in_full; @@ -521,7 +521,7 @@ dd_out(int force) outp += nw; st.bytes += nw; if (nw == n) { - if (n != out.dbsz) + if (n != (int64_t)out.dbsz) ++st.out_part; else ++st.out_full; @@ -649,8 +649,8 @@ pos_in(void) void pos_out(void) { -// struct mtop t_op; - int cnt, n; +/* struct mtop t_op; */ + int64_t cnt, n; /* * If not a tape, try seeking on the file. Seeking on a pipe is @@ -681,7 +681,7 @@ pos_out(void) } /* Read it. */ - for (cnt = 0; cnt < out.offset; ++cnt) { + for (cnt = 0; cnt < (int64_t)out.offset; ++cnt) { if ((n = read(out.fd, out.db, out.dbsz)) > 0) continue; @@ -705,8 +705,8 @@ pos_out(void) /* NOTREACHED */ } - while (cnt++ < out.offset) - if ((n = bwrite(out.fd, out.db, out.dbsz)) != out.dbsz) { + while (cnt++ < (int64_t)out.offset) + if ((n = bwrite(out.fd, out.db, out.dbsz)) != (int64_t)out.dbsz) { fprintf(stderr, "%s: cannot position " "by writing: %s\n", out.name, strerror(errno)); @@ -1153,7 +1153,7 @@ c_arg(const void *a, const void *b) ((const struct arg *)b)->name)); } -static long long strsuftoll(const char* name, const char* arg, int def, unsigned int max) +static long long strsuftoll(const char* name, const char* arg, int def, unsigned long long max) { long long result; @@ -1180,7 +1180,7 @@ static void f_count(char *arg) { - cpy_cnt = strsuftoll("block count", arg, 0, LLONG_MAX); + cpy_cnt = (uint64_t)strsuftoll("block count", arg, 0, 0xFFFFFFFFFFFFFFFFULL); if (!cpy_cnt) terminate(0); } @@ -1228,14 +1228,14 @@ static void f_seek(char *arg) { - out.offset = strsuftoll("seek blocks", arg, 0, LLONG_MAX); + out.offset = (uint64_t)strsuftoll("seek blocks", arg, 0, 0xFFFFFFFFFFFFFFFFULL); } static void f_skip(char *arg) { - in.offset = strsuftoll("skip blocks", arg, 0, LLONG_MAX); + in.offset = (uint64_t)strsuftoll("skip blocks", arg, 0, 0xFFFFFFFFFFFFFFFFULL); } static void diff --git a/toolbox/du.c b/toolbox/du.c index fc7c943..c8beba5 100644 --- a/toolbox/du.c +++ b/toolbox/du.c @@ -76,7 +76,7 @@ du_main(int argc, char *argv[]) int64_t totalblocks; int ftsoptions, listfiles; int depth; - int Hflag, Lflag, aflag, ch, cflag, dflag, gkmflag, nflag, rval, sflag; + int Hflag, Lflag, aflag, ch, cflag, dflag, gkmflag, rval, sflag; const char *noargv[2]; Hflag = Lflag = aflag = cflag = dflag = gkmflag = sflag = 0; diff --git a/toolbox/getevent.c b/toolbox/getevent.c index c979c99..da83ec3 100644 --- a/toolbox/getevent.c +++ b/toolbox/getevent.c @@ -498,13 +498,11 @@ int getevent_main(int argc, char *argv[]) int c; int i; int res; - int pollres; int get_time = 0; int print_device = 0; char *newline = "\n"; uint16_t get_switch = 0; struct input_event event; - int version; int print_flags = 0; int print_flags_set = 0; int dont_block = -1; @@ -635,7 +633,8 @@ int getevent_main(int argc, char *argv[]) return 0; while(1) { - pollres = poll(ufds, nfds, -1); + //int pollres = + poll(ufds, nfds, -1); //printf("poll %d, returned %d\n", nfds, pollres); if(ufds[0].revents & POLLIN) { read_notify(device_path, ufds[0].fd, print_flags); diff --git a/toolbox/getevent.h b/toolbox/getevent.h index 2b76209..0482d04 100644 --- a/toolbox/getevent.h +++ b/toolbox/getevent.h @@ -652,6 +652,7 @@ static struct label snd_labels[] = { LABEL_END, }; +#if 0 static struct label id_labels[] = { LABEL(ID_BUS), LABEL(ID_VENDOR), @@ -682,6 +683,7 @@ static struct label bus_labels[] = { LABEL(BUS_SPI), LABEL_END, }; +#endif static struct label mt_tool_labels[] = { LABEL(MT_TOOL_FINGER), diff --git a/toolbox/getprop.c b/toolbox/getprop.c index 7fd694d..dcc0ea0 100644 --- a/toolbox/getprop.c +++ b/toolbox/getprop.c @@ -32,8 +32,6 @@ static void list_properties(void) int getprop_main(int argc, char *argv[]) { - int n = 0; - if (argc == 1) { list_properties(); } else { diff --git a/toolbox/grep/file.c b/toolbox/grep/file.c index 86b7658..d28dff5 100644 --- a/toolbox/grep/file.c +++ b/toolbox/grep/file.c @@ -78,7 +78,9 @@ static inline int grep_refill(struct file *f) { ssize_t nr; +#ifndef ANDROID int bzerr; +#endif bufpos = buffer; bufrem = 0; diff --git a/toolbox/grep/grep.c b/toolbox/grep/grep.c index 5a4fa0c..7b2c487 100644 --- a/toolbox/grep/grep.c +++ b/toolbox/grep/grep.c @@ -403,7 +403,7 @@ grep_main(int argc, char *argv[]) Aflag = 0; else if (Aflag > LLONG_MAX / 10) { errno = ERANGE; - err(2, NULL); + err(2, "%llu", Aflag); } Aflag = Bflag = (Aflag * 10) + (c - '0'); break; @@ -420,10 +420,10 @@ grep_main(int argc, char *argv[]) l = strtoull(optarg, &ep, 10); if (((errno == ERANGE) && (l == ULLONG_MAX)) || ((errno == EINVAL) && (l == 0))) - err(2, NULL); + err(2, "strtoull"); else if (ep[0] != '\0') { errno = EINVAL; - err(2, NULL); + err(2, "empty"); } if (c == 'A') Aflag = l; @@ -509,10 +509,10 @@ grep_main(int argc, char *argv[]) mcount = strtoull(optarg, &ep, 10); if (((errno == ERANGE) && (mcount == ULLONG_MAX)) || ((errno == EINVAL) && (mcount == 0))) - err(2, NULL); + err(2, "strtoull"); else if (ep[0] != '\0') { errno = EINVAL; - err(2, NULL); + err(2, "empty"); } break; case 'n': diff --git a/toolbox/hd.c b/toolbox/hd.c index 0d2f96a..7c9998e 100644 --- a/toolbox/hd.c +++ b/toolbox/hd.c @@ -14,7 +14,6 @@ int hd_main(int argc, char *argv[]) unsigned char buf[4096]; int res; int read_len; - int rv = 0; int i; int filepos = 0; int sum; diff --git a/toolbox/ioctl.c b/toolbox/ioctl.c index fd24885..fd90812 100644 --- a/toolbox/ioctl.c +++ b/toolbox/ioctl.c @@ -21,9 +21,9 @@ int ioctl_main(int argc, char *argv[]) int arg_size = 4; int direct_arg = 0; uint32_t ioctl_nr; - void *ioctl_args; + void *ioctl_args = NULL; uint8_t *ioctl_argp; - uint8_t *ioctl_argp_save; + uint8_t *ioctl_argp_save = NULL; int rem; do { @@ -116,6 +116,7 @@ int ioctl_main(int argc, char *argv[]) else res = ioctl(fd, ioctl_nr, 0); if (res < 0) { + free(ioctl_args); fprintf(stderr, "ioctl 0x%x failed, %d\n", ioctl_nr, res); return 1; } @@ -128,5 +129,6 @@ int ioctl_main(int argc, char *argv[]) } printf("\n"); } + free(ioctl_args); return 0; } diff --git a/toolbox/load_policy.c b/toolbox/load_policy.c index eb5aba6..90d48c4 100644 --- a/toolbox/load_policy.c +++ b/toolbox/load_policy.c @@ -10,7 +10,7 @@ int load_policy_main(int argc, char **argv) { - int fd, rc, vers; + int fd, rc; struct stat sb; void *map; const char *path; diff --git a/toolbox/ls.c b/toolbox/ls.c index 06910ee..011f7b5 100644 --- a/toolbox/ls.c +++ b/toolbox/ls.c @@ -443,7 +443,6 @@ static int listpath(const char *name, int flags) int ls_main(int argc, char **argv) { int flags = 0; - int listed = 0; if(argc > 1) { int i; diff --git a/toolbox/lsof.c b/toolbox/lsof.c index af321af..bee981d 100644 --- a/toolbox/lsof.c +++ b/toolbox/lsof.c @@ -99,10 +99,7 @@ out: static void print_maps(struct pid_info_t* info) { FILE *maps; - char buffer[PATH_MAX + 100]; - size_t offset; - int major, minor; char device[10]; long int inode; char file[PATH_MAX]; diff --git a/toolbox/mkdir.c b/toolbox/mkdir.c index 656970a..398d350 100644 --- a/toolbox/mkdir.c +++ b/toolbox/mkdir.c @@ -15,7 +15,6 @@ static int usage() int mkdir_main(int argc, char *argv[]) { - int symbolic = 0; int ret; if(argc < 2 || strcmp(argv[1], "--help") == 0) { return usage(); diff --git a/toolbox/newfs_msdos.c b/toolbox/newfs_msdos.c index 27dca42..30b9f77 100644 --- a/toolbox/newfs_msdos.c +++ b/toolbox/newfs_msdos.c @@ -360,7 +360,7 @@ newfs_msdos_main(int argc, char *argv[]) if (!opt_create && !strchr(fname, '/')) { snprintf(buf, sizeof(buf), "%s%s", _PATH_DEV, fname); if (!(fname = strdup(buf))) - err(1, NULL); + err(1, "%s", buf); } dtype = *argv; if (opt_create) { @@ -493,7 +493,7 @@ newfs_msdos_main(int argc, char *argv[]) if (!strchr(bname, '/')) { snprintf(buf, sizeof(buf), "/boot/%s", bname); if (!(bname = strdup(buf))) - err(1, NULL); + err(1, "%s", buf); } if ((fd1 = open(bname, O_RDONLY)) == -1 || fstat(fd1, &sb)) err(1, "%s", bname); @@ -611,7 +611,7 @@ newfs_msdos_main(int argc, char *argv[]) now = tv.tv_sec; tm = localtime(&now); if (!(img = malloc(bpb.bps))) - err(1, NULL); + err(1, "%u", bpb.bps); dir = bpb.res + (bpb.spf ? bpb.spf : bpb.bspf) * bpb.nft; for (lsn = 0; lsn < dir + (fat == 32 ? bpb.spc : rds); lsn++) { x = lsn; @@ -728,14 +728,14 @@ newfs_msdos_main(int argc, char *argv[]) static void check_mounted(const char *fname, mode_t mode) { +#ifdef ANDROID + warnx("Skipping mount checks"); +#else struct statfs *mp; const char *s1, *s2; size_t len; int n, r; -#ifdef ANDROID - warnx("Skipping mount checks"); -#else if (!(n = getmntinfo(&mp, MNT_NOWAIT))) err(1, "getmntinfo"); len = strlen(_PATH_DEV); diff --git a/toolbox/ps.c b/toolbox/ps.c index c68438b..5458f6b 100644 --- a/toolbox/ps.c +++ b/toolbox/ps.c @@ -44,7 +44,7 @@ static int ps_line(int pid, int tid, char *namefilter) struct stat stats; int fd, r; char *ptr, *name, *state; - int ppid, tty; + int ppid; unsigned wchan, rss, vss, eip; unsigned utime, stime; int prio, nice, rtprio, sched, psr; @@ -92,8 +92,7 @@ static int ps_line(int pid, int tid, char *namefilter) ppid = atoi(nexttok(&ptr)); nexttok(&ptr); // pgrp nexttok(&ptr); // sid - tty = atoi(nexttok(&ptr)); - + nexttok(&ptr); // tty nexttok(&ptr); // tpgid nexttok(&ptr); // flags nexttok(&ptr); // minflt @@ -134,7 +133,7 @@ static int ps_line(int pid, int tid, char *namefilter) rtprio = atoi(nexttok(&ptr)); // rt_priority sched = atoi(nexttok(&ptr)); // scheduling policy - tty = atoi(nexttok(&ptr)); + nexttok(&ptr); // tty if(tid != 0) { ppid = pid; diff --git a/toolbox/rmdir.c b/toolbox/rmdir.c index 06f3df2..749fec8 100644 --- a/toolbox/rmdir.c +++ b/toolbox/rmdir.c @@ -11,7 +11,6 @@ static int usage() int rmdir_main(int argc, char *argv[]) { - int symbolic = 0; int ret; if(argc < 2) return usage(); diff --git a/toolbox/schedtop.c b/toolbox/schedtop.c index 0c85e76..2fccd2e 100644 --- a/toolbox/schedtop.c +++ b/toolbox/schedtop.c @@ -227,7 +227,6 @@ static void update_table(DIR *d, uint32_t flags) } for (i = 0; i < last_processes.active; i++) { int pid = last_processes.data[i].pid; - int tid = last_processes.data[i].tid; for (j = 0; j < processes.active; j++) if (pid == processes.data[j].pid) break; @@ -270,9 +269,6 @@ int schedtop_main(int argc, char **argv) { int c; DIR *d; - struct dirent *de; - char *namefilter = 0; - int pidfilter = 0; uint32_t flags = 0; int delay = 3000000; float delay_f; diff --git a/toolbox/sendevent.c b/toolbox/sendevent.c index 1608e6c..9b813f6 100644 --- a/toolbox/sendevent.c +++ b/toolbox/sendevent.c @@ -47,9 +47,8 @@ struct input_event { int sendevent_main(int argc, char *argv[]) { - int i; int fd; - int ret; + ssize_t ret; int version; struct input_event event; @@ -72,7 +71,7 @@ int sendevent_main(int argc, char *argv[]) event.code = atoi(argv[3]); event.value = atoi(argv[4]); ret = write(fd, &event, sizeof(event)); - if(ret < sizeof(event)) { + if(ret < (ssize_t) sizeof(event)) { fprintf(stderr, "write event failed, %s\n", strerror(errno)); return -1; } diff --git a/toolbox/start.c b/toolbox/start.c index 26344da..0941e64 100644 --- a/toolbox/start.c +++ b/toolbox/start.c @@ -7,8 +7,6 @@ int start_main(int argc, char *argv[]) { - char buf[1024]; - if(argc > 1) { property_set("ctl.start", argv[1]); } else { diff --git a/toolbox/stop.c b/toolbox/stop.c index 6552c7c..ed9a293 100644 --- a/toolbox/stop.c +++ b/toolbox/stop.c @@ -5,8 +5,6 @@ int stop_main(int argc, char *argv[]) { - char buf[1024]; - if(argc > 1) { property_set("ctl.stop", argv[1]); } else{ diff --git a/toolbox/top.c b/toolbox/top.c index 7382f1f..280a032 100644 --- a/toolbox/top.c +++ b/toolbox/top.c @@ -328,7 +328,6 @@ static void read_procs(void) { static int read_stat(char *filename, struct proc_info *proc) { FILE *file; char buf[MAX_LINE], *open_paren, *close_paren; - int res, idx; file = fopen(filename, "r"); if (!file) return 1; @@ -414,9 +413,7 @@ static void print_procs(void) { struct proc_info *old_proc, *proc; long unsigned total_delta_time; struct passwd *user; - struct group *group; char *user_str, user_buf[20]; - char *group_str, group_buf[20]; for (i = 0; i < num_new_procs; i++) { if (new_procs[i]) { @@ -467,19 +464,12 @@ static void print_procs(void) { if (!proc || (max_procs && (i >= max_procs))) break; user = getpwuid(proc->uid); - group = getgrgid(proc->gid); if (user && user->pw_name) { user_str = user->pw_name; } else { snprintf(user_buf, 20, "%d", proc->uid); user_str = user_buf; } - if (group && group->gr_name) { - group_str = group->gr_name; - } else { - snprintf(group_buf, 20, "%d", proc->gid); - group_str = group_buf; - } if (!threads) printf("%5d %2d %3ld%% %c %5d %6ldK %6ldK %3s %-8.8s %s\n", proc->pid, proc->prs, proc->delta_time * 100 / total_delta_time, proc->state, proc->num_threads, proc->vss / 1024, proc->rss * getpagesize() / 1024, proc->policy, user_str, proc->name[0] != 0 ? proc->name : proc->tname); diff --git a/toolbox/umount.c b/toolbox/umount.c index 890e870..3e17396 100644 --- a/toolbox/umount.c +++ b/toolbox/umount.c @@ -33,7 +33,6 @@ static int is_loop_mount(const char* path, char *loopdev) char mount_path[256]; char rest[256]; int result = 0; - int path_length = strlen(path); f = fopen("/proc/mounts", "r"); if (!f) { diff --git a/toolbox/watchprops.c b/toolbox/watchprops.c index bf82882..9921dbc 100644 --- a/toolbox/watchprops.c +++ b/toolbox/watchprops.c @@ -77,9 +77,7 @@ static void update_watchlist(const prop_info *pi, void *cookie) int watchprops_main(int argc, char *argv[]) { - unsigned serial = 0; - unsigned count = 0; - unsigned n; + unsigned serial; Hashmap *watchlist = hashmapCreate(1024, str_hash, str_equals); if (!watchlist) @@ -87,7 +85,7 @@ int watchprops_main(int argc, char *argv[]) __system_property_foreach(populate_watchlist, watchlist); - for(;;) { + for(serial = 0;;) { serial = __system_property_wait_any(serial); __system_property_foreach(update_watchlist, watchlist); } |