fix "if (p) free(p)" constructs
authorDenis Vlasenko <vda.linux@googlemail.com>
Fri, 28 Sep 2007 22:07:23 +0000 (22:07 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Fri, 28 Sep 2007 22:07:23 +0000 (22:07 -0000)
editors/sed.c
shell/ash.c
shell/lash.c

index a2e2b7349457d060bde230e8a4fa07f09ecacc76..dcdf382dc5906095417f53928d265ebc6e1100fc 100644 (file)
@@ -157,7 +157,7 @@ static void sed_free_and_close_stuff(void)
                sed_cmd = sed_cmd_next;
        }
 
-       if (G.hold_space) free(G.hold_space);
+       free(G.hold_space);
 
        while (G.current_input_file < G.input_file_count)
                fclose(G.input_file_list[G.current_input_file++]);
index a3bfe3977c1356d425b9813e5b45b3b373f46f12..183911cccfc4eee552605c302753a266bebbb84c 100644 (file)
@@ -5328,8 +5328,7 @@ expbackq(union node *cmd, int quoted, int quotes)
                p = buf;
        }
 
-       if (in.buf)
-               free(in.buf);
+       free(in.buf);
        if (in.fd >= 0) {
                close(in.fd);
                back_exitstatus = waitforjob(in.jp);
@@ -8788,8 +8787,7 @@ popfile(void)
        INT_OFF;
        if (pf->fd >= 0)
                close(pf->fd);
-       if (pf->buf)
-               free(pf->buf);
+       free(pf->buf);
        while (pf->strpush)
                popstring();
        parsefile = pf->prev;
@@ -10330,8 +10328,7 @@ parsebackq: {
 #endif
        savepbq = parsebackquote;
        if (setjmp(jmploc.loc)) {
-               if (str)
-                       free(str);
+               free(str);
                parsebackquote = 0;
                exception_handler = savehandler;
                longjmp(exception_handler->loc, 1);
@@ -11264,8 +11261,7 @@ trapcmd(int argc, char **argv)
                        else
                                action = ckstrdup(action);
                }
-               if (trap[signo])
-                       free(trap[signo]);
+               free(trap[signo]);
                trap[signo] = action;
                if (signo != 0)
                        setsignal(signo);
index 4ce6d42353962ccff7de275cac78403d05d9de76..5ba490f2a9b1163b02faa784a14c1deca705cac2 100644 (file)
@@ -455,8 +455,7 @@ static void free_job(struct job *cmd)
        for (i = 0; i < cmd->num_progs; i++) {
                free(cmd->progs[i].argv);
 #if ENABLE_LASH_PIPE_N_REDIRECTS
-               if (cmd->progs[i].redirects)
-                       free(cmd->progs[i].redirects);
+               free(cmd->progs[i].redirects);
 #endif
        }
        free(cmd->progs);