Change if(x)free(x); to free(x);
authorAaron Lehmann <aaronl@vitelius.com>
Thu, 28 Nov 2002 11:27:31 +0000 (11:27 -0000)
committerAaron Lehmann <aaronl@vitelius.com>
Thu, 28 Nov 2002 11:27:31 +0000 (11:27 -0000)
16 files changed:
archival/dpkg.c
archival/gzip.c
coreutils/ls.c
editors/awk.c
editors/sed.c
editors/vi.c
findutils/grep.c
libpwdgrp/__getgrent.c
modutils/insmod.c
networking/udhcp/dhcpc.c
networking/udhcp/files.c
shell/hush.c
shell/lash.c
util-linux/fsck_minix.c
util-linux/getopt.c
util-linux/umount.c

index 8b25bace34ca02db720115e7bf6ae5dfaa348508..23509fcb5c8873c9fd5302c4a5ff8edea9dc8b19 100644 (file)
@@ -491,13 +491,9 @@ void free_package(common_node_t *node)
        unsigned short i;
        if (node) {
                for (i = 0; i < node->num_of_edges; i++) {
-                       if (node->edge[i]) {
-                               free(node->edge[i]);
-                       }
-               }
-               if (node->edge) {
-                       free(node->edge);
+                       free(node->edge[i]);
                }
+               free(node->edge);
                free(node);
        }
 }
@@ -571,12 +567,8 @@ unsigned int fill_package_struct(char *control_buffer)
                                break;
                }
 fill_package_struct_cleanup:
-               if (field_name) {
-                       free(field_name);
-               }
-               if (field_value) {
-                       free(field_value);
-               }
+               free(field_name);
+               free(field_value);
        }
 
        if (new_node->version == search_name_hashtable("unknown")) {
@@ -880,9 +872,7 @@ void write_status_file(deb_file_t **deb_file)
                        fprintf(new_status_file, "%s\n\n", control_buffer);
                }
 
-               if (status_from_file != NULL) {
-                       free(status_from_file);
-               }
+               free(status_from_file);
                free(package_name);
                free(control_buffer);
        }
@@ -1661,9 +1651,7 @@ int dpkg_main(int argc, char **argv)
        free(deb_file);
 
        for (i = 0; i < NAME_HASH_PRIME; i++) {
-               if (name_hashtable[i] != NULL) {
-                       free(name_hashtable[i]);
-               }
+               free(name_hashtable[i]);
        }
 
        for (i = 0; i < PACKAGE_HASH_PRIME; i++) {
@@ -1673,9 +1661,7 @@ int dpkg_main(int argc, char **argv)
        }
 
        for (i = 0; i < STATUS_HASH_PRIME; i++) {
-               if (status_hashtable[i] != NULL) {
-                       free(status_hashtable[i]);
-               }
+               free(status_hashtable[i]);
        }
 
        return(EXIT_SUCCESS);
index da931579f978f8d53f575c7251b9b7f4a6f19c52..971724d74c3e1b2eec96686a69016902cbbdedd8 100644 (file)
@@ -111,7 +111,7 @@ typedef unsigned long ulg;
 #  define ALLOC(type, array, size) { \
       array = (type*)xcalloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
    }
-#  define FREE(array) {if (array != NULL) free(array), array=NULL;}
+#  define FREE(array) {free(array), array=NULL;}
 #else
 #  define DECLARE(type, array, size)  static type array[size]
 #  define ALLOC(type, array, size)
