From b878121e76730f7f7e458180363371dbe10fd253 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 24 May 2015 18:01:53 +0200 Subject: tc: fix print_rate Signed-off-by: Denys Vlasenko --- networking/tc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/networking/tc.c b/networking/tc.c index 533f7c042..76e2e8359 100644 --- a/networking/tc.c +++ b/networking/tc.c @@ -151,17 +151,17 @@ static void print_rate(char *buf, int len, uint32_t rate) double tmp = (double)rate*8; if (use_iec) { - if (tmp >= 1000.0*1024.0*1024.0) - snprintf(buf, len, "%.0fMibit", tmp/1024.0*1024.0); - else if (tmp >= 1000.0*1024) + if (tmp >= 1000*1024*1024) + snprintf(buf, len, "%.0fMibit", tmp/(1024*1024)); + else if (tmp >= 1000*1024) snprintf(buf, len, "%.0fKibit", tmp/1024); else snprintf(buf, len, "%.0fbit", tmp); } else { - if (tmp >= 1000.0*1000000.0) - snprintf(buf, len, "%.0fMbit", tmp/1000000.0); - else if (tmp >= 1000.0 * 1000.0) - snprintf(buf, len, "%.0fKbit", tmp/1000.0); + if (tmp >= 1000*1000000) + snprintf(buf, len, "%.0fMbit", tmp/1000000); + else if (tmp >= 1000*1000) + snprintf(buf, len, "%.0fKbit", tmp/1000); else snprintf(buf, len, "%.0fbit", tmp); } -- cgit v1.2.3-55-g6feb From c4603fb09aa2ec06bc8c0ad51b69fe7995a8ea17 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 25 May 2015 13:31:25 +0200 Subject: dc: fix "dc p" prinitng bogus data function old new delta check_under - 20 +20 print_no_pop 27 32 +5 pop 33 24 -9 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/1 up/down: 25/-9) Total: 16 bytes Signed-off-by: Denys Vlasenko --- miscutils/dc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/miscutils/dc.c b/miscutils/dc.c index f94d6fa6b..9c74172ba 100644 --- a/miscutils/dc.c +++ b/miscutils/dc.c @@ -56,6 +56,12 @@ enum { STACK_SIZE = (COMMON_BUFSIZE - offsetof(struct globals, stack)) / sizeof( } while (0) +static void check_under(void) +{ + if (pointer == 0) + bb_error_msg_and_die("stack underflow"); +} + static void push(double a) { if (pointer >= STACK_SIZE) @@ -65,8 +71,7 @@ static void push(double a) static double pop(void) { - if (pointer == 0) - bb_error_msg_and_die("stack underflow"); + check_under(); return stack[--pointer]; } @@ -187,6 +192,7 @@ static void print_stack_no_pop(void) static void print_no_pop(void) { + check_under(); print_base(stack[pointer-1]); } -- cgit v1.2.3-55-g6feb From 97c6491b4edf4bc9db293533ae0c3a81c4ef07f7 Mon Sep 17 00:00:00 2001 From: Maninder Singh Date: Mon, 25 May 2015 13:46:36 +0200 Subject: typo fixes Signed-off-by: Maninder Singh Signed-off-by: Denys Vlasenko --- Makefile | 2 +- coreutils/Config.src | 2 +- coreutils/stat.c | 2 +- coreutils/uudecode.c | 2 +- docs/cgi/env.html | 2 +- e2fsprogs/old_e2fsprogs/blkid/dev.c | 2 +- e2fsprogs/old_e2fsprogs/blkid/tag.c | 2 +- e2fsprogs/old_e2fsprogs/e2fsck.c | 4 ++-- editors/diff.c | 2 +- editors/vi.c | 14 +++++++------- findutils/xargs.c | 2 +- miscutils/less.c | 2 +- networking/netstat.c | 2 +- scripts/basic/docproc.c | 2 +- selinux/Config.src | 2 +- shell/hush.c | 2 +- util-linux/mkfs_reiser.c | 2 +- 17 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index e0888578f..65b2642f0 100644 --- a/Makefile +++ b/Makefile @@ -552,7 +552,7 @@ export INSTALL_PATH ?= /boot # # INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory # relocations required by build roots. This is not defined in the -# makefile but the arguement can be passed to make if needed. +# makefile but the argument can be passed to make if needed. # MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) diff --git a/coreutils/Config.src b/coreutils/Config.src index 1bbb91ee9..1ec3a0a99 100644 --- a/coreutils/Config.src +++ b/coreutils/Config.src @@ -11,7 +11,7 @@ config CAL bool "cal" default y help - cal is used to display a monthly calender. + cal is used to display a monthly calendar. config CATV bool "catv" diff --git a/coreutils/stat.c b/coreutils/stat.c index 769fac078..f7fd227bb 100644 --- a/coreutils/stat.c +++ b/coreutils/stat.c @@ -374,7 +374,7 @@ static void print_it(const char *masterformat, { /* Create a working copy of the format string */ char *format = xstrdup(masterformat); - /* Add 2 to accomodate our conversion of the stat '%s' format string + /* Add 2 to accommodate our conversion of the stat '%s' format string * to the printf '%llu' one. */ char *dest = xmalloc(strlen(format) + 2 + 1); char *b; diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c index 3f1227306..7aa5c67f2 100644 --- a/coreutils/uudecode.c +++ b/coreutils/uudecode.c @@ -46,7 +46,7 @@ static void FAST_FUNC read_stduu(FILE *src_stream, FILE *dst_stream, int flags U encoded_len = line[0] * 4 / 3; /* Check that line is not too short. (we tolerate - * overly _long_ line to accomodate possible extra '`'). + * overly _long_ line to accommodate possible extra '`'). * Empty line case is also caught here. */ if (str_len <= encoded_len) { break; /* go to bb_error_msg_and_die("short file"); */ diff --git a/docs/cgi/env.html b/docs/cgi/env.html index b83c750bf..66a548b46 100644 --- a/docs/cgi/env.html +++ b/docs/cgi/env.html @@ -38,7 +38,7 @@ fulfilled by the gateway program:

  • SERVER_PROTOCOL

    - The name and revision of the information protcol this request came + The name and revision of the information protocol this request came in with. Format: protocol/revision

  • SERVER_PORT

    diff --git a/e2fsprogs/old_e2fsprogs/blkid/dev.c b/e2fsprogs/old_e2fsprogs/blkid/dev.c index 260e49c65..84b7b0a72 100644 --- a/e2fsprogs/old_e2fsprogs/blkid/dev.c +++ b/e2fsprogs/old_e2fsprogs/blkid/dev.c @@ -90,7 +90,7 @@ void blkid_debug_dump_dev(blkid_dev dev) * * These routines do not expose the list.h implementation, which are a * contamination of the namespace, and which force us to reveal far, far - * too much of our internal implemenation. I'm not convinced I want + * too much of our internal implementation. I'm not convinced I want * to keep list.h in the long term, anyway. It's fine for kernel * programming, but performance is not the #1 priority for this * library, and I really don't like the tradeoff of type-safety for diff --git a/e2fsprogs/old_e2fsprogs/blkid/tag.c b/e2fsprogs/old_e2fsprogs/blkid/tag.c index 7424edeb8..f10a701d2 100644 --- a/e2fsprogs/old_e2fsprogs/blkid/tag.c +++ b/e2fsprogs/old_e2fsprogs/blkid/tag.c @@ -230,7 +230,7 @@ errout: * * These routines do not expose the list.h implementation, which are a * contamination of the namespace, and which force us to reveal far, far - * too much of our internal implemenation. I'm not convinced I want + * too much of our internal implementation. I'm not convinced I want * to keep list.h in the long term, anyway. It's fine for kernel * programming, but performance is not the #1 priority for this * library, and I really don't like the tradeoff of type-safety for diff --git a/e2fsprogs/old_e2fsprogs/e2fsck.c b/e2fsprogs/old_e2fsprogs/e2fsck.c index 0799b64ad..b816c62b0 100644 --- a/e2fsprogs/old_e2fsprogs/e2fsck.c +++ b/e2fsprogs/old_e2fsprogs/e2fsck.c @@ -6381,7 +6381,7 @@ static int deallocate_inode_block(ext2_filsys fs, blk_t *block_nr, } /* - * This fuction deallocates an inode + * This function deallocates an inode */ static void deallocate_inode(e2fsck_t ctx, ext2_ino_t ino, char* block_buf) { @@ -6447,7 +6447,7 @@ static void deallocate_inode(e2fsck_t ctx, ext2_ino_t ino, char* block_buf) } /* - * This fuction clears the htree flag on an inode + * This function clears the htree flag on an inode */ static void clear_htree(e2fsck_t ctx, ext2_ino_t ino) { diff --git a/editors/diff.c b/editors/diff.c index c3ad31bf3..cf14b1d03 100644 --- a/editors/diff.c +++ b/editors/diff.c @@ -363,7 +363,7 @@ static void stone(const int *a, int n, const int *b, int *J, int pref) } struct line { - /* 'serial' is not used in the begining, so we reuse it + /* 'serial' is not used in the beginning, so we reuse it * to store line offsets, thus reducing memory pressure */ union { diff --git a/editors/vi.c b/editors/vi.c index 2e4f7fcb5..6ce513c0c 100644 --- a/editors/vi.c +++ b/editors/vi.c @@ -501,7 +501,7 @@ static char *prev_line(char *); // return pointer to prev line B-o-l static char *next_line(char *); // return pointer to next line B-o-l static char *end_screen(void); // get pointer to last char on screen static int count_lines(char *, char *); // count line from start to stop -static char *find_line(int); // find begining of line #li +static char *find_line(int); // find beginning of line #li static char *move_to_col(char *, int); // move "p" to column l static void dot_left(void); // move dot left- dont leave line static void dot_right(void); // move dot right- dont leave line @@ -1684,10 +1684,10 @@ static char *dollar_line(char *p) // return pointer to just before NL line static char *prev_line(char *p) // return pointer first char prev line { - p = begin_line(p); // goto begining of cur line + p = begin_line(p); // goto beginning of cur line if (p > text && p[-1] == '\n') p--; // step to prev line - p = begin_line(p); // goto begining of prev line + p = begin_line(p); // goto beginning of prev line return p; } @@ -1735,7 +1735,7 @@ static int count_lines(char *start, char *stop) return cnt; } -static char *find_line(int li) // find begining of line #li +static char *find_line(int li) // find beginning of line #li { char *q; @@ -3357,7 +3357,7 @@ static void refresh(int full_screen) tp = t + 1; } - // see if there are any changes between vitual screen and out_buf + // see if there are any changes between virtual screen and out_buf changed = FALSE; // assume no change cs = 0; ce = columns - 1; @@ -3394,7 +3394,7 @@ static void refresh(int full_screen) if (cs < 0) cs = 0; if (ce > columns - 1) ce = columns - 1; if (cs > ce) { cs = 0; ce = columns - 1; } - // is there a change between vitual screen and out_buf + // is there a change between virtual screen and out_buf if (changed) { // copy changed part of buffer to virtual screen memcpy(sp+cs, out_buf+cs, ce-cs+1); @@ -3844,7 +3844,7 @@ static void do_cmd(int c) } break; #endif /* FEATURE_VI_SEARCH */ - case '0': // 0- goto begining of line + case '0': // 0- goto beginning of line case '1': // 1- case '2': // 2- case '3': // 3- diff --git a/findutils/xargs.c b/findutils/xargs.c index 76c4747fe..25e47ec89 100644 --- a/findutils/xargs.c +++ b/findutils/xargs.c @@ -151,7 +151,7 @@ static void store_param(char *s) * is seen, store the address of a new parameter to args[]. * If reading discovers that last chars do not form the complete * parameter, the pointer to the first such "tail character" is returned. - * (buf has extra byte at the end to accomodate terminating NUL + * (buf has extra byte at the end to accommodate terminating NUL * of "tail characters" string). * Otherwise, the returned pointer points to NUL byte. * On entry, buf[] may contain some "seed chars" which are to become diff --git a/miscutils/less.c b/miscutils/less.c index 554e54687..d5a68d1e1 100644 --- a/miscutils/less.c +++ b/miscutils/less.c @@ -1848,7 +1848,7 @@ key and/or command line switch compatibility is a good idea: Most options may be changed either on the command line, or from within less by using the - or -- command. Options may be given in one of two forms: either a single - character preceded by a -, or a name preceeded by --. + character preceded by a -, or a name preceded by --. -? ........ --help Display help (from command line). -a ........ --search-skip-screen diff --git a/networking/netstat.c b/networking/netstat.c index 1303d3f3d..2196d42f7 100644 --- a/networking/netstat.c +++ b/networking/netstat.c @@ -119,7 +119,7 @@ typedef enum { #define ADDR_NORMAL_WIDTH 23 /* When there are IPv6 connections the IPv6 addresses will be * truncated to none-recognition. The '-W' option makes the - * address columns wide enough to accomodate for longest possible + * address columns wide enough to accommodate for longest possible * IPv6 addresses, i.e. addresses of the form * xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:ddd.ddd.ddd.ddd */ diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c index 7f21443c1..720098a23 100644 --- a/scripts/basic/docproc.c +++ b/scripts/basic/docproc.c @@ -264,7 +264,7 @@ void singfunc(char * filename, char * line) vec[idx++] = KERNELDOC; vec[idx++] = DOCBOOK; - /* Split line up in individual parameters preceeded by FUNCTION */ + /* Split line up in individual parameters preceded by FUNCTION */ for (i=0; line[i]; i++) { if (isspace(line[i])) { line[i] = '\0'; diff --git a/selinux/Config.src b/selinux/Config.src index 47d15b6af..d4701f60b 100644 --- a/selinux/Config.src +++ b/selinux/Config.src @@ -64,7 +64,7 @@ config RUNCON default n depends on SELINUX help - Enable support to run command in speficied security context. + Enable support to run command in specified security context. config FEATURE_RUNCON_LONG_OPTIONS bool "Enable long options" diff --git a/shell/hush.c b/shell/hush.c index f2c0a70f2..96c739fb7 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -442,7 +442,7 @@ enum { MAYBE_ASSIGNMENT = 0, DEFINITELY_ASSIGNMENT = 1, NOT_ASSIGNMENT = 2, - /* Not an assigment, but next word may be: "if v=xyz cmd;" */ + /* Not an assignment, but next word may be: "if v=xyz cmd;" */ WORD_IS_KEYWORD = 3, }; /* Used for initialization: o_string foo = NULL_O_STRING; */ diff --git a/util-linux/mkfs_reiser.c b/util-linux/mkfs_reiser.c index 13abaa889..56c8f0ab5 100644 --- a/util-linux/mkfs_reiser.c +++ b/util-linux/mkfs_reiser.c @@ -66,7 +66,7 @@ struct reiserfs_super_block { char s_magic[10]; /* 52 "ReIsErFs" or "ReIsEr2Fs" or "ReIsEr3Fs" */ uint16_t sb_fs_state; /* 62 it is set to used by fsck to mark which phase of rebuilding is done (used for fsck debugging) */ - uint32_t sb_hash_function_code; /* 64 code of fuction which was/is/will be used to sort names in a directory. See codes in above */ + uint32_t sb_hash_function_code; /* 64 code of function which was/is/will be used to sort names in a directory. See codes in above */ uint16_t sb_tree_height; /* 68 height of filesytem tree. Tree consisting of only one root block has 2 here */ uint16_t sb_bmap_nr; /* 70 amount of bitmap blocks needed to address each block of file system */ uint16_t sb_version; /* 72 this field is only reliable on filesystem with non-standard journal */ -- cgit v1.2.3-55-g6feb From 7f4a49a96c4e6626f01a09a801d79c591ad0b1db Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 25 May 2015 14:30:52 +0200 Subject: Print one less newline at the end of bb_show_usage() Signed-off-by: Denys Vlasenko --- libbb/appletlib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libbb/appletlib.c b/libbb/appletlib.c index ba3d6e7a0..46849e4f0 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -130,7 +130,7 @@ void FAST_FUNC bb_show_usage(void) full_write2_str(applet_name); full_write2_str(" "); full_write2_str(p); - full_write2_str("\n\n"); + full_write2_str("\n"); } if (ENABLE_FEATURE_CLEAN_UP) dealloc_usage_messages((char*)usage_string); -- cgit v1.2.3-55-g6feb From fc3e40ee8102c8b17fc98fbc93417bed4d878723 Mon Sep 17 00:00:00 2001 From: Ari Sundholm Date: Mon, 25 May 2015 15:16:11 +0200 Subject: truncate: do not die when a file doesn't exist and no-create flag is on Additionally, open(2) failures do not make the program die immediately. This makes the behavior of the program match coreutils more closely. function old new delta truncate_main 161 221 +60 Signed-off-by: Ari Sundholm Signed-off-by: Denys Vlasenko --- coreutils/truncate.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/coreutils/truncate.c b/coreutils/truncate.c index 0e36daba3..e5fa656c8 100644 --- a/coreutils/truncate.c +++ b/coreutils/truncate.c @@ -64,12 +64,22 @@ int truncate_main(int argc UNUSED_PARAM, char **argv) argv += optind; while (*argv) { - int fd = xopen(*argv, flags); - if (ftruncate(fd, size) == -1) { - bb_perror_msg("%s: ftruncate", *argv); - ret = EXIT_FAILURE; + int fd = open(*argv, flags); + if (fd < 0) { + if (errno != ENOENT || !(opts & OPT_NOCREATE)) { + bb_perror_msg("%s: open", *argv); + ret = EXIT_FAILURE; + } + /* else: ENOENT && OPT_NOCREATE: + * do not report error, exitcode is also 0. + */ + } else { + if (ftruncate(fd, size) == -1) { + bb_perror_msg("%s: truncate", *argv); + ret = EXIT_FAILURE; + } + xclose(fd); } - xclose(fd); ++argv; } -- cgit v1.2.3-55-g6feb From d291c2fdd5cb8616605c67ecbfb04274fa094242 Mon Sep 17 00:00:00 2001 From: Junling Zheng Date: Sun, 7 Jun 2015 02:32:23 +0200 Subject: chown: fix help text Signed-off-by: Junling Zheng Signed-off-by: Denys Vlasenko --- coreutils/chown.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreutils/chown.c b/coreutils/chown.c index cb07bbcbb..679c0d832 100644 --- a/coreutils/chown.c +++ b/coreutils/chown.c @@ -11,7 +11,7 @@ /* http://www.opengroup.org/onlinepubs/007904975/utilities/chown.html */ //usage:#define chown_trivial_usage -//usage: "[-RhLHP"IF_DESKTOP("cvf")"]... OWNER[<.|:>[GROUP]] FILE..." +//usage: "[-Rh"IF_DESKTOP("LHPcvf")"]... OWNER[<.|:>[GROUP]] FILE..." //usage:#define chown_full_usage "\n\n" //usage: "Change the owner and/or group of each FILE to OWNER and/or GROUP\n" //usage: "\n -R Recurse" -- cgit v1.2.3-55-g6feb From 314742747deecd454ae58dfd68be453115ba226c Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Fri, 5 Jun 2015 10:27:28 +0200 Subject: i2cdetect: don't die on addresses already in use by drivers We can't use i2c_set_slave_addr() in i2cdetect, as we have to check for EBUSY after calling ioctl(I2C_SLAVE) and print 'UU' on busy addresses instead of bailing-out. While we're at it: reorder definitions of local vars in i2cdetect_main(). function old new delta i2cdetect_main 703 744 +41 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 41/0) Total: 41 bytes text data bss dec hex filename 826097 4164 9584 839845 cd0a5 busybox_old 826145 4164 9584 839893 cd0d5 busybox_unstripped Signed-off-by: Bartosz Golaszewski Signed-off-by: Denys Vlasenko --- miscutils/i2c_tools.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c index 7034dc9a8..d5127ec27 100644 --- a/miscutils/i2c_tools.c +++ b/miscutils/i2c_tools.c @@ -355,6 +355,13 @@ static void i2c_set_pec(int fd, int pec) itoptr(pec ? 1 : 0), "can't set PEC"); } + +static void i2c_set_slave_addr(int fd, int addr, int force) +{ + ioctl_or_perror_and_die(fd, force ? I2C_SLAVE_FORCE : I2C_SLAVE, + itoptr(addr), + "can't set address to 0x%02x", addr); +} #endif /* ENABLE_I2CGET || ENABLE_I2CSET || ENABLE_I2CDUMP */ #if ENABLE_I2CGET || ENABLE_I2CSET @@ -390,13 +397,6 @@ static int i2c_dev_open(int i2cbus) return fd; } -static void i2c_set_slave_addr(int fd, int addr, int force) -{ - ioctl_or_perror_and_die(fd, force ? I2C_SLAVE_FORCE : I2C_SLAVE, - itoptr(addr), - "can't set address to 0x%02x", addr); -} - /* Size reducing helpers for xxx_check_funcs(). */ static void get_funcs_matrix(int fd, unsigned long *funcs) { @@ -1281,11 +1281,9 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv) opt_F = (1 << 4), opt_l = (1 << 5); const char *const optstr = "yaqrFl"; - int fd, bus_num, i, j, mode = DETECT_MODE_AUTO; - int status; - unsigned first = 0x00, last = 0x77; + int fd, bus_num, i, j, mode = DETECT_MODE_AUTO, status; + unsigned first = 0x00, last = 0x77, opts; unsigned long funcs; - unsigned opts; opt_complementary = "q--r:r--q:" /* mutually exclusive */ "?3"; /* up to 3 args */ @@ -1370,7 +1368,16 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv) continue; } - i2c_set_slave_addr(fd, i + j, 0); + status = ioctl(fd, I2C_SLAVE, itoptr(i + j)); + if (status < 0) { + if (errno == EBUSY) { + printf("UU "); + continue; + } + + bb_perror_msg_and_die( + "can't set address to 0x%02x", i + j); + } switch (mode) { case DETECT_MODE_READ: -- cgit v1.2.3-55-g6feb From e545bf6723ebfd486c6dce6b754b6de792c46de1 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Fri, 5 Jun 2015 10:27:29 +0200 Subject: i2cdetect: don't scan non-regular addresses without the '-a' option Addresses 0x00-0x02 shouldn't be scanned by default. This patch makes 'first' default to 0x03 and only enables lower addresses if '-a' option is passed Signed-off-by: Bartosz Golaszewski Signed-off-by: Denys Vlasenko --- miscutils/i2c_tools.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c index d5127ec27..6f9787280 100644 --- a/miscutils/i2c_tools.c +++ b/miscutils/i2c_tools.c @@ -1282,7 +1282,7 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv) const char *const optstr = "yaqrFl"; int fd, bus_num, i, j, mode = DETECT_MODE_AUTO, status; - unsigned first = 0x00, last = 0x77, opts; + unsigned first = 0x03, last = 0x77, opts; unsigned long funcs; opt_complementary = "q--r:r--q:" /* mutually exclusive */ @@ -1316,8 +1316,10 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv) else if (opts & opt_q) mode = DETECT_MODE_QUICK; - if (opts & opt_a) + if (opts & opt_a) { + first = 0x00; last = 0x7f; + } /* Read address range. */ if (argv[1]) { -- cgit v1.2.3-55-g6feb From 2204472497285dd6fd7b686bb49732fda7394492 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Fri, 5 Jun 2015 10:27:30 +0200 Subject: i2cdetect: add a check for (mode == DETECT_MODE_AUTO) We should only warn the user about addresses to be skipped if (mode == DETECT_MODE_AUTO). Signed-off-by: Bartosz Golaszewski Signed-off-by: Denys Vlasenko --- miscutils/i2c_tools.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c index 6f9787280..16784e948 100644 --- a/miscutils/i2c_tools.c +++ b/miscutils/i2c_tools.c @@ -1336,7 +1336,9 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv) } else if (mode == DETECT_MODE_READ && !(funcs & I2C_FUNC_SMBUS_READ_BYTE)) { no_support("SMBus Receive Byte command"); - } else { + } + + if (mode == DETECT_MODE_AUTO) { if (!(funcs & I2C_FUNC_SMBUS_QUICK)) will_skip("SMBus Quick Write"); if (!(funcs & I2C_FUNC_SMBUS_READ_BYTE)) -- cgit v1.2.3-55-g6feb From aeb11a949667f82173c733e55e9f762c56a1fcba Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Fri, 5 Jun 2015 10:27:31 +0200 Subject: i2cdump: code rework Split i2cdump_main() into shorter functions. Simplify the code a bit. Make block an array of ints so that we can store negative results of read functions (fixes a bug found by Denys Vlasenko). Signed-off-by: Bartosz Golaszewski Signed-off-by: Denys Vlasenko --- miscutils/i2c_tools.c | 316 ++++++++++++++++++++++++++------------------------ 1 file changed, 167 insertions(+), 149 deletions(-) diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c index 16784e948..2f501cd9c 100644 --- a/miscutils/i2c_tools.c +++ b/miscutils/i2c_tools.c @@ -816,6 +816,163 @@ int i2cset_main(int argc, char **argv) #endif /* ENABLE_I2CSET */ #if ENABLE_I2CDUMP +static int read_block_data(int buf_fd, int mode, int *block) +{ + uint8_t cblock[I2C_SMBUS_BLOCK_MAX + I2C_MAX_REGS]; + int res, blen = 0, tmp, i; + + if (mode == I2C_SMBUS_BLOCK_DATA || mode == I2C_SMBUS_I2C_BLOCK_DATA) { + res = i2c_smbus_read_block_data(buf_fd, 0, cblock); + blen = res; + } else { + for (res = 0; res < I2C_MAX_REGS; res += tmp) { + tmp = i2c_smbus_read_i2c_block_data( + buf_fd, res, I2C_SMBUS_BLOCK_MAX, + cblock + res); + if (tmp < 0) { + bb_error_msg_and_die("block read failed"); + } + } + + if (res >= I2C_MAX_REGS) + res = I2C_MAX_REGS; + + for (i = 0; i < res; i++) + block[i] = cblock[i]; + + if (mode != I2C_SMBUS_BLOCK_DATA) + for (i = res; i < I2C_MAX_REGS; i++) + block[i] = -1; + } + + return blen; +} + +/* Dump all but word data. */ +static void dump_data(int bus_fd, int mode, unsigned first, + unsigned last, int *block, int blen) +{ + int i, j, res; + + printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f" + " 0123456789abcdef\n"); + + for (i = 0; i < I2C_MAX_REGS; i += 0x10) { + if (mode == I2C_SMBUS_BLOCK_DATA && i >= blen) + break; + if (i/16 < first/16) + continue; + if (i/16 > last/16) + break; + + printf("%02x: ", i); + for (j = 0; j < 16; j++) { + fflush_all(); + /* Skip unwanted registers */ + if (i+j < first || i+j > last) { + printf(" "); + if (mode == I2C_SMBUS_WORD_DATA) { + printf(" "); + j++; + } + continue; + } + + switch (mode) { + case I2C_SMBUS_BYTE_DATA: + res = i2c_smbus_read_byte_data(bus_fd, i+j); + block[i+j] = res; + break; + case I2C_SMBUS_WORD_DATA: + res = i2c_smbus_read_word_data(bus_fd, i+j); + if (res < 0) { + block[i+j] = res; + block[i+j+1] = res; + } else { + block[i+j] = res & 0xff; + block[i+j+1] = res >> 8; + } + break; + case I2C_SMBUS_BYTE: + res = i2c_smbus_read_byte(bus_fd); + block[i+j] = res; + break; + default: + res = block[i+j]; + } + + if (mode == I2C_SMBUS_BLOCK_DATA && + i+j >= blen) { + printf(" "); + } else if (res < 0) { + printf("XX "); + if (mode == I2C_SMBUS_WORD_DATA) + printf("XX "); + } else { + printf("%02x ", block[i+j]); + if (mode == I2C_SMBUS_WORD_DATA) + printf("%02x ", block[i+j+1]); + } + + if (mode == I2C_SMBUS_WORD_DATA) + j++; + } + printf(" "); + + for (j = 0; j < 16; j++) { + if (mode == I2C_SMBUS_BLOCK_DATA && i+j >= blen) + break; + /* Skip unwanted registers */ + if (i+j < first || i+j > last) { + printf(" "); + continue; + } + + res = block[i+j]; + if (res < 0) { + printf("X"); + } else if (res == 0x00 || res == 0xff) { + printf("."); + } else if (res < 32 || res >= 127) { + printf("?"); + } else { + printf("%c", res); + } + } + printf("\n"); + } +} + +static void dump_word_data(int bus_fd, unsigned first, unsigned last) +{ + int i, j, rv; + + /* Word data. */ + printf(" 0,8 1,9 2,a 3,b 4,c 5,d 6,e 7,f\n"); + for (i = 0; i < 256; i += 8) { + if (i/8 < first/8) + continue; + if (i/8 > last/8) + break; + + printf("%02x: ", i); + for (j = 0; j < 8; j++) { + /* Skip unwanted registers. */ + if (i+j < first || i+j > last) { + printf(" "); + continue; + } + + rv = i2c_smbus_read_word_data(bus_fd, i+j); + if (rv < 0) + printf("XXXX "); + else + printf("%04x ", rv & 0xffff); + } + printf("\n"); + } +} + //usage:#define i2cdump_trivial_usage //usage: "[-f] [-r FIRST-LAST] [-y] BUS ADDR [MODE]" //usage:#define i2cdump_full_usage "\n\n" @@ -842,12 +999,10 @@ int i2cdump_main(int argc UNUSED_PARAM, char **argv) const char *const optstr = "fyr:"; int bus_num, bus_addr, mode = I2C_SMBUS_BYTE_DATA, even = 0, pec = 0; - unsigned first = 0x00, last = 0xff; - int fd, i, j, res, blen = 0, tmp; - unsigned char cblock[I2C_SMBUS_BLOCK_MAX + I2C_MAX_REGS]; - unsigned char block[I2C_SMBUS_BLOCK_MAX]; + unsigned first = 0x00, last = 0xff, opts; + int *block = (int *)bb_common_bufsiz1; char *opt_r_str, *dash; - unsigned opts; + int fd, res, blen; opt_complementary = "-2:?3"; /* from 2 to 3 args */ opts = getopt32(argv, optstr, &opt_r_str); @@ -858,7 +1013,7 @@ int i2cdump_main(int argc UNUSED_PARAM, char **argv) if (argv[2]) { switch (argv[2][0]) { - case 'b': /* Already set */ break; + case 'b': /* Already set. */ break; case 'c': mode = I2C_SMBUS_BYTE; break; case 'w': mode = I2C_SMBUS_WORD_DATA; break; case 'W': @@ -887,7 +1042,7 @@ int i2cdump_main(int argc UNUSED_PARAM, char **argv) bb_error_msg_and_die("invalid range"); last = xstrtou_range(++dash, 0, first, 0xff); - /* Range is not available for every mode */ + /* Range is not available for every mode. */ switch (mode) { case I2C_SMBUS_BYTE: case I2C_SMBUS_BYTE_DATA: @@ -912,156 +1067,19 @@ int i2cdump_main(int argc UNUSED_PARAM, char **argv) if (!(opts & opt_y)) confirm_action(bus_addr, mode, -1 /* data_addr */, pec); - /* All but word data */ + /* All but word data. */ if (mode != I2C_SMBUS_WORD_DATA || even) { - /* - * FIXME This section has been ported from upstream i2cdump. - * It has been reworked a bit but is still pretty spaghetti - * and needs splitting into several functions. - */ - if (mode == I2C_SMBUS_BLOCK_DATA || - mode == I2C_SMBUS_I2C_BLOCK_DATA) { - res = i2c_smbus_read_block_data(fd, 0, cblock); - blen = res; - } else { - for (res = 0; res < I2C_MAX_REGS; res += tmp) { - tmp = i2c_smbus_read_i2c_block_data( - fd, res, I2C_SMBUS_BLOCK_MAX, - cblock + res); - if (tmp < 0) { - bb_error_msg_and_die( - "block read failed"); - } - } - if (res >= I2C_MAX_REGS) - res = I2C_MAX_REGS; - for (i = 0; i < res; i++) - block[i] = cblock[i]; - if (mode != I2C_SMBUS_BLOCK_DATA) - for (i = res; i < I2C_MAX_REGS; i++) - cblock[i] = -1; - } + blen = read_block_data(fd, mode, block); if (mode == I2C_SMBUS_BYTE) { res = i2c_smbus_write_byte(fd, first); if (res < 0) - bb_perror_msg_and_die( - "write start address failed"); + bb_perror_msg_and_die("write start address"); } - printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f" - " 0123456789abcdef\n"); - - for (i = 0; i < I2C_MAX_REGS; i += 0x10) { - if (mode == I2C_SMBUS_BLOCK_DATA && i >= blen) - break; - if (i/16 < first/16) - continue; - if (i/16 > last/16) - break; - - printf("%02x: ", i); - for (j = 0; j < 16; j++) { - fflush_all(); - /* Skip unwanted registers */ - if (i+j < first || i+j > last) { - printf(" "); - if (mode == I2C_SMBUS_WORD_DATA) { - printf(" "); - j++; - } - continue; - } - - switch (mode) { - case I2C_SMBUS_BYTE_DATA: - res = i2c_smbus_read_byte_data(fd, i+j); - block[i+j] = res; - break; - case I2C_SMBUS_WORD_DATA: - res = i2c_smbus_read_word_data(fd, i+j); - if (res < 0) { - block[i+j] = res; - block[i+j+1] = res; - } else { - block[i+j] = res & 0xff; - block[i+j+1] = res >> 8; - } - break; - case I2C_SMBUS_BYTE: - res = i2c_smbus_read_byte(fd); - block[i+j] = res; - break; - default: - res = block[i+j]; - } - - if (mode == I2C_SMBUS_BLOCK_DATA && - i+j >= blen) { - printf(" "); - } else if (res < 0) { - printf("XX "); - if (mode == I2C_SMBUS_WORD_DATA) - printf("XX "); - } else { - printf("%02x ", block[i+j]); - if (mode == I2C_SMBUS_WORD_DATA) - printf("%02x ", block[i+j+1]); - } - - if (mode == I2C_SMBUS_WORD_DATA) - j++; - } - printf(" "); - - for (j = 0; j < 16; j++) { - if (mode == I2C_SMBUS_BLOCK_DATA && i+j >= blen) - break; - /* Skip unwanted registers */ - if (i+j < first || i+j > last) { - printf(" "); - continue; - } - - res = block[i+j]; - if (res < 0) { -//FIXME: impossible, block[] is uchar[] - printf("X"); - } else if (res == 0x00 || res == 0xff) { - printf("."); - } else if (res < 32 || res >= 127) { - printf("?"); - } else { - printf("%c", res); - } - } - printf("\n"); - } + dump_data(fd, mode, first, last, block, blen); } else { - /* Word data. */ - printf(" 0,8 1,9 2,a 3,b 4,c 5,d 6,e 7,f\n"); - for (i = 0; i < 256; i += 8) { - if (i/8 < first/8) - continue; - if (i/8 > last/8) - break; - - printf("%02x: ", i); - for (j = 0; j < 8; j++) { - /* Skip unwanted registers. */ - if (i+j < first || i+j > last) { - printf(" "); - continue; - } - - res = i2c_smbus_read_word_data(fd, i+j); - if (res < 0) - printf("XXXX "); - else - printf("%04x ", res & 0xffff); - } - printf("\n"); - } + dump_word_data(fd, first, last); } return 0; -- cgit v1.2.3-55-g6feb From d90899206dd96b4c18064c18afc3b856382e64d4 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Fri, 5 Jun 2015 10:27:32 +0200 Subject: i2cdetect: use break instead of goto in list_i2c_busses_and_exit() Since there are now more statements in the if block after the while loop in list_i2c_busses_and_exit(), there's no need for a label. Signed-off-by: Bartosz Golaszewski Signed-off-by: Denys Vlasenko --- miscutils/i2c_tools.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c index 2f501cd9c..38d90ff10 100644 --- a/miscutils/i2c_tools.c +++ b/miscutils/i2c_tools.c @@ -1226,12 +1226,11 @@ static void NORETURN list_i2c_busses_and_exit(void) i2cdev_path, de->d_name, subde->d_name); fp = fopen(path, "r"); - goto found; + break; } } } -found: if (fp != NULL) { /* * Get the rest of the info and display a line -- cgit v1.2.3-55-g6feb From 0fabedf085591b50994e4f8c133bfa87f1777ee4 Mon Sep 17 00:00:00 2001 From: Maninder Singh Date: Mon, 1 Jun 2015 10:38:07 +0000 Subject: fix if(p)/free(p) construct No need of explicit NULL check before free. Signed-off-by: Maninder Singh Signed-off-by: Akhilesh Kumar Signed-off-by: Denys Vlasenko --- e2fsprogs/old_e2fsprogs/blkid/dev.c | 3 +-- e2fsprogs/old_e2fsprogs/fsck.c | 12 ++++-------- scripts/kconfig/confdata.c | 3 +-- scripts/kconfig/util.c | 3 +-- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/e2fsprogs/old_e2fsprogs/blkid/dev.c b/e2fsprogs/old_e2fsprogs/blkid/dev.c index 84b7b0a72..c2bbb06f3 100644 --- a/e2fsprogs/old_e2fsprogs/blkid/dev.c +++ b/e2fsprogs/old_e2fsprogs/blkid/dev.c @@ -44,8 +44,7 @@ void blkid_free_dev(blkid_dev dev) bit_tags); blkid_free_tag(tag); } - if (dev->bid_name) - free(dev->bid_name); + free(dev->bid_name); free(dev); } diff --git a/e2fsprogs/old_e2fsprogs/fsck.c b/e2fsprogs/old_e2fsprogs/fsck.c index 91cce970c..87874ce71 100644 --- a/e2fsprogs/old_e2fsprogs/fsck.c +++ b/e2fsprogs/old_e2fsprogs/fsck.c @@ -354,12 +354,9 @@ static void parse_escape(char *word) static void free_instance(struct fsck_instance *i) { - if (i->prog) - free(i->prog); - if (i->device) - free(i->device); - if (i->base_device) - free(i->base_device); + free(i->prog); + free(i->device); + free(i->base_device); free(i); } @@ -432,8 +429,7 @@ static int parse_fstab_line(char *line, struct fs_info **ret_fs) fs = create_fs_device(device, mntpnt, type ? type : "auto", opts, freq ? atoi(freq) : -1, passno ? atoi(passno) : -1); - if (dev) - free(dev); + free(dev); if (!fs) return -1; diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 303df0be7..8f4ecbd33 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -124,8 +124,7 @@ int conf_read_simple(const char *name) case S_INT: case S_HEX: case S_STRING: - if (sym->user.val) - free(sym->user.val); + free(sym->user.val); default: sym->user.val = NULL; sym->user.tri = no; diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index 263091945..13369e6a1 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -79,8 +79,7 @@ struct gstr str_assign(const char *s) /* Free storage for growable string */ void str_free(struct gstr *gs) { - if (gs->s) - free(gs->s); + free(gs->s); gs->s = NULL; gs->len = 0; } -- cgit v1.2.3-55-g6feb From 7db312ad265608264c1d42106ceadf158ff7f77e Mon Sep 17 00:00:00 2001 From: Maninder Singh Date: Mon, 1 Jun 2015 10:40:09 +0000 Subject: fix whitespaces reported by script :- scripts/fix_ws.sh Signed-off-by: Maninder Singh Signed-off-by: Denys Vlasenko --- coreutils/shuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreutils/shuf.c b/coreutils/shuf.c index 6d0a68fc1..9f61f2f7d 100644 --- a/coreutils/shuf.c +++ b/coreutils/shuf.c @@ -94,7 +94,7 @@ int shuf_main(int argc, char **argv) *dash = '\0'; lo = xatou(opt_i_str); hi = xatou(dash + 1); - *dash = '-'; + *dash = '-'; if (hi < lo) { bb_error_msg_and_die("bad range '%s'", opt_i_str); } -- cgit v1.2.3-55-g6feb From 6a7cd3d4aba493c0b0d00155b1e09a867db437cf Mon Sep 17 00:00:00 2001 From: Michael Tokarev Date: Wed, 20 May 2015 16:27:44 +0300 Subject: ip addr: support change and replace commands Signed-off-by: Michael Tokarev Signed-off-by: Denys Vlasenko --- networking/ip.c | 2 +- networking/libiproute/ipaddress.c | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/networking/ip.c b/networking/ip.c index 98fe621b1..d35345c36 100644 --- a/networking/ip.c +++ b/networking/ip.c @@ -33,7 +33,7 @@ //usage: "{ {add|del} IFADDR dev STRING | {show|flush}\n" //usage: " [dev STRING] [to PREFIX] }" //usage:#define ipaddr_full_usage "\n\n" -//usage: "ipaddr {add|delete} IFADDR dev STRING\n" +//usage: "ipaddr {add|change|replace|delete} IFADDR dev STRING\n" //usage: "ipaddr {show|flush} [dev STRING] [scope SCOPE-ID]\n" //usage: " [to PREFIX] [label PATTERN]\n" //usage: " IFADDR := PREFIX | ADDR peer PREFIX\n" diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c index 4072d0626..85f33560f 100644 --- a/networking/libiproute/ipaddress.c +++ b/networking/libiproute/ipaddress.c @@ -598,7 +598,7 @@ static int default_scope(inet_prefix *lcl) } /* Return value becomes exitcode. It's okay to not return at all */ -static int ipaddr_modify(int cmd, char **argv) +static int ipaddr_modify(int cmd, int flags, char **argv) { static const char option[] ALIGN1 = "peer\0""remote\0""broadcast\0""brd\0" @@ -622,7 +622,7 @@ static int ipaddr_modify(int cmd, char **argv) memset(&req, 0, sizeof(req)); req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg)); - req.n.nlmsg_flags = NLM_F_REQUEST; + req.n.nlmsg_flags = NLM_F_REQUEST | flags; req.n.nlmsg_type = cmd; req.ifa.ifa_family = preferred_family; @@ -749,16 +749,20 @@ static int ipaddr_modify(int cmd, char **argv) int FAST_FUNC do_ipaddr(char **argv) { static const char commands[] ALIGN1 = - "add\0""delete\0""list\0""show\0""lst\0""flush\0"; + /* 0 1 2 3 4 5 6 7 8 */ + "add\0""change\0""chg\0""replace\0""delete\0""list\0""show\0""lst\0""flush\0"; int cmd = 2; if (*argv) { cmd = index_in_substrings(commands, *argv); if (cmd < 0) invarg(*argv, applet_name); argv++; - if (cmd <= 1) - return ipaddr_modify((cmd == 0) ? RTM_NEWADDR : RTM_DELADDR, argv); - } - /* 2 == list, 3 == show, 4 == lst */ - return ipaddr_list_or_flush(argv, cmd == 5); + if (cmd <= 4) + return ipaddr_modify(cmd == 4 ? RTM_DELADDR : RTM_NEWADDR, + cmd == 0 ? NLM_F_CREATE|NLM_F_EXCL : + cmd == 1 || cmd == 2 ? NLM_F_REPLACE : + cmd == 3 ? NLM_F_CREATE|NLM_F_REPLACE : + 0, argv); + } + return ipaddr_list_or_flush(argv, cmd == 8); } -- cgit v1.2.3-55-g6feb From db31c637fa72cfdc546dd85e10d231a0fdce2b1e Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 1 Jul 2015 18:36:06 +0200 Subject: ipaddress: better formatting, no code changes Signed-off-by: Denys Vlasenko --- networking/libiproute/ipaddress.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c index 85f33560f..a6d5129e7 100644 --- a/networking/libiproute/ipaddress.c +++ b/networking/libiproute/ipaddress.c @@ -757,12 +757,16 @@ int FAST_FUNC do_ipaddr(char **argv) if (cmd < 0) invarg(*argv, applet_name); argv++; - if (cmd <= 4) - return ipaddr_modify(cmd == 4 ? RTM_DELADDR : RTM_NEWADDR, - cmd == 0 ? NLM_F_CREATE|NLM_F_EXCL : - cmd == 1 || cmd == 2 ? NLM_F_REPLACE : - cmd == 3 ? NLM_F_CREATE|NLM_F_REPLACE : - 0, argv); + if (cmd <= 4) { + return ipaddr_modify( + /*cmd:*/ cmd == 4 ? RTM_DELADDR : RTM_NEWADDR, + /*flags:*/ + cmd == 0 ? NLM_F_CREATE|NLM_F_EXCL : /* add */ + cmd == 1 || cmd == 2 ? NLM_F_REPLACE : /* change */ + cmd == 3 ? NLM_F_CREATE|NLM_F_REPLACE : /* replace */ + 0 /* delete */ + , argv); + } } return ipaddr_list_or_flush(argv, cmd == 8); } -- cgit v1.2.3-55-g6feb From c9091d8947b6f0e28485eadab11d737e4c910430 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 1 Jul 2015 19:07:24 +0200 Subject: ps: fix SEGV on narrow screens. closes 8176 Signed-off-by: Denys Vlasenko --- procps/ps.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/procps/ps.c b/procps/ps.c index c65fa012a..bde5f9485 100644 --- a/procps/ps.c +++ b/procps/ps.c @@ -654,8 +654,8 @@ int ps_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) OPT_l = (1 << ENABLE_SELINUX) * (1 << ENABLE_FEATURE_SHOW_THREADS) * ENABLE_FEATURE_PS_LONG, }; #if ENABLE_FEATURE_PS_LONG - time_t now = now; - unsigned long uptime; + time_t now = now; /* for compiler */ + unsigned long uptime = uptime; #endif /* If we support any options, parse argv */ #if ENABLE_SELINUX || ENABLE_FEATURE_SHOW_THREADS || ENABLE_FEATURE_PS_WIDE || ENABLE_FEATURE_PS_LONG @@ -786,9 +786,11 @@ int ps_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) { int sz = terminal_width - len; - char buf[sz + 1]; - read_cmdline(buf, sz, p->pid, p->comm); - puts(buf); + if (sz >= 0) { + char buf[sz + 1]; + read_cmdline(buf, sz, p->pid, p->comm); + puts(buf); + } } } if (ENABLE_FEATURE_CLEAN_UP) -- cgit v1.2.3-55-g6feb From b7ee7e1e13fa4a680e8b228bd158e7aa53fe342a Mon Sep 17 00:00:00 2001 From: Clayton Shotwell Date: Thu, 21 May 2015 14:48:35 -0500 Subject: applets: Add installation of individual binaries Adding support to install individual binaries if the option is enabled. This also installs the shared libbusybox.so.* library. Signed-off-by: Clayton Shotwell Signed-off-by: Denys Vlasenko --- Makefile.custom | 4 ++++ applets/install.sh | 26 ++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Makefile.custom b/Makefile.custom index f8a12831d..891c9ced7 100644 --- a/Makefile.custom +++ b/Makefile.custom @@ -28,6 +28,10 @@ ifeq ($(CONFIG_INSTALL_SH_APPLET_SCRIPT_WRAPPER),y) INSTALL_OPTS:= --scriptwrapper endif endif +ifeq ($(CONFIG_FEATURE_INDIVIDUAL),y) +INSTALL_OPTS:= --binaries +LIBBUSYBOX_SONAME:= 0_lib/libbusybox.so.$(BB_VER) +endif install: $(srctree)/applets/install.sh busybox busybox.links $(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \ $(SHELL) $< $(CONFIG_PREFIX) $(INSTALL_OPTS) diff --git a/applets/install.sh b/applets/install.sh index 95b4719d4..f6c097e57 100755 --- a/applets/install.sh +++ b/applets/install.sh @@ -5,19 +5,26 @@ export LC_CTYPE=POSIX prefix=$1 if [ -z "$prefix" ]; then - echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks/--scriptwrapper]" + echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks/--binaries/--scriptwrapper]" exit 1 fi +# Source the configuration +. ./.config + h=`sort busybox.links | uniq` +sharedlib_dir="0_lib" + linkopts="" scriptwrapper="n" +binaries="n" cleanup="0" noclobber="0" case "$2" in --hardlinks) linkopts="-f";; --symlinks) linkopts="-fs";; + --binaries) binaries="y";; --scriptwrapper) scriptwrapper="y";swrapall="y";; --sw-sh-hard) scriptwrapper="y";linkopts="-f";; --sw-sh-sym) scriptwrapper="y";linkopts="-fs";; @@ -40,8 +47,9 @@ if [ -n "$DO_INSTALL_LIBS" ] && [ "$DO_INSTALL_LIBS" != "n" ]; then for i in $DO_INSTALL_LIBS; do rm -f "$prefix/$libdir/$i" || exit 1 if [ -f "$i" ]; then + echo " Installing $i to the target at $prefix/$libdir/" cp -pPR "$i" "$prefix/$libdir/" || exit 1 - chmod 0644 "$prefix/$libdir/$i" || exit 1 + chmod 0644 "$prefix/$libdir/`basename $i`" || exit 1 fi done fi @@ -68,6 +76,7 @@ install -m 755 busybox "$prefix/bin/busybox" || exit 1 for i in $h; do appdir=`dirname "$i"` + app=`basename "$i"` mkdir -p "$prefix/$appdir" || exit 1 if [ "$scriptwrapper" = "y" ]; then if [ "$swrapall" != "y" ] && [ "$i" = "/bin/sh" ]; then @@ -78,6 +87,19 @@ for i in $h; do chmod +x "$prefix/$i" fi echo " $prefix/$i" + elif [ "$binaries" = "y" ]; then + # Copy the binary over rather + if [ -e $sharedlib_dir/$app ]; then + if [ "$noclobber" = "0" ] || [ ! -e "$prefix/$i" ]; then + echo " Copying $sharedlib_dir/$app to $prefix/$i" + cp -pPR $sharedlib_dir/$app $prefix/$i || exit 1 + else + echo " $prefix/$i already exists" + fi + else + echo "Error: Could not find $sharedlib_dir/$app" + exit 1 + fi else if [ "$2" = "--hardlinks" ]; then bb_path="$prefix/bin/busybox" -- cgit v1.2.3-55-g6feb From 97f2f7ca7fe10783a592087df989a7f394492fa1 Mon Sep 17 00:00:00 2001 From: Maninder Singh Date: Wed, 10 Jun 2015 03:47:27 +0000 Subject: Removes stray empty line from code This patch removes stray empty line from busybox code reported by script find_stray_empty_lines Signed-off-by: Maninder Singh Signed-off-by: Akhilesh Kumar Signed-off-by: Denys Vlasenko --- archival/cpio.c | 1 - archival/gzip.c | 3 --- archival/libarchive/bz/compress.c | 1 - archival/libarchive/decompress_uncompress.c | 1 - archival/libarchive/lzo1x_9x.c | 1 - archival/libarchive/unxz/xz_dec_lzma2.c | 3 --- archival/libarchive/unxz/xz_dec_stream.c | 2 -- archival/unzip.c | 2 -- console-tools/showkey.c | 1 - coreutils/ln.c | 1 - editors/awk.c | 12 ------------ editors/ed.c | 1 - editors/vi.c | 1 - libbb/appletlib.c | 1 - libbb/in_ether.c | 1 - libbb/procps.c | 1 - libbb/xfuncs.c | 1 - mailutils/reformime.c | 1 - miscutils/crontab.c | 1 - networking/arp.c | 1 - networking/ntpd.c | 1 - networking/tftp.c | 1 - networking/wget.c | 1 - selinux/setfiles.c | 1 - shell/ash.c | 2 -- shell/hush.c | 1 - shell/shell_common.c | 1 - sysklogd/syslogd.c | 1 - 28 files changed, 46 deletions(-) diff --git a/archival/cpio.c b/archival/cpio.c index 454648d68..cdc16c14e 100644 --- a/archival/cpio.c +++ b/archival/cpio.c @@ -257,7 +257,6 @@ static NOINLINE int cpio_o(void) free(line); continue; } - } else { /* line == NULL: EOF */ next_link: if (links) { diff --git a/archival/gzip.c b/archival/gzip.c index 42b2f0b2e..c9171304a 100644 --- a/archival/gzip.c +++ b/archival/gzip.c @@ -1372,7 +1372,6 @@ static void build_tree(tree_desc * desc) /* and insert the new node in the heap */ G2.heap[SMALLEST] = node++; pqdownheap(tree, SMALLEST); - } while (G2.heap_len >= 2); G2.heap[--G2.heap_max] = G2.heap[SMALLEST]; @@ -1720,7 +1719,6 @@ static ulg flush_block(char *buf, ulg stored_len, int eof) copy_block(buf, (unsigned) stored_len, 0); /* without header */ G2.compressed_len = stored_len << 3; - } else if (stored_len + 4 <= opt_lenb && buf != NULL) { /* 4: two words for the lengths */ /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. @@ -1734,7 +1732,6 @@ static ulg flush_block(char *buf, ulg stored_len, int eof) G2.compressed_len += (stored_len + 4) << 3; copy_block(buf, (unsigned) stored_len, 1); /* with header */ - } else if (static_lenb == opt_lenb) { send_bits((STATIC_TREES << 1) + eof, 3); compress_block((ct_data *) G2.static_ltree, (ct_data *) G2.static_dtree); diff --git a/archival/libarchive/bz/compress.c b/archival/libarchive/bz/compress.c index 23de9d3f5..2d994685c 100644 --- a/archival/libarchive/bz/compress.c +++ b/archival/libarchive/bz/compress.c @@ -385,7 +385,6 @@ void sendMTFValues(EState* s) cost[0] = cost01 & 0xffff; cost[1] = cost01 >> 16; cost[2] = cost23 & 0xffff; cost[3] = cost23 >> 16; cost[4] = cost45 & 0xffff; cost[5] = cost45 >> 16; - } else #endif { diff --git a/archival/libarchive/decompress_uncompress.c b/archival/libarchive/decompress_uncompress.c index 496d864a7..034ed502d 100644 --- a/archival/libarchive/decompress_uncompress.c +++ b/archival/libarchive/decompress_uncompress.c @@ -297,7 +297,6 @@ unpack_Z_stream(transformer_state_t *xstate) /* Remember previous code. */ oldcode = incode; } - } while (rsize > 0); if (outpos > 0) { diff --git a/archival/libarchive/lzo1x_9x.c b/archival/libarchive/lzo1x_9x.c index 2b490ae83..09ee4ba5c 100644 --- a/archival/libarchive/lzo1x_9x.c +++ b/archival/libarchive/lzo1x_9x.c @@ -71,7 +71,6 @@ typedef struct { uint8_t *out; unsigned r1_lit; - } lzo1x_999_t; #define getbyte(c) ((c).ip < (c).in_end ? *((c).ip)++ : (-1)) diff --git a/archival/libarchive/unxz/xz_dec_lzma2.c b/archival/libarchive/unxz/xz_dec_lzma2.c index 3c2dc88b7..351251f7c 100644 --- a/archival/libarchive/unxz/xz_dec_lzma2.c +++ b/archival/libarchive/unxz/xz_dec_lzma2.c @@ -995,10 +995,8 @@ XZ_EXTERN NOINLINE enum xz_ret XZ_FUNC xz_dec_lzma2_run( s->lzma2.need_props = false; s->lzma2.next_sequence = SEQ_PROPERTIES; - } else if (s->lzma2.need_props) { return XZ_DATA_ERROR; - } else { s->lzma2.next_sequence = SEQ_LZMA_PREPARE; @@ -1080,7 +1078,6 @@ XZ_EXTERN NOINLINE enum xz_ret XZ_FUNC xz_dec_lzma2_run( rc_reset(&s->rc); s->lzma2.sequence = SEQ_CONTROL; - } else if (b->out_pos == b->out_size || (b->in_pos == b->in_size && s->temp.size diff --git a/archival/libarchive/unxz/xz_dec_stream.c b/archival/libarchive/unxz/xz_dec_stream.c index bdcbf1ba3..bf791055b 100644 --- a/archival/libarchive/unxz/xz_dec_stream.c +++ b/archival/libarchive/unxz/xz_dec_stream.c @@ -353,7 +353,6 @@ static enum xz_ret XZ_FUNC crc32_validate(struct xz_dec *s, struct xz_buf *b) return XZ_DATA_ERROR; s->pos += 8; - } while (s->pos < 32); s->crc32 = 0; @@ -753,7 +752,6 @@ XZ_EXTERN enum xz_ret XZ_FUNC xz_dec_run(struct xz_dec *s, struct xz_buf *b) b->in_pos = in_start; b->out_pos = out_start; } - } else if (ret == XZ_OK && in_start == b->in_pos && out_start == b->out_pos) { if (s->allow_buf_error) diff --git a/archival/unzip.c b/archival/unzip.c index eed225677..f41ab6f44 100644 --- a/archival/unzip.c +++ b/archival/unzip.c @@ -604,7 +604,6 @@ int unzip_main(int argc, char **argv) || (zaccept && !find_list_entry(zaccept, dst_fn)) ) { /* Skip entry */ i = 'n'; - } else { if (listing) { /* List entry */ @@ -666,7 +665,6 @@ int unzip_main(int argc, char **argv) } } i = 'n'; - } else { /* Extract file */ check_file: diff --git a/console-tools/showkey.c b/console-tools/showkey.c index 69b785ec6..b7b4c32a8 100644 --- a/console-tools/showkey.c +++ b/console-tools/showkey.c @@ -83,7 +83,6 @@ int showkey_main(int argc UNUSED_PARAM, char **argv) if (04 /*CTRL-D*/ == c) break; } - } else { // we assume a PC keyboard xioctl(STDIN_FILENO, KDGKBMODE, &kbmode); diff --git a/coreutils/ln.c b/coreutils/ln.c index 3b822e8c7..168814801 100644 --- a/coreutils/ln.c +++ b/coreutils/ln.c @@ -134,7 +134,6 @@ int ln_main(int argc, char **argv) } free(src_name); - } while ((++argv)[1]); return status; diff --git a/editors/awk.c b/editors/awk.c index f487163af..9c6819ad2 100644 --- a/editors/awk.c +++ b/editors/awk.c @@ -1060,12 +1060,10 @@ static uint32_t next_token(uint32_t expected) if (t_rollback) { t_rollback = FALSE; - } else if (concat_inserted) { concat_inserted = FALSE; t_tclass = save_tclass; t_info = save_info; - } else { p = g_pos; readnext: @@ -1081,7 +1079,6 @@ static uint32_t next_token(uint32_t expected) if (*p == '\0') { tc = TC_EOF; debug_printf_parse("%s: token found: TC_EOF\n", __func__); - } else if (*p == '\"') { /* it's a string */ t_string = s = ++p; @@ -1097,7 +1094,6 @@ static uint32_t next_token(uint32_t expected) *s = '\0'; tc = TC_STRING; debug_printf_parse("%s: token found:'%s' TC_STRING\n", __func__, t_string); - } else if ((expected & TC_REGEXP) && *p == '/') { /* it's regexp */ t_string = s = ++p; @@ -1130,7 +1126,6 @@ static uint32_t next_token(uint32_t expected) syntax_error(EMSG_UNEXP_TOKEN); tc = TC_NUMBER; debug_printf_parse("%s: token found:%f TC_NUMBER\n", __func__, t_double); - } else { /* search for something known */ tl = tokenlist; @@ -1580,12 +1575,10 @@ static void parse_program(char *p) debug_printf_parse("%s: TC_BEGIN\n", __func__); seq = &beginseq; chain_group(); - } else if (tclass & TC_END) { debug_printf_parse("%s: TC_END\n", __func__); seq = &endseq; chain_group(); - } else if (tclass & TC_FUNCDECL) { debug_printf_parse("%s: TC_FUNCDECL\n", __func__); next_token(TC_FUNCTION); @@ -1603,7 +1596,6 @@ static void parse_program(char *p) seq = &f->body; chain_group(); clear_array(ahash); - } else if (tclass & TC_OPSEQ) { debug_printf_parse("%s: TC_OPSEQ\n", __func__); rollback_token(); @@ -1618,7 +1610,6 @@ static void parse_program(char *p) chain_node(OC_PRINT); } cn->r.n = mainseq.last; - } else /* if (tclass & TC_GRPSTART) */ { debug_printf_parse("%s: TC_GRPSTART(?)\n", __func__); rollback_token(); @@ -1879,13 +1870,10 @@ static void handle_special(var *v) split_f0(); mk_splitter(getvar_s(v), &fsplitter); - } else if (v == intvar[RS]) { mk_splitter(getvar_s(v), &rsplitter); - } else if (v == intvar[IGNORECASE]) { icase = istrue(v); - } else { /* $n */ n = getvar_i(intvar[NF]); setvar_i(intvar[NF], n > v-Fields ? n : v-Fields+1); diff --git a/editors/ed.c b/editors/ed.c index 3087fb0b9..f0e5e4d5d 100644 --- a/editors/ed.c +++ b/editors/ed.c @@ -732,7 +732,6 @@ static int readLines(const char *file, int num) cc = safe_read(fd, bufPtr, bufSize - bufUsed); bufUsed += cc; bufPtr = bufBase; - } while (cc > 0); if (cc < 0) { diff --git a/editors/vi.c b/editors/vi.c index 6ce513c0c..3db597ae1 100644 --- a/editors/vi.c +++ b/editors/vi.c @@ -411,7 +411,6 @@ struct globals { char undo_text[1]; // text that was deleted (if deletion) } *undo_stack_tail; #endif /* ENABLE_FEATURE_VI_UNDO */ - }; #define G (*ptr_to_globals) #define text (G.text ) diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 46849e4f0..24253cf27 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -457,7 +457,6 @@ static void parse_config_file(void) errmsg = "keyword outside section"; goto pe_label; } - } /* while (1) */ pe_label: diff --git a/libbb/in_ether.c b/libbb/in_ether.c index 1de383bde..161c8ea3c 100644 --- a/libbb/in_ether.c +++ b/libbb/in_ether.c @@ -51,7 +51,6 @@ int FAST_FUNC in_ether(const char *bufp, struct sockaddr *sap) } while (j); *ptr++ = val; - } while (--i); /* Error if we aren't at end of string */ diff --git a/libbb/procps.c b/libbb/procps.c index 948b91ee6..3d335b37b 100644 --- a/libbb/procps.c +++ b/libbb/procps.c @@ -614,7 +614,6 @@ void FAST_FUNC read_cmdline(char *buf, int col, unsigned pid, const char *comm) buf[comm_len - 1] = ' '; buf[col - 1] = '\0'; } - } else { snprintf(buf, col, "[%s]", comm); } diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index f25ce9446..0c9969640 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c @@ -207,7 +207,6 @@ off_t FAST_FUNC fdlength(int fd) else bottom = pos; // If we can't, it's smaller. - } else { if (bottom == top) { if (!top) return 0; diff --git a/mailutils/reformime.c b/mailutils/reformime.c index 8e7d455f6..86b2cfed3 100644 --- a/mailutils/reformime.c +++ b/mailutils/reformime.c @@ -134,7 +134,6 @@ static int parse(const char *boundary, char **argv) if (strcasecmp(type + 10, "mixed") != 0) bb_error_msg_and_die("no support of content type '%s'", type); parse(xfind_token(tokens, "boundary"), argv); - } else { /* No, process one non-multipart section */ char *end; diff --git a/miscutils/crontab.c b/miscutils/crontab.c index aad242fd8..85c6623b2 100644 --- a/miscutils/crontab.c +++ b/miscutils/crontab.c @@ -170,7 +170,6 @@ int crontab_main(int argc UNUSED_PARAM, char **argv) unlink(tmp_fname); /*free(tmp_fname);*/ /*free(new_fname);*/ - } /* switch */ /* Bump notification file. Handle window where crond picks file up diff --git a/networking/arp.c b/networking/arp.c index e79b1b6a1..0099aa534 100644 --- a/networking/arp.c +++ b/networking/arp.c @@ -68,7 +68,6 @@ struct globals { const struct hwtype *hw; /* current hardware type */ const char *device; /* current device */ smallint hw_set; /* flag if hw-type was set (-H) */ - } FIX_ALIASING; #define G (*(struct globals*)&bb_common_bufsiz1) #define ap (G.ap ) diff --git a/networking/ntpd.c b/networking/ntpd.c index 0233ed82c..b5120a70d 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c @@ -1497,7 +1497,6 @@ update_local_clock(peer_t *p) #endif abs_offset = offset = 0; set_new_values(STATE_SYNC, offset, recv_time); - } else { /* abs_offset <= STEP_THRESHOLD */ /* The ratio is calculated before jitter is updated to make diff --git a/networking/tftp.c b/networking/tftp.c index 7c0ee58d7..8ecd7bb6f 100644 --- a/networking/tftp.c +++ b/networking/tftp.c @@ -348,7 +348,6 @@ static int tftp_protocol( * as if it is "block 0" */ block_nr = 0; } - } else { /* tftp */ /* Open file (must be after changing user) */ local_fd = CMD_GET(option_mask32) ? STDOUT_FILENO : STDIN_FILENO; diff --git a/networking/wget.c b/networking/wget.c index 6c8bd90a8..f744ea2de 100644 --- a/networking/wget.c +++ b/networking/wget.c @@ -1050,7 +1050,6 @@ However, in real world it was observed that some web servers /* For HTTP, data is pumped over the same connection */ dfp = sfp; - } else { /* * FTP session diff --git a/selinux/setfiles.c b/selinux/setfiles.c index 0173db99e..c974c4a9d 100644 --- a/selinux/setfiles.c +++ b/selinux/setfiles.c @@ -251,7 +251,6 @@ static int match(const char *name, struct stat *sb, char **con) name = path; if (excludeCtr > 0 && exclude(name)) goto err; - } else { char *p; p = realpath(name, path); diff --git a/shell/ash.c b/shell/ash.c index 282f761fc..4c01e67d4 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -9447,7 +9447,6 @@ evalcommand(union node *cmd, int flags) if (evalfun(cmdentry.u.func, argc, argv, flags)) goto raise; break; - } /* switch */ out: @@ -11763,7 +11762,6 @@ parsearith: { goto parsearith_return; } #endif - } /* end of readtoken */ /* diff --git a/shell/hush.c b/shell/hush.c index 96c739fb7..3ca04494c 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -5390,7 +5390,6 @@ static NOINLINE int expand_vars_to_list(o_string *output, int n, char *arg) !!(output->o_expflags & EXP_FLAG_ESC_GLOB_CHARS)); } break; - } /* switch (char after ) */ if (val && val[0]) { diff --git a/shell/shell_common.c b/shell/shell_common.c index 57297155e..2b6f7dc92 100644 --- a/shell/shell_common.c +++ b/shell/shell_common.c @@ -493,7 +493,6 @@ shell_builtin_ulimit(char **argv) /* bad option. getopt already complained. */ break; } - } /* while (there are options) */ return 0; diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index 266657f3b..156f487e5 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c @@ -237,7 +237,6 @@ enum { OPT_dup = IF_FEATURE_SYSLOGD_DUP( (1 << OPTBIT_dup )) + 0, OPT_cfg = IF_FEATURE_SYSLOGD_CFG( (1 << OPTBIT_cfg )) + 0, OPT_kmsg = IF_FEATURE_KMSG_SYSLOG( (1 << OPTBIT_kmsg )) + 0, - }; #define OPTION_STR "m:nO:l:S" \ IF_FEATURE_ROTATE_LOGFILE("s:" ) \ -- cgit v1.2.3-55-g6feb From 0e056f7e9efcebbbb85444221e141b37d3ab79e6 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Wed, 1 Jul 2015 16:45:40 +0100 Subject: ash: remove parsebackquote flag Commit 503a0b8 from git://git.kernel.org/pub/scm/utils/dash/dash.git by Herbert Xu says: >The parsebackquote flag is only used in a test where it always has the >value zero. So we can remove it altogether. The first statement is incorrect: parsebackquote is non-zero when backquotes (as opposed to $(...)) are used for command substitution. It is possible for the test to be executed with parsebackquote != 0 in that case. The test is question checks whether quotes have been closed, raising the error "unterminated quoted string" if they haven't. There seems to be no good reason to allow unclosed quotes within backquotes. Bash, hush and dash (after commit 503a0b8) all treat the following as an error: XX=`"pwd` whereas BusyBox ash doesn't. It just ignores the unclosed quote and executes pwd. So, parsebackquote should be removed but not for the reason stated. function old new delta parsebackquote 1 - -1 readtoken1 3222 3182 -40 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-41) Total: -41 bytes Signed-off-by: Ron Yorston Signed-off-by: Denys Vlasenko --- shell/ash.c | 8 +------- shell/ash_test/ash-misc/tickquote1.right | 1 + shell/ash_test/ash-misc/tickquote1.tests | 1 + 3 files changed, 3 insertions(+), 7 deletions(-) create mode 100644 shell/ash_test/ash-misc/tickquote1.right create mode 100755 shell/ash_test/ash-misc/tickquote1.tests diff --git a/shell/ash.c b/shell/ash.c index 4c01e67d4..6627cec9b 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -10473,7 +10473,6 @@ struct heredoc { }; static smallint tokpushback; /* last token pushed back */ -static smallint parsebackquote; /* nonzero if we are inside backquotes */ static smallint quoteflag; /* set if (part of) last token was quoted */ static token_id_t lasttoken; /* last token read (integer id Txxx) */ static struct heredoc *heredoclist; /* list of here documents to read */ @@ -11313,7 +11312,7 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs) if (syntax == ARISYNTAX) raise_error_syntax("missing '))'"); #endif - if (syntax != BASESYNTAX && !parsebackquote && eofmark == NULL) + if (syntax != BASESYNTAX && eofmark == NULL) raise_error_syntax("unterminated quoted string"); if (varnest != 0) { startlinno = g_parsefile->linno; @@ -11609,7 +11608,6 @@ parsesub: { */ parsebackq: { struct nodelist **nlpp; - smallint savepbq; union node *n; char *volatile str; struct jmploc jmploc; @@ -11620,10 +11618,8 @@ parsebackq: { #ifdef __GNUC__ (void) &saveprompt; #endif - savepbq = parsebackquote; if (setjmp(jmploc.loc)) { free(str); - parsebackquote = 0; exception_handler = savehandler; longjmp(exception_handler->loc, 1); } @@ -11707,7 +11703,6 @@ parsebackq: { nlpp = &(*nlpp)->next; *nlpp = stzalloc(sizeof(**nlpp)); /* (*nlpp)->next = NULL; - stzalloc did it */ - parsebackquote = oldstyle; if (oldstyle) { saveprompt = doprompt; @@ -11741,7 +11736,6 @@ parsebackq: { str = NULL; INT_ON; } - parsebackquote = savepbq; exception_handler = savehandler; USTPUTC(CTLBACKQ, out); if (oldstyle) diff --git a/shell/ash_test/ash-misc/tickquote1.right b/shell/ash_test/ash-misc/tickquote1.right new file mode 100644 index 000000000..2e661bfe3 --- /dev/null +++ b/shell/ash_test/ash-misc/tickquote1.right @@ -0,0 +1 @@ +./tickquote1.tests: line 1: syntax error: unterminated quoted string diff --git a/shell/ash_test/ash-misc/tickquote1.tests b/shell/ash_test/ash-misc/tickquote1.tests new file mode 100755 index 000000000..90d5bbc9b --- /dev/null +++ b/shell/ash_test/ash-misc/tickquote1.tests @@ -0,0 +1 @@ +echo `"pwd` -- cgit v1.2.3-55-g6feb From f54a487bb4d36a4318c5ec539f8265fdff2cac90 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 13 Jul 2015 03:52:32 +0200 Subject: fix file mode Signed-off-by: Denys Vlasenko --- shell/ash_test/ash-misc/echo_write_error.tests | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 shell/ash_test/ash-misc/echo_write_error.tests diff --git a/shell/ash_test/ash-misc/echo_write_error.tests b/shell/ash_test/ash-misc/echo_write_error.tests old mode 100644 new mode 100755 -- cgit v1.2.3-55-g6feb From 072fc60f29ee3a4ff38f095a9ef149b2e820c8c0 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Wed, 1 Jul 2015 16:46:18 +0100 Subject: ash: use alloca to get rid of setjmp Now that the only thing protected by setjmp/longjmp is the saved string, we can allocate it on the stack to get rid of the jump. Based on commit bd35d8e from git://git.kernel.org/pub/scm/utils/dash/dash.git by Herbert Xu. function old new delta readtoken1 3182 3116 -66 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-66) Total: -66 bytes Signed-off-by: Ron Yorston Signed-off-by: Denys Vlasenko --- shell/ash.c | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/shell/ash.c b/shell/ash.c index 6627cec9b..f4779ee2b 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -11132,19 +11132,6 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs) IF_ASH_BASH_COMPAT(smallint bash_dollar_squote = 0;) -#if __GNUC__ - /* Avoid longjmp clobbering */ - (void) &out; - (void) "ef; - (void) &dblquote; - (void) &varnest; - (void) &arinest; - (void) &parenlevel; - (void) &dqvarnest; - (void) &oldstyle; - (void) &prevsyntax; - (void) &syntax; -#endif startlinno = g_parsefile->linno; bqlist = NULL; quotef = 0; @@ -11609,30 +11596,16 @@ parsesub: { parsebackq: { struct nodelist **nlpp; union node *n; - char *volatile str; - struct jmploc jmploc; - struct jmploc *volatile savehandler; + char *str; size_t savelen; smallint saveprompt = 0; -#ifdef __GNUC__ - (void) &saveprompt; -#endif - if (setjmp(jmploc.loc)) { - free(str); - exception_handler = savehandler; - longjmp(exception_handler->loc, 1); - } - INT_OFF; str = NULL; savelen = out - (char *)stackblock(); if (savelen > 0) { - str = ckmalloc(savelen); + str = alloca(savelen); memcpy(str, stackblock(), savelen); } - savehandler = exception_handler; - exception_handler = &jmploc; - INT_ON; if (oldstyle) { /* We must read until the closing backquote, giving special * treatment to some slashes, and then push the string and @@ -11731,12 +11704,7 @@ parsebackq: { if (str) { memcpy(out, str, savelen); STADJUST(savelen, out); - INT_OFF; - free(str); - str = NULL; - INT_ON; } - exception_handler = savehandler; USTPUTC(CTLBACKQ, out); if (oldstyle) goto parsebackq_oldreturn; -- cgit v1.2.3-55-g6feb