diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-06 03:05:54 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-06 03:05:54 +0000 |
commit | 6bef3d1d2216234454875052220ca0f477a820b4 (patch) | |
tree | 717060345370b781d3d1cde7ab4dd29304a066e8 | |
parent | 1bec1b980e3cf5ad604fb0c2038a3ab83d9ab5f5 (diff) | |
download | busybox-w32-6bef3d1d2216234454875052220ca0f477a820b4.tar.gz busybox-w32-6bef3d1d2216234454875052220ca0f477a820b4.tar.bz2 busybox-w32-6bef3d1d2216234454875052220ca0f477a820b4.zip |
fbset: fix buglet where we were using wrong pointer
readahead: stop using stdio.h
*: style fixes
-rw-r--r-- | coreutils/mknod.c | 36 | ||||
-rw-r--r-- | editors/diff.c | 7 | ||||
-rw-r--r-- | init/init.c | 6 | ||||
-rw-r--r-- | libbb/device_open.c | 8 | ||||
-rw-r--r-- | libbb/dump.c | 6 | ||||
-rw-r--r-- | libbb/obscure.c | 3 | ||||
-rw-r--r-- | loginutils/getty.c | 4 | ||||
-rw-r--r-- | miscutils/devfsd.c | 37 | ||||
-rw-r--r-- | miscutils/hdparm.c | 3 | ||||
-rw-r--r-- | miscutils/readahead.c | 10 | ||||
-rw-r--r-- | runit/runit_lib.c | 15 | ||||
-rw-r--r-- | util-linux/dmesg.c | 3 | ||||
-rw-r--r-- | util-linux/fbset.c | 10 | ||||
-rw-r--r-- | util-linux/fdisk.c | 3 |
14 files changed, 94 insertions, 57 deletions
diff --git a/coreutils/mknod.c b/coreutils/mknod.c index ee539e387..55f531033 100644 --- a/coreutils/mknod.c +++ b/coreutils/mknod.c | |||
@@ -28,23 +28,29 @@ int mknod_main(int argc, char **argv) | |||
28 | argv += optind; | 28 | argv += optind; |
29 | argc -= optind; | 29 | argc -= optind; |
30 | 30 | ||
31 | if ((argc >= 2) && ((name = strchr(modes_chars, argv[1][0])) != NULL)) { | 31 | if (argc >= 2) { |
32 | mode |= modes_cubp[(int)(name[4])]; | 32 | name = strchr(modes_chars, argv[1][0]); |
33 | 33 | if (name != NULL) { | |
34 | dev = 0; | 34 | mode |= modes_cubp[(int)(name[4])]; |
35 | if ((*name != 'p') && ((argc -= 2) == 2)) { | 35 | |
36 | /* Autodetect what the system supports; these macros should | 36 | dev = 0; |
37 | * optimize out to two constants. */ | 37 | if (*name != 'p') { |
38 | dev = makedev(xatoul_range(argv[2], 0, major(UINT_MAX)), | 38 | argc -= 2; |
39 | xatoul_range(argv[3], 0, minor(UINT_MAX))); | 39 | if (argc == 2) { |
40 | } | 40 | /* Autodetect what the system supports; these macros should |
41 | * optimize out to two constants. */ | ||
42 | dev = makedev(xatoul_range(argv[2], 0, major(UINT_MAX)), | ||
43 | xatoul_range(argv[3], 0, minor(UINT_MAX))); | ||
44 | } | ||
45 | } | ||
41 | 46 | ||
42 | if (argc == 2) { | 47 | if (argc == 2) { |
43 | name = *argv; | 48 | name = *argv; |
44 | if (mknod(name, mode, dev) == 0) { | 49 | if (mknod(name, mode, dev) == 0) { |
45 | return EXIT_SUCCESS; | 50 | return EXIT_SUCCESS; |
51 | } | ||
52 | bb_simple_perror_msg_and_die(name); | ||
46 | } | 53 | } |
47 | bb_simple_perror_msg_and_die(name); | ||
48 | } | 54 | } |
49 | } | 55 | } |
50 | bb_show_usage(); | 56 | bb_show_usage(); |
diff --git a/editors/diff.c b/editors/diff.c index c158c8763..64b7daa11 100644 --- a/editors/diff.c +++ b/editors/diff.c | |||
@@ -588,7 +588,9 @@ static void check(FILE * f1, FILE * f2) | |||
588 | while (1) { | 588 | while (1) { |
589 | ctold++; | 589 | ctold++; |
590 | ctnew++; | 590 | ctnew++; |
591 | if ((c = getc(f1)) != (d = getc(f2))) { | 591 | c = getc(f1); |
592 | d = getc(f2); | ||
593 | if (c != d) { | ||
592 | J[i] = 0; | 594 | J[i] = 0; |
593 | if (c != '\n' && c != EOF) | 595 | if (c != '\n' && c != EOF) |
594 | ctold += skipline(f1); | 596 | ctold += skipline(f1); |
@@ -668,7 +670,8 @@ static void fetch(long *f, int a, int b, FILE * lb, int ch) | |||
668 | } | 670 | } |
669 | col = 0; | 671 | col = 0; |
670 | for (j = 0, lastc = '\0'; j < nc; j++, lastc = c) { | 672 | for (j = 0, lastc = '\0'; j < nc; j++, lastc = c) { |
671 | if ((c = getc(lb)) == EOF) { | 673 | c = getc(lb); |
674 | if (c == EOF) { | ||
672 | printf("\n\\ No newline at end of file\n"); | 675 | printf("\n\\ No newline at end of file\n"); |
673 | return; | 676 | return; |
674 | } | 677 | } |
diff --git a/init/init.c b/init/init.c index 409e8c41f..4b543a44f 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -369,7 +369,8 @@ static pid_t run(const struct init_action *a) | |||
369 | if (a->action & (SYSINIT | WAIT | CTRLALTDEL | SHUTDOWN | RESTART)) { | 369 | if (a->action & (SYSINIT | WAIT | CTRLALTDEL | SHUTDOWN | RESTART)) { |
370 | 370 | ||
371 | /* Now fork off another process to just hang around */ | 371 | /* Now fork off another process to just hang around */ |
372 | if ((pid = fork()) < 0) { | 372 | pid = fork(); |
373 | if (pid) { | ||
373 | message(L_LOG | L_CONSOLE, "Can't fork"); | 374 | message(L_LOG | L_CONSOLE, "Can't fork"); |
374 | _exit(1); | 375 | _exit(1); |
375 | } | 376 | } |
@@ -388,7 +389,8 @@ static pid_t run(const struct init_action *a) | |||
388 | _exit(0); | 389 | _exit(0); |
389 | 390 | ||
390 | /* Use a temporary process to steal the controlling tty. */ | 391 | /* Use a temporary process to steal the controlling tty. */ |
391 | if ((pid = fork()) < 0) { | 392 | pid = fork(); |
393 | if (pid < 0) { | ||
392 | message(L_LOG | L_CONSOLE, "Can't fork"); | 394 | message(L_LOG | L_CONSOLE, "Can't fork"); |
393 | _exit(1); | 395 | _exit(1); |
394 | } | 396 | } |
diff --git a/libbb/device_open.c b/libbb/device_open.c index 2b35ad8a3..6907e9814 100644 --- a/libbb/device_open.c +++ b/libbb/device_open.c | |||
@@ -12,15 +12,17 @@ | |||
12 | /* try to open up the specified device */ | 12 | /* try to open up the specified device */ |
13 | int device_open(const char *device, int mode) | 13 | int device_open(const char *device, int mode) |
14 | { | 14 | { |
15 | int m, f, fd = -1; | 15 | int m, f, fd; |
16 | 16 | ||
17 | m = mode | O_NONBLOCK; | 17 | m = mode | O_NONBLOCK; |
18 | 18 | ||
19 | /* Retry up to 5 times */ | 19 | /* Retry up to 5 times */ |
20 | /* TODO: explain why it can't be considered insane */ | 20 | /* TODO: explain why it can't be considered insane */ |
21 | for (f = 0; f < 5; f++) | 21 | for (f = 0; f < 5; f++) { |
22 | if ((fd = open(device, m, 0600)) >= 0) | 22 | fd = open(device, m, 0600); |
23 | if (fd >= 0) | ||
23 | break; | 24 | break; |
25 | } | ||
24 | if (fd < 0) | 26 | if (fd < 0) |
25 | return fd; | 27 | return fd; |
26 | /* Reset original flags. */ | 28 | /* Reset original flags. */ |
diff --git a/libbb/dump.c b/libbb/dump.c index 829050d69..71e35c60f 100644 --- a/libbb/dump.c +++ b/libbb/dump.c | |||
@@ -59,7 +59,8 @@ int bb_dump_size(FS * fs) | |||
59 | prec = atoi(fmt); | 59 | prec = atoi(fmt); |
60 | while (isdigit(*++fmt)); | 60 | while (isdigit(*++fmt)); |
61 | } | 61 | } |
62 | if (!(p = strchr(size_conv_str + 12, *fmt))) { | 62 | p = strchr(size_conv_str + 12, *fmt); |
63 | if (!p) { | ||
63 | if (*fmt == 's') { | 64 | if (*fmt == 's') { |
64 | bcnt += prec; | 65 | bcnt += prec; |
65 | } else if (*fmt == '_') { | 66 | } else if (*fmt == '_') { |
@@ -162,7 +163,8 @@ static void rewrite(FS * fs) | |||
162 | DO_INT_CONV: | 163 | DO_INT_CONV: |
163 | { | 164 | { |
164 | const char *e; | 165 | const char *e; |
165 | if (!(e = strchr(lcc, *p1))) { | 166 | e = strchr(lcc, *p1); |
167 | if (!e) { | ||
166 | goto DO_BAD_CONV_CHAR; | 168 | goto DO_BAD_CONV_CHAR; |
167 | } | 169 | } |
168 | pr->flags = F_INT; | 170 | pr->flags = F_INT; |
diff --git a/libbb/obscure.c b/libbb/obscure.c index 2599095df..5cc906235 100644 --- a/libbb/obscure.c +++ b/libbb/obscure.c | |||
@@ -130,7 +130,8 @@ static const char *obscure_msg(const char *old_p, const char *new_p, const struc | |||
130 | c = 0; | 130 | c = 0; |
131 | p = new_p; | 131 | p = new_p; |
132 | while (1) { | 132 | while (1) { |
133 | if ((p = strchr(p, new_p[i])) == NULL) { | 133 | p = strchr(p, new_p[i]); |
134 | if (p == NULL) { | ||
134 | break; | 135 | break; |
135 | } | 136 | } |
136 | c++; | 137 | c++; |
diff --git a/loginutils/getty.c b/loginutils/getty.c index bc735d0c4..d32d18935 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c | |||
@@ -166,8 +166,10 @@ static void parse_speeds(struct options *op, char *arg) | |||
166 | 166 | ||
167 | debug("entered parse_speeds\n"); | 167 | debug("entered parse_speeds\n"); |
168 | for (cp = strtok(arg, ","); cp != 0; cp = strtok((char *) 0, ",")) { | 168 | for (cp = strtok(arg, ","); cp != 0; cp = strtok((char *) 0, ",")) { |
169 | if ((op->speeds[op->numspeed++] = bcode(cp)) <= 0) | 169 | op->speeds[op->numspeed] = bcode(cp); |
170 | if (op->speeds[op->numspeed] <= 0) | ||
170 | bb_error_msg_and_die("bad speed: %s", cp); | 171 | bb_error_msg_and_die("bad speed: %s", cp); |
172 | op->numspeed++; | ||
171 | if (op->numspeed > MAX_SPEED) | 173 | if (op->numspeed > MAX_SPEED) |
172 | bb_error_msg_and_die("too many alternate speeds"); | 174 | bb_error_msg_and_die("too many alternate speeds"); |
173 | } | 175 | } |
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c index cd94869ae..9990142c2 100644 --- a/miscutils/devfsd.c +++ b/miscutils/devfsd.c | |||
@@ -465,7 +465,8 @@ static void read_config_file(char *path, int optional, unsigned long *event_mask | |||
465 | free(p); | 465 | free(p); |
466 | return; | 466 | return; |
467 | } | 467 | } |
468 | if ((fp = fopen(path, "r")) != NULL) { | 468 | fp = fopen(path, "r"); |
469 | if (fp != NULL) { | ||
469 | while (fgets(buf, STRING_LENGTH, fp) != NULL) { | 470 | while (fgets(buf, STRING_LENGTH, fp) != NULL) { |
470 | /* Skip whitespace */ | 471 | /* Skip whitespace */ |
471 | line = buf; | 472 | line = buf; |
@@ -560,7 +561,8 @@ static void process_config_line(const char *line, unsigned long *event_mask) | |||
560 | case 4: /* "PERMISSIONS" */ | 561 | case 4: /* "PERMISSIONS" */ |
561 | new->action.what = AC_PERMISSIONS; | 562 | new->action.what = AC_PERMISSIONS; |
562 | /* Get user and group */ | 563 | /* Get user and group */ |
563 | if ((ptr = strchr(p[0], '.')) == NULL) { | 564 | ptr = strchr(p[0], '.'); |
565 | if (ptr == NULL) { | ||
564 | msg = "UID.GID"; | 566 | msg = "UID.GID"; |
565 | goto process_config_line_err; /*"missing '.' in UID.GID"*/ | 567 | goto process_config_line_err; /*"missing '.' in UID.GID"*/ |
566 | } | 568 | } |
@@ -979,8 +981,9 @@ static int copy_inode(const char *destpath, const struct stat *dest_stat, | |||
979 | if ((source_stat->st_mode & S_IFMT) ==(dest_stat->st_mode & S_IFMT)) { | 981 | if ((source_stat->st_mode & S_IFMT) ==(dest_stat->st_mode & S_IFMT)) { |
980 | /* Same type */ | 982 | /* Same type */ |
981 | if (S_ISLNK(source_stat->st_mode)) { | 983 | if (S_ISLNK(source_stat->st_mode)) { |
982 | if ((source_len = readlink(sourcepath, source_link, STRING_LENGTH - 1)) < 0 | 984 | source_len = readlink(sourcepath, source_link, STRING_LENGTH - 1); |
983 | || (dest_len = readlink(destpath , dest_link , STRING_LENGTH - 1)) < 0 | 985 | if ((source_len < 0) |
986 | || (dest_len = readlink(destpath, dest_link, STRING_LENGTH - 1)) < 0 | ||
984 | ) | 987 | ) |
985 | return FALSE; | 988 | return FALSE; |
986 | source_link[source_len] = '\0'; | 989 | source_link[source_len] = '\0'; |
@@ -999,7 +1002,8 @@ static int copy_inode(const char *destpath, const struct stat *dest_stat, | |||
999 | unlink(destpath); | 1002 | unlink(destpath); |
1000 | switch (source_stat->st_mode & S_IFMT) { | 1003 | switch (source_stat->st_mode & S_IFMT) { |
1001 | case S_IFSOCK: | 1004 | case S_IFSOCK: |
1002 | if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) | 1005 | fd = socket(AF_UNIX, SOCK_STREAM, 0); |
1006 | if (fd < 0) | ||
1003 | break; | 1007 | break; |
1004 | un_addr.sun_family = AF_UNIX; | 1008 | un_addr.sun_family = AF_UNIX; |
1005 | snprintf(un_addr.sun_path, sizeof(un_addr.sun_path), "%s", destpath); | 1009 | snprintf(un_addr.sun_path, sizeof(un_addr.sun_path), "%s", destpath); |
@@ -1009,14 +1013,16 @@ static int copy_inode(const char *destpath, const struct stat *dest_stat, | |||
1009 | break; | 1013 | break; |
1010 | goto do_chown; | 1014 | goto do_chown; |
1011 | case S_IFLNK: | 1015 | case S_IFLNK: |
1012 | if ((val = readlink(sourcepath, symlink_val, STRING_LENGTH - 1)) < 0) | 1016 | val = readlink(sourcepath, symlink_val, STRING_LENGTH - 1); |
1017 | if (val < 0) | ||
1013 | break; | 1018 | break; |
1014 | symlink_val[val] = '\0'; | 1019 | symlink_val[val] = '\0'; |
1015 | if (symlink(symlink_val, destpath) == 0) | 1020 | if (symlink(symlink_val, destpath) == 0) |
1016 | return TRUE; | 1021 | return TRUE; |
1017 | break; | 1022 | break; |
1018 | case S_IFREG: | 1023 | case S_IFREG: |
1019 | if ((fd = open(destpath, O_RDONLY | O_CREAT, new_mode & ~S_IFMT)) < 0) | 1024 | fd = open(destpath, O_RDONLY | O_CREAT, new_mode & ~S_IFMT); |
1025 | if (fd < 0) | ||
1020 | break; | 1026 | break; |
1021 | close(fd); | 1027 | close(fd); |
1022 | if (chmod(destpath, new_mode & ~S_IFMT) != 0) | 1028 | if (chmod(destpath, new_mode & ~S_IFMT) != 0) |
@@ -1082,7 +1088,7 @@ static int get_uid_gid(int flag, const char *string) | |||
1082 | if (isdigit(string[0]) ||((string[0] == '-') && isdigit(string[1]))) | 1088 | if (isdigit(string[0]) ||((string[0] == '-') && isdigit(string[1]))) |
1083 | return atoi(string); | 1089 | return atoi(string); |
1084 | 1090 | ||
1085 | if (flag == UID && (pw_ent = getpwnam(string)) != NULL) | 1091 | if (flag == UID && (pw_ent = getpwnam(string)) != NULL) |
1086 | return pw_ent->pw_uid; | 1092 | return pw_ent->pw_uid; |
1087 | 1093 | ||
1088 | if (flag == GID && (grp_ent = getgrnam(string)) != NULL) | 1094 | if (flag == GID && (grp_ent = getgrnam(string)) != NULL) |
@@ -1197,7 +1203,8 @@ static void dir_operation(int type, const char * dir_name, int var, unsigned lon | |||
1197 | struct dirent *de; | 1203 | struct dirent *de; |
1198 | char *path; | 1204 | char *path; |
1199 | 1205 | ||
1200 | if ((dp = warn_opendir(dir_name)) == NULL) | 1206 | dp = warn_opendir(dir_name); |
1207 | if (dp == NULL) | ||
1201 | return; | 1208 | return; |
1202 | 1209 | ||
1203 | while ((de = readdir(dp)) != NULL) { | 1210 | while ((de = readdir(dp)) != NULL) { |
@@ -1581,7 +1588,8 @@ int st_expr_expand(char *output, unsigned int length, const char *input, | |||
1581 | ch = input[1]; | 1588 | ch = input[1]; |
1582 | if (isspace(ch) ||(ch == '/') ||(ch == '\0')) { | 1589 | if (isspace(ch) ||(ch == '/') ||(ch == '\0')) { |
1583 | /* User's own home directory: leave separator for next time */ | 1590 | /* User's own home directory: leave separator for next time */ |
1584 | if ((env = getenv("HOME")) == NULL) { | 1591 | env = getenv("HOME"); |
1592 | if (env == NULL) { | ||
1585 | info_logger(LOG_INFO, bb_msg_variable_not_found, "HOME"); | 1593 | info_logger(LOG_INFO, bb_msg_variable_not_found, "HOME"); |
1586 | return FALSE; | 1594 | return FALSE; |
1587 | } | 1595 | } |
@@ -1600,7 +1608,8 @@ int st_expr_expand(char *output, unsigned int length, const char *input, | |||
1600 | goto st_expr_expand_out; | 1608 | goto st_expr_expand_out; |
1601 | safe_memcpy(tmp, input, len); | 1609 | safe_memcpy(tmp, input, len); |
1602 | input = ptr - 1; | 1610 | input = ptr - 1; |
1603 | if ((pwent = getpwnam(tmp)) == NULL) { | 1611 | pwent = getpwnam(tmp); |
1612 | if (pwent == NULL) { | ||
1604 | info_logger(LOG_INFO, "no pwent for: %s", tmp); | 1613 | info_logger(LOG_INFO, "no pwent for: %s", tmp); |
1605 | return FALSE; | 1614 | return FALSE; |
1606 | } | 1615 | } |
@@ -1680,7 +1689,8 @@ static const char *expand_variable(char *buffer, unsigned int length, | |||
1680 | 1689 | ||
1681 | safe_memcpy(tmp, input, len); | 1690 | safe_memcpy(tmp, input, len); |
1682 | input = ptr - 1; | 1691 | input = ptr - 1; |
1683 | if ((env = get_variable_v2(tmp, func, info)) == NULL) { | 1692 | env = get_variable_v2(tmp, func, info); |
1693 | if (env == NULL) { | ||
1684 | info_logger(LOG_INFO, bb_msg_variable_not_found, tmp); | 1694 | info_logger(LOG_INFO, bb_msg_variable_not_found, tmp); |
1685 | return NULL; | 1695 | return NULL; |
1686 | } | 1696 | } |
@@ -1740,7 +1750,8 @@ static const char *expand_variable(char *buffer, unsigned int length, | |||
1740 | } | 1750 | } |
1741 | --ptr; | 1751 | --ptr; |
1742 | /* At this point ptr should point to closing brace of "${var:-word}" */ | 1752 | /* At this point ptr should point to closing brace of "${var:-word}" */ |
1743 | if ((env = get_variable_v2(tmp, func, info)) != NULL) { | 1753 | env = get_variable_v2(tmp, func, info); |
1754 | if (env != NULL) { | ||
1744 | /* Found environment variable, so skip the input to the closing brace | 1755 | /* Found environment variable, so skip the input to the closing brace |
1745 | and return the variable */ | 1756 | and return the variable */ |
1746 | input = ptr; | 1757 | input = ptr; |
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index 93b1aacb3..03a30e6e9 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c | |||
@@ -1111,7 +1111,8 @@ static void identify(uint16_t *val) | |||
1111 | /* reset result */ | 1111 | /* reset result */ |
1112 | jj = val[HWRST_RSLT]; | 1112 | jj = val[HWRST_RSLT]; |
1113 | if ((jj & VALID) == VALID_VAL) { | 1113 | if ((jj & VALID) == VALID_VAL) { |
1114 | if (!(oo = (jj & RST0))) | 1114 | oo = (jj & RST0); |
1115 | if (!oo) | ||
1115 | jj >>= 8; | 1116 | jj >>= 8; |
1116 | if ((jj & DEV_DET) == JUMPER_VAL) | 1117 | if ((jj & DEV_DET) == JUMPER_VAL) |
1117 | strng = " determined by the jumper"; | 1118 | strng = " determined by the jumper"; |
diff --git a/miscutils/readahead.c b/miscutils/readahead.c index 647eb3121..7b375cfff 100644 --- a/miscutils/readahead.c +++ b/miscutils/readahead.c | |||
@@ -15,17 +15,15 @@ | |||
15 | int readahead_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 15 | int readahead_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
16 | int readahead_main(int argc, char **argv) | 16 | int readahead_main(int argc, char **argv) |
17 | { | 17 | { |
18 | FILE *f; | ||
19 | int retval = EXIT_SUCCESS; | 18 | int retval = EXIT_SUCCESS; |
20 | 19 | ||
21 | if (argc == 1) bb_show_usage(); | 20 | if (argc == 1) bb_show_usage(); |
22 | 21 | ||
23 | while (*++argv) { | 22 | while (*++argv) { |
24 | if ((f = fopen_or_warn(*argv, "r")) != NULL) { | 23 | int fd = open_or_warn(*argv, O_RDONLY); |
25 | int r, fd=fileno(f); | 24 | if (fd >= 0) { |
26 | 25 | int r = readahead(fd, 0, fdlength(fd)); | |
27 | r = readahead(fd, 0, fdlength(fd)); | 26 | close(fd); |
28 | fclose(f); | ||
29 | if (r >= 0) continue; | 27 | if (r >= 0) continue; |
30 | } | 28 | } |
31 | retval = EXIT_FAILURE; | 29 | retval = EXIT_FAILURE; |
diff --git a/runit/runit_lib.c b/runit/runit_lib.c index 2ed9054fd..bedd5401f 100644 --- a/runit/runit_lib.c +++ b/runit/runit_lib.c | |||
@@ -233,19 +233,23 @@ unsigned pmatch(const char *p, const char *s, unsigned len) | |||
233 | if (!c) return !len; | 233 | if (!c) return !len; |
234 | switch (c) { | 234 | switch (c) { |
235 | case '*': | 235 | case '*': |
236 | if (!(c = *p)) return 1; | 236 | c = *p; |
237 | if (!c) return 1; | ||
237 | for (;;) { | 238 | for (;;) { |
238 | if (!len) return 0; | 239 | if (!len) return 0; |
239 | if (*s == c) break; | 240 | if (*s == c) break; |
240 | ++s; --len; | 241 | ++s; |
242 | --len; | ||
241 | } | 243 | } |
242 | continue; | 244 | continue; |
243 | case '+': | 245 | case '+': |
244 | if ((c = *p++) != *s) return 0; | 246 | c = *p++; |
247 | if (c != *s) return 0; | ||
245 | for (;;) { | 248 | for (;;) { |
246 | if (!len) return 1; | 249 | if (!len) return 1; |
247 | if (*s != c) break; | 250 | if (*s != c) break; |
248 | ++s; --len; | 251 | ++s; |
252 | --len; | ||
249 | } | 253 | } |
250 | continue; | 254 | continue; |
251 | /* | 255 | /* |
@@ -260,7 +264,8 @@ unsigned pmatch(const char *p, const char *s, unsigned len) | |||
260 | default: | 264 | default: |
261 | if (!len) return 0; | 265 | if (!len) return 0; |
262 | if (*s != c) return 0; | 266 | if (*s != c) return 0; |
263 | ++s; --len; | 267 | ++s; |
268 | --len; | ||
264 | continue; | 269 | continue; |
265 | } | 270 | } |
266 | } | 271 | } |
diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c index 1adb0fc2f..90b327b4c 100644 --- a/util-linux/dmesg.c +++ b/util-linux/dmesg.c | |||
@@ -27,7 +27,8 @@ int dmesg_main(int argc, char **argv) | |||
27 | 27 | ||
28 | len = (flags & 2) ? xatoul_range(size, 2, INT_MAX) : 16384; | 28 | len = (flags & 2) ? xatoul_range(size, 2, INT_MAX) : 16384; |
29 | buf = xmalloc(len); | 29 | buf = xmalloc(len); |
30 | if (0 > (len = klogctl(3 + (flags & 1), buf, len))) | 30 | len = klogctl(3 + (flags & 1), buf, len); |
31 | if (len < 0) | ||
31 | bb_perror_msg_and_die("klogctl"); | 32 | bb_perror_msg_and_die("klogctl"); |
32 | 33 | ||
33 | // Skip <#> at the start of lines, and make sure we end with a newline. | 34 | // Skip <#> at the start of lines, and make sure we end with a newline. |
diff --git a/util-linux/fbset.c b/util-linux/fbset.c index f67a283c1..d616abd36 100644 --- a/util-linux/fbset.c +++ b/util-linux/fbset.c | |||
@@ -181,10 +181,11 @@ static int readmode(struct fb_var_screeninfo *base, const char *fn, | |||
181 | f = xfopen(fn, "r"); | 181 | f = xfopen(fn, "r"); |
182 | while (!feof(f)) { | 182 | while (!feof(f)) { |
183 | fgets(buf, sizeof(buf), f); | 183 | fgets(buf, sizeof(buf), f); |
184 | if (!(p = strstr(buf, "mode ")) && !(p = strstr(buf, "mode\t"))) | 184 | p = strstr(buf, "mode "); |
185 | if (!p && !(p = strstr(buf, "mode\t"))) | ||
185 | continue; | 186 | continue; |
186 | p += 5; | 187 | p = strstr(p + 5, mode); |
187 | if (!(p = strstr(buf, mode))) | 188 | if (!p) |
188 | continue; | 189 | continue; |
189 | p += strlen(mode); | 190 | p += strlen(mode); |
190 | if (!isspace(*p) && (*p != 0) && (*p != '"') | 191 | if (!isspace(*p) && (*p != 0) && (*p != '"') |
@@ -193,7 +194,8 @@ static int readmode(struct fb_var_screeninfo *base, const char *fn, | |||
193 | 194 | ||
194 | while (!feof(f)) { | 195 | while (!feof(f)) { |
195 | fgets(buf, sizeof(buf), f); | 196 | fgets(buf, sizeof(buf), f); |
196 | if ((p = strstr(buf, "geometry "))) { | 197 | p = strstr(buf, "geometry "); |
198 | if (p) { | ||
197 | p += 9; | 199 | p += 9; |
198 | /* FIXME: catastrophic on arches with 64bit ints */ | 200 | /* FIXME: catastrophic on arches with 64bit ints */ |
199 | sscanf(p, "%d %d %d %d %d", | 201 | sscanf(p, "%d %d %d %d %d", |
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c index 01c01bd24..3b60847c9 100644 --- a/util-linux/fdisk.c +++ b/util-linux/fdisk.c | |||
@@ -1837,7 +1837,8 @@ wrong_p_order(int *prev) | |||
1837 | last_p_start_pos = 0; | 1837 | last_p_start_pos = 0; |
1838 | } | 1838 | } |
1839 | pe = &ptes[i]; | 1839 | pe = &ptes[i]; |
1840 | if ((p = pe->part_table)->sys_ind) { | 1840 | p = pe->part_table; |
1841 | if (p->sys_ind) { | ||
1841 | p_start_pos = get_partition_start(pe); | 1842 | p_start_pos = get_partition_start(pe); |
1842 | 1843 | ||
1843 | if (last_p_start_pos > p_start_pos) { | 1844 | if (last_p_start_pos > p_start_pos) { |