index d2a935d82b184247b560db4f846cbdb6023ae3ce..853a18059451bd9712492ef3d76db89cd1c8e958 100644 (file)
@@ -360,8 +360,7 @@ static void dfree(struct dnode **dnp)
 
        cur = dnp[0];
        while (cur != NULL) {
-               if (cur->fullname != NULL)
-                       free(cur->fullname);    /* free the filename */
+               free(cur->fullname);    /* free the filename */
                next = cur->next;
                free(cur);              /* free the dnode */
                cur = next;
index aea852b0d1498d7f8055deb7bad9b1e6938e96f7..44c2f45b2733bb21700a468d600f1281b5fde817 100644 (file)
@@ -650,7 +650,7 @@ static void clear_array(xhash *array) {
                while (hi) {
                        thi = hi;
                        hi = hi->next;
-                       if (thi->data.v.string) free(thi->data.v.string);
+                       free(thi->data.v.string);
                        free(thi);
                }
                array->items[i] = NULL;
@@ -661,7 +661,7 @@ static void clear_array(xhash *array) {
 /* clear a variable */
 static var *clrvar(var *v) {
 
-       if (v->string && !(v->type & VF_FSTR))
+       if (!(v->type & VF_FSTR))
                free(v->string);
 
        v->type &= VF_DONTTOUCH;
@@ -1504,7 +1504,7 @@ static void split_f0(void) {
                return;
 
        is_f0_split = TRUE;
-       if (fstrings) free(fstrings);
+       free(fstrings);
        fsrealloc(0);
        n = awk_split(getvar_s(V[F0]), &fsplitter.n, &fstrings);
        fsrealloc(n);
@@ -2376,8 +2376,7 @@ re_cont:
                                X.rsm = (rstream *)hash_search(fdhash, L.s);
                                if (X.rsm) {
                                        R.i = X.rsm->is_pipe ? pclose(X.rsm->F) : fclose(X.rsm->F);
-                                       if (X.rsm->buffer)
-                                               free(X.rsm->buffer);
+                                       free(X.rsm->buffer);
                                        hash_remove(fdhash, L.s);
                                }
                                if (R.i != 0)
index 23e9d545bd47dfe48b16e96a384c1b79658036b1..df623465f0a16b4dbb7d694e592a4a2e32c10761 100644 (file)
@@ -130,8 +130,7 @@ static void destroy_cmd_strs(void)
                        regfree(sed_cmds[ncmds].sub_match);
                        free(sed_cmds[ncmds].sub_match);
                }
-               if (sed_cmds[ncmds].replace)
-                       free(sed_cmds[ncmds].replace);
+               free(sed_cmds[ncmds].replace);
        }
 
        /* destroy the array */
index 1275d133b0a74df6abfa7ed92c62060629e2678a..835adb62ee16b40fd8c9b3b17299559cb3ef6c6c 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 static const char vi_Version[] =
-       "$Id: vi.c,v 1.24 2002/10/26 10:19:19 andersen Exp $";
+       "$Id: vi.c,v 1.25 2002/11/28 11:27:23 aaronl Exp $";
 
 /*
  * To compile for standalone use:
@@ -383,8 +383,7 @@ extern int vi_main(int argc, char **argv)
        } else {
                for (; optind < argc; optind++) {
                        editing = 1;    // 0=exit, 1=one file, 2+ =many files
-                       if (cfn != 0)
-                               free(cfn);
+                       free(cfn);
                        cfn = (Byte *) xstrdup(argv[optind]);
                        edit_file(cfn);
                }
@@ -490,10 +489,8 @@ static void edit_file(Byte * fn)
        offset = 0;                     // no horizontal offset
        c = '\0';
 #ifdef CONFIG_FEATURE_VI_DOT_CMD
-       if (last_modifying_cmd != 0)
-               free(last_modifying_cmd);
-       if (ioq_start != NULL)
-               free(ioq_start);
+       free(last_modifying_cmd);
+       free(ioq_start);
        ioq = ioq_start = last_modifying_cmd = 0;
        adding2q = 0;
 #endif                                                 /* CONFIG_FEATURE_VI_DOT_CMD */
@@ -998,8 +995,7 @@ static void colon(Byte * buf)
                // There is a read-able regular file
                // make this the current file
                q = (Byte *) xstrdup((char *) fn);      // save the cfn
-               if (cfn != 0)
-                       free(cfn);              // free the old name
+               free(cfn);              // free the old name
                cfn = q;                        // remember new cfn
 
          vc5:
@@ -1048,8 +1044,7 @@ static void colon(Byte * buf)
                }
                if (strlen((char *) args) > 0) {
                        // user wants a new filename
-                       if (cfn != NULL)
-                               free(cfn);
+                       free(cfn);
                        cfn = (Byte *) xstrdup((char *) args);
                } else {
                        // user wants file status info
@@ -1635,8 +1630,7 @@ static Byte *new_screen(int ro, int co)
 {
        int li;
 
-       if (screen != 0)
-               free(screen);
+       free(screen);
        screensize = ro * co + 8;
        screen = (Byte *) xmalloc(screensize);
        // initialize the new screen. assume this will be a empty file.
@@ -1652,10 +1646,7 @@ static Byte *new_text(int size)
 {
        if (size < 10240)
                size = 10240;   // have a minimum size for new files
-       if (text != 0) {
-               //text -= 4;
-               free(text);
-       }
+       free(text);
        text = (Byte *) xmalloc(size + 8);
        memset(text, '\0', size);       // clear new text[]
        //text += 4;            // leave some room for "oops"
@@ -2171,8 +2162,7 @@ extern inline void print_literal(Byte * buf, Byte * s) // copy s to buf, convert
 static void start_new_cmd_q(Byte c)
 {
        // release old cmd
-       if (last_modifying_cmd != 0)
-               free(last_modifying_cmd);
+       free(last_modifying_cmd);
        // get buffer for new cmd
        last_modifying_cmd = (Byte *) xmalloc(BUFSIZ);
        memset(last_modifying_cmd, '\0', BUFSIZ);       // clear new cmd queue
@@ -2227,9 +2217,7 @@ static Byte *text_yank(Byte * p, Byte * q, int dest)      // copy text into a registe
        }
        cnt = q - p + 1;
        t = reg[dest];
-       if (t != 0) {           // if already a yank register
-               free(t);                //   free it
-       }
+       free(t);                //  if already a yank register, free it
        t = (Byte *) xmalloc(cnt + 1);  // get a new register
        memset(t, '\0', cnt + 1);       // clear new text[]
        strncpy((char *) t, (char *) p, cnt);   // copy text[] into bufer
@@ -2615,8 +2603,7 @@ static Byte *get_input_line(Byte * prompt) // get input line- use "status line"
                }
        }
        refresh(FALSE);
-       if (obufp != NULL)
-               free(obufp);
+       free(obufp);
        obufp = (Byte *) xstrdup((char *) buf);
        return (obufp);
 }
@@ -3454,9 +3441,7 @@ key_cmd_mode:
                        goto dc3;       // if no pat re-use old pat
                if (strlen((char *) q) > 1) {   // new pat- save it and find
                        // there is a new pat
-                       if (last_search_pattern != 0) {
-                               free(last_search_pattern);
-                       }
+                       free(last_search_pattern);
                        last_search_pattern = (Byte *) xstrdup((char *) q);
                        goto dc3;       // now find the pattern
                }
index 6fe183325fbf5b88be548ed913a799e62013f285..cc2b697e8c63009b26e736481b167620b0ca8da0 100644 (file)
@@ -153,8 +153,7 @@ static void grep_file(FILE *file)
                        else { /* no match */
                                /* Add the line to the circular 'before' buffer */
                                if(lines_before) {
-                                       if(before_buf[curpos])
-                                               free(before_buf[curpos]);
+                                       free(before_buf[curpos]);
                                        before_buf[curpos] = xstrdup(line);
                                        curpos = (curpos + 1) % lines_before;
                                }
@@ -225,8 +224,7 @@ static void destroy_regexes(void)
        while (--nregexes >= 0) {
                regfree(&(regexes[nregexes]));
        }
-       if (regexes)
-           free(regexes);
+       free(regexes);
 }
 #endif
 
index 39cf1890a42533ed56033ddf2326f676204e871e..5fb4193cb5716363f382fef3ec88a0a8cdfed88a 100644 (file)
@@ -186,8 +186,7 @@ struct group *__getgrent(int grp_fd)
                members[member_num + 1] = NULL;
        }
 #else                                                  /* !GR_SCALE_DYNAMIC */
-       if (members != NULL)
-           free(members);
+       free(members);
        members = (char **) malloc((member_num + 1) * sizeof(char *));   
        for ( ; field_begin && *field_begin != '\0'; field_begin = ptr) {
            if ((ptr = strchr(field_begin, ',')) != NULL)
index b367e84af1a8901dfe5e10a2ba9e0df24efcc0ac..eda4e1a48437963d3bc79b62849404b317ac8010 100644 (file)
 #ifndef MODUTILS_MODULE_H
 static const int MODUTILS_MODULE_H = 1;
 
-#ident "$Id: insmod.c,v 1.91 2002/10/10 04:20:21 andersen Exp $"
+#ident "$Id: insmod.c,v 1.92 2002/11/28 11:27:27 aaronl Exp $"
 
 /* This file contains the structures used by the 2.0 and 2.1 kernels.
    We do not use the kernel headers directly because we do not wish
@@ -455,7 +455,7 @@ int delete_module(const char *);
 #ifndef MODUTILS_OBJ_H
 static const int MODUTILS_OBJ_H = 1;
 
-#ident "$Id: insmod.c,v 1.91 2002/10/10 04:20:21 andersen Exp $"
+#ident "$Id: insmod.c,v 1.92 2002/11/28 11:27:27 aaronl Exp $"
 
 /* The relocatable object is manipulated using elfin types.  */
 
@@ -3589,8 +3589,7 @@ extern int insmod_main( int argc, char **argv)
                                flag_export = 0;
                                break;
                        case 'o':                       /* name the output module */
-                               if(m_name)  /* Hmmm, duplicate "-o name". */
-                                       free(m_name);
+                               free(m_name);
                                m_name = xstrdup(optarg);
                                break;
                        case 'L':                       /* Stub warning */
index 295486c98fee27c51c6abb6d53a667d80c3d6f36..b50b1ed030ce9469f3827655bb99ebd90a5a0a99 100644 (file)
@@ -246,7 +246,7 @@ int main(int argc, char *argv[])
                switch (c) {
                case 'c':
                        len = strlen(optarg) > 255 ? 255 : strlen(optarg);
-                       if (client_config.clientid) free(client_config.clientid);
+                       free(client_config.clientid);
                        client_config.clientid = xmalloc(len + 2);
                        client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID;
                        client_config.clientid[OPT_LEN] = len;
@@ -262,7 +262,7 @@ int main(int argc, char *argv[])
                case 'h':
                case 'H':
                        len = strlen(optarg) > 255 ? 255 : strlen(optarg);
-                       if (client_config.hostname) free(client_config.hostname);
+                       free(client_config.hostname);
                        client_config.hostname = xmalloc(len + 2);
                        client_config.hostname[OPT_CODE] = DHCP_HOST_NAME;
                        client_config.hostname[OPT_LEN] = len;
index 842e0f2dbc8152e38373a4ab6f94c6141714f5f9..cf72de1a8cbde9078e7aee3abcb1ac7910e67d3a 100644 (file)
@@ -38,7 +38,7 @@ static int read_str(char *line, void *arg)
 {
        char **dest = arg;
        
-       if (*dest) free(*dest);
+       free(*dest);
        *dest = strdup(line);
        
        return 1;
index 08b3b295f671d60be22070ab185a8ccd524b37ed..48d1d1458affddadfb0bebd4140540eb7b165e4a 100644 (file)
@@ -810,7 +810,7 @@ static void b_reset(o_string *o)
 static void b_free(o_string *o)
 {
        b_reset(o);
-       if (o->data != NULL) free(o->data);
+       free(o->data);
        o->data = NULL;
        o->maxlen = 0;
 }
@@ -880,8 +880,7 @@ static inline void setup_prompt_string(int promptmode, char **prompt_str)
 #ifndef CONFIG_FEATURE_SH_FANCY_PROMPT
        /* Set up the prompt */
        if (promptmode == 1) {
-               if (PS1)
-                       free(PS1);
+               free(PS1);
                PS1=xmalloc(strlen(cwd)+4);
                sprintf(PS1, "%s %s", cwd, ( geteuid() != 0 ) ?  "$ ":"# ");
                *prompt_str = PS1;
index 7994d2620d81f21815b3ec551930f5b1776ce532..c4d6ef04e93684eee24e98100f84e26b5037e481 100644 (file)
@@ -518,12 +518,9 @@ static void free_job(struct job *cmd)
                if (cmd->progs[i].redirects)
                        free(cmd->progs[i].redirects);
        }
-       if (cmd->progs)
-               free(cmd->progs);
-       if (cmd->text)
-               free(cmd->text);
-       if (cmd->cmdbuf)
-               free(cmd->cmdbuf);
+       free(cmd->progs);
+       free(cmd->text);
+       free(cmd->cmdbuf);
        keep = cmd->job_list;
        memset(cmd, 0, sizeof(struct job));
        cmd->job_list = keep;
@@ -677,8 +674,7 @@ static inline void setup_prompt_string(char **prompt_str)
 #ifndef CONFIG_FEATURE_SH_FANCY_PROMPT
        /* Set up the prompt */
        if (shell_context == 0) {
-               if (PS1)
-                       free(PS1);
+               free(PS1);
                PS1=xmalloc(strlen(cwd)+4);
                sprintf(PS1, "%s %s", cwd, ( geteuid() != 0 ) ?  "$ ":"# ");
                *prompt_str = PS1;
index dbe4f74b3c7fa0dc0e1a2d63cb9d3eaa135ec1d1..d332b6b0aff0ca760bac484c3f4996d6352efd1f 100644 (file)
@@ -1314,9 +1314,7 @@ static void free_name_list(void)
 
        if (name_list) { 
                for (i = 0; i < MAX_DEPTH; i++) {
-                       if (name_list[i]) {
-                               free(name_list[i]);
-                       }
+                       free(name_list[i]);
                }
                free(name_list);
        }
index 2390f3056d4783a4ba7759eef0172db0fd926726..e126d7b6e93a6edf04c92160331ae33b78d5dc9e 100644 (file)
@@ -92,8 +92,7 @@ const char *normalize(const char *arg)
         const char *argptr=arg;
         char *bufptr;
 
-        if (BUFFER != NULL)
-                free(BUFFER);
+        free(BUFFER);
 
         if (!quote) { /* Just copy arg */
                BUFFER=xstrdup(arg);
@@ -340,16 +339,14 @@ int getopt_main(int argc, char *argv[])
                         alternative=1;
                         break;
                 case 'o':
-                        if (optstr)
-                                free(optstr);
+                       free(optstr);
                        optstr=xstrdup(optarg);
                         break;
                 case 'l':
                         add_long_options(optarg);
                         break;
                 case 'n':
-                        if (name)
-                                free(name);
+                       free(name);
                        name=xstrdup(optarg);
                         break;
                 case 'q':
index 29e2e3b660415fc22895895f339cc4ae4d1a2e15..391d245a8e01472981933efa48d8541b488f3115 100644 (file)
@@ -158,10 +158,8 @@ static void mtab_free(void)
        this = mtab_cache;
        while (this) {
                next = this->next;
-               if (this->device)
-                       free(this->device);
-               if (this->mountpt)
-                       free(this->mountpt);
+               free(this->device);
+               free(this->mountpt);
                free(this);
                this = next;
        }