remove some GNUisms. by Dan Fandrich (dan AT coneharvesters.com)
authorDenys Vlasenko <vda.linux@googlemail.com>
Sun, 6 Sep 2009 00:36:23 +0000 (02:36 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sun, 6 Sep 2009 00:36:23 +0000 (02:36 +0200)
function                                             old     new   delta
logdirs_reopen                                      1310    1308      -2
read_line_input                                     4757    4753      -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-6)               Total: -6 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
15 files changed:
archival/gzip.c
editors/awk.c
editors/sed.c
include/libbb.h
init/init.c
libbb/lineedit.c
libbb/loop.c
mailutils/mime.c
miscutils/less.c
modutils/modprobe-small.c
runit/svlogd.c
selinux/setfiles.c
shell/bbsh.c
shell/hush.c
util-linux/fbset.c

index 3358469081e2c08c08be85f9d9d46126f17c752f..1e56c9dec453dd51c7af76a646e7b5d240d448ff 100644 (file)
@@ -2078,7 +2078,7 @@ int gzip_main(int argc UNUSED_PARAM, char **argv)
        //if (opt & 0x4) // -v
        argv += optind;
 
-       SET_PTR_TO_GLOBALS(xzalloc(sizeof(struct globals) + sizeof(struct globals2))
+       SET_PTR_TO_GLOBALS((char *)xzalloc(sizeof(struct globals)+sizeof(struct globals2))
                        + sizeof(struct globals));
        barrier();
 
index cef73342c2d71a03f3590309a2e5a2d5c0c2cec7..30f09cbaf79698ac13901f89cce2d54e9a0d5607 100644 (file)
@@ -486,7 +486,7 @@ struct globals2 {
 #define fsplitter    (G.fsplitter   )
 #define rsplitter    (G.rsplitter   )
 #define INIT_G() do { \
-       SET_PTR_TO_GLOBALS(xzalloc(sizeof(G1) + sizeof(G)) + sizeof(G1)); \
+       SET_PTR_TO_GLOBALS((char*)xzalloc(sizeof(G1)+sizeof(G)) + sizeof(G1)); \
        G.next_token__ltclass = TC_OPTERM; \
        G.evaluate__seed = 1; \
 } while (0)
index 8b4f60a8cd76a261e4906afbb26e3c10389c409a..b74941944e7e904d36c6c527d6213e3dbe91be72 100644 (file)
@@ -1186,7 +1186,7 @@ static void process_files(void)
                case 'x': /* Exchange hold and pattern space */
                {
                        char *tmp = pattern_space;
-                       pattern_space = G.hold_space ? : xzalloc(1);
+                       pattern_space = G.hold_space ? G.hold_space : xzalloc(1);
                        last_gets_char = '\n';
                        G.hold_space = tmp;
                        break;
index c795e6aadbe5dc57d9d2db9450af7b6ce7a86f35..9f7c2603157d83ed948d1843719b99c59a6e975c 100644 (file)
@@ -1479,7 +1479,7 @@ extern struct globals *const ptr_to_globals;
 /* At least gcc 3.4.6 on mipsel system needs optimization barrier */
 #define barrier() __asm__ __volatile__("":::"memory")
 #define SET_PTR_TO_GLOBALS(x) do { \
-       (*(struct globals**)&ptr_to_globals) = (x); \
+       (*(struct globals**)&ptr_to_globals) = (void*)(x); \
        barrier(); \
 } while (0)
 
index 35f64cf8a198a825018074e080fc4557c75d857d..6bee8f35ca5bf49c3c3879ddaa2b48a917ef3703 100644 (file)
@@ -862,7 +862,7 @@ int init_main(int argc UNUSED_PARAM, char **argv)
                struct sysinfo info;
 
                if (sysinfo(&info) == 0
-                && (info.mem_unit ? : 1) * (long long)info.totalram < 1024*1024
+                && (info.mem_unit ? info.mem_unit : 1) * (long long)info.totalram < 1024*1024
                ) {
                        message(L_CONSOLE, "Low memory, forcing swapon");
                        /* swapon -a requires /proc typically */
index 9a773b4b8ceaae5420d59f1e4b5bed0e51316a2f..38c69c60209fc71efc756af444feeb2cbe53fb8f 100644 (file)
@@ -2037,7 +2037,8 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li
  rewrite_line:
                        /* Rewrite the line with the selected history item */
                        /* change command */
-                       command_len = load_string(state->history[state->cur_history] ? : "", maxsize);
+                       command_len = load_string(state->history[state->cur_history] ?
+                                       state->history[state->cur_history] : "", maxsize);
                        /* redraw and go to eol (bol, in vi) */
                        redraw(cmdedit_y, (state->flags & VI_MODE) ? 9999 : 0);
                        break;
index 24dab1ac0533b79a95bdddd69850bdbcc8289bfc..3fec7ad6d876f641d691a4a44ee57cffe33e72ad 100644 (file)
@@ -105,7 +105,7 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse
        }
 
        /* Find a loop device.  */
-       try = *device ? : dev;
+       try = *device ? *device : dev;
        for (i = 0; rc; i++) {
                sprintf(dev, LOOP_FORMAT, i);
 
index b856c8149df20c8d566f3be6c49c5fca93605d89..dd81139f2434667283c202aa6bf219c0461b6b29 100644 (file)
@@ -177,7 +177,8 @@ int makemime_main(int argc UNUSED_PARAM, char **argv)
 static const char *find_token(const char *const string_array[], const char *key, const char *defvalue)
 {
        const char *r = NULL;
-       for (int i = 0; string_array[i] != 0; i++) {
+       int i;
+       for (i = 0; string_array[i] != NULL; i++) {
                if (strcasecmp(string_array[i], key) == 0) {
                        r = (char *)string_array[i+1];
                        break;
index bd855066fbd2b6ee5b7d73cfd7c7782a02787950..ce77ddd3a1e1ceecc3d22fef5d2fc4aef58bed6b 100644 (file)
@@ -624,7 +624,7 @@ static void print_found(const char *line)
 
        while (match_status == 0) {
                char *new = xasprintf("%s%.*s"HIGHLIGHT"%.*s"NORMAL,
-                               growline ? : "",
+                               growline ? growline : "",
                                match_structs.rm_so, str,
                                match_structs.rm_eo - match_structs.rm_so,
                                                str + match_structs.rm_so);
index 0d78033c39b5fcef7f9f31fe111e61dd82664561..bbd700eb723316497c38b2f47a7ababed5a25c27 100644 (file)
@@ -314,6 +314,7 @@ static int load_dep_bb(void)
 
        while ((line = xmalloc_fgetline(fp)) != NULL) {
                char* space;
+               char* linebuf;
                int cur;
 
                if (!line[0]) {
@@ -328,7 +329,8 @@ static int load_dep_bb(void)
                if (*space)
                        *space++ = '\0';
                modinfo[cur].aliases = space;
-               modinfo[cur].deps = xmalloc_fgetline(fp) ? : xzalloc(1);
+               linebuf = xmalloc_fgetline(fp);
+               modinfo[cur].deps = linebuf ? linebuf : xzalloc(1);
                if (modinfo[cur].deps[0]) {
                        /* deps are not "", so next line must be empty */
                        line = xmalloc_fgetline(fp);
index 25c169aeb4fbaccfdfb556cdfec8350316a74541..66a13fbd04b94f374a5005ce95ecc72ac15d6804 100644 (file)
@@ -670,7 +670,7 @@ static unsigned logdir_open(struct logdir *ld, const char *fn)
                                memRchr = memchr;
                                /* Add '\n'-terminated line to ld->inst */
                                while (1) {
-                                       int l = asprintf(&new, "%s%s\n", ld->inst ? : "", s);
+                                       int l = asprintf(&new, "%s%s\n", ld->inst ? ld->inst : "", s);
                                        if (l >= 0 && new)
                                                break;
                                        pause_nomem();
index b410d7eded31b8c40d6c2a6fd4aa3d3b0e09c0a0..aabc371372a3d1a53cffbb75e1bc74c4adf503bd 100644 (file)
@@ -347,7 +347,7 @@ static int restore(const char *file)
                 * same.  For "-vv", emit everything. */
                if (verbose > 1 || !user_only_changed) {
                        bb_info_msg("%s: reset %s context %s->%s",
-                               applet_name, my_file, context ?: "", newcon);
+                               applet_name, my_file, context ? context : "", newcon);
                }
        }
 
index 897c0227cce785504a9dc6076eabab41d3356fad..ad875abf51c932a72447979d7f64f6ce525924c6 100644 (file)
@@ -212,7 +212,7 @@ int bbsh_main(int argc, char **argv)
                unsigned cmdlen=0;
                for (;;) {
                        if (!f) putchar('$');
-                       if (1 > getline(&command, &cmdlen,f ? : stdin)) break;
+                       if (1 > getline(&command, &cmdlen, f ? f : stdin)) break;
 
                        handle(command);
                }
index 5794b1ddfe761eae04116c6ed17637d5de5dfcfb..30eddadcce7ca27b48ebd6f50644dd629ea879f1 100644 (file)
@@ -5794,7 +5794,7 @@ static struct pipe *parse_stream(char **pstring,
         * found.  When recursing, quote state is passed in via dest->o_escape.
         */
        debug_printf_parse("parse_stream entered, end_trigger='%c'\n",
-                       end_trigger ? : 'X');
+                       end_trigger ? end_trigger : 'X');
        debug_enter();
 
        G.ifs = get_local_var_value("IFS");
@@ -6860,7 +6860,8 @@ static int FAST_FUNC builtin_cd(char **argv)
                 * bash says "bash: cd: HOME not set" and does nothing
                 * (exitcode 1)
                 */
-               newdir = get_local_var_value("HOME") ? : "/";
+               const char *home = get_local_var_value("HOME");
+               newdir = home ? home : "/";
        }
        if (chdir(newdir)) {
                /* Mimic bash message exactly */
index affeab0610840f3e9d74f45f32cf98b61bbabd72..358d0a8fc4d10f5390441d841538609e5fa953d1 100644 (file)
@@ -254,7 +254,7 @@ static int read_mode_db(struct fb_var_screeninfo *base, const char *fn,
 }
 #endif
 
-static void setmode(struct fb_var_screeninfo *base,
+static void setfbmode(struct fb_var_screeninfo *base,
                                        struct fb_var_screeninfo *set)
 {
        if ((int32_t) set->xres > 0)
@@ -402,7 +402,7 @@ int fbset_main(int argc, char **argv)
        }
 
        if (options & OPT_CHANGE) {
-               setmode(&var, &varset);
+               setfbmode(&var, &varset);
                if (options & OPT_ALL)
                        var.activate = FB_ACTIVATE_ALL;
                xioctl(fh, FBIOPUT_VSCREENINFO, &var);