From Jakub Zawadzki (bug 3331):
authorstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 13 Mar 2009 22:06:48 +0000 (22:06 +0000)
committerstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 13 Mar 2009 22:06:48 +0000 (22:06 +0000)
g_free() is NULL safe, so we don't need check against it.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@27718 f5534014-38df-0310-8fa8-9805f1628bb7

58 files changed:
epan/addr_resolv.c
epan/dfilter/dfilter-macro.c
epan/dfilter/dfilter.c
epan/dissectors/packet-dcerpc.c
epan/dissectors/packet-gsm_sms.c
epan/dissectors/packet-ieee80211.c
epan/dissectors/packet-k12.c
epan/dissectors/packet-kerberos.c
epan/dissectors/packet-multipart.c
epan/dissectors/packet-rtps.c
epan/dissectors/packet-rtps2.c
epan/dissectors/packet-snmp.c
epan/dissectors/packet-ssl-utils.c
epan/dissectors/packet-user_encap.c
epan/dissectors/packet-xml.c
epan/filesystem.c
epan/ftypes/ftype-pcre.c
epan/ftypes/ftype-string.c
epan/geoip_db.c
epan/ipv4.c
epan/oids.c
epan/prefs.c
epan/proto.c
epan/reassemble.c
epan/stats_tree.c
epan/tvbuff.c
epan/uat.h
epan/wslua/wslua_listener.c
epan/wslua/wslua_pinfo.c
epan/wslua/wslua_proto.c
gtk/capture_dlg.c
gtk/capture_if_dlg.c
gtk/color_edit_dlg.c
gtk/decode_as_ber.c
gtk/decode_as_dcerpc.c
gtk/decode_as_dlg.c
gtk/dfilter_expr_dlg.c
gtk/file_dlg.c
gtk/filter_autocomplete.c
gtk/filter_dlg.c
gtk/filter_utils.c
gtk/find_dlg.c
gtk/flow_graph.c
gtk/gtkvumeter.c
gtk/gui_utils.c
gtk/io_stat.c
gtk/main.c
gtk/main_menu.c
gtk/main_welcome.c
gtk/prefs_column.c
gtk/prefs_dlg.c
gtk/prefs_gui.c
gtk/prefs_layout.c
gtk/prefs_print.c
gtk/profile_dlg.c
gtk/recent.c
gtk/uat_gui.c
gtk/voip_calls.c

index 590c496ea9e99e9928c2db15151c075f08e25892..ea32c6f2bae5d9622bc1250daff6a2d2ed1714d6 100644 (file)
@@ -1961,8 +1961,7 @@ read_hosts_file (const char *hostspath)
         add_ipv4_name(host_addr[0], cp);
     }
   }
-  if (line != NULL)
-    g_free(line);
+  g_free(line);
 
   fclose(hf);
   return TRUE;
@@ -2028,8 +2027,7 @@ read_subnets_file (const char *subnetspath)
 
     subnet_entry_set(host_addr, (guint32)mask_length, cp);
   }
-  if (line != NULL)
-    g_free(line);
+  g_free(line);
 
   fclose(hf);
   return TRUE;
index a6601c4ce49709cdcba7fa504915da8ce56362b8..531aff91118ff137d3a9cf4842a14acc6f0907b2 100644 (file)
@@ -61,7 +61,7 @@ void dump_dfilter_macro_t(const dfilter_macro_t *m, const char *function, const
 
 static gboolean free_value(gpointer k _U_, gpointer v, gpointer u _U_) {
        fvt_cache_entry_t* e = v;
-       if (e->repr) g_free(e->repr);
+       g_free(e->repr);
        g_free(e);
        return TRUE;
 }
@@ -465,12 +465,10 @@ static void macro_update(void* mp, const gchar** error) {
 done:
        g_ptr_array_add(parts,NULL);
 
-       if (m->parts) g_free(m->parts);
-
+       g_free(m->parts);
        m->parts = (gchar**)parts->pdata;
 
-       if (m->args_pos) g_free(m->args_pos);
-
+       g_free(m->args_pos);
        m->args_pos = (int*)(void *)args_pos->data;
 
        g_ptr_array_free(parts,FALSE);
index 13e489110cdfd67cc0003c16c0a2eb6299d835df..6bc1bcd12dd901c28c428795ce0410dd03bea7c9 100644 (file)
@@ -150,9 +150,7 @@ dfilter_free(dfilter_t *df)
                free_insns(df->consts);
        }
 
-       if (df->interesting_fields) {
-               g_free(df->interesting_fields);
-       }
+       g_free(df->interesting_fields);
 
        /* clear registers */
        for (i = 0; i < df->max_registers; i++) {
index 3c43b377198c306151eb7d45c627e694f7a11dfd..6fee1c1d06a9598c373eb23e3324f11faca25267 100644 (file)
@@ -1679,9 +1679,7 @@ init_ndr_pointer_list(packet_info *pinfo)
 
                npd=g_slist_nth_data(ndr_pointer_list, 0);
                ndr_pointer_list=g_slist_remove(ndr_pointer_list, npd);
-               if(npd){
-                       g_free(npd);
-               }
+               g_free(npd);
        }
 
        ndr_pointer_list=NULL;
index cad7db2ca00043a4c12850a44e45e0dc33f4b4b9..1521ee7d15040034a2977b962ce7fa65803dbade 100644 (file)
@@ -2747,8 +2747,7 @@ dis_field_ud(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint32 length, gb
                                                }
                                        }
 
-                                       if(utf8_text)
-                                               g_free(utf8_text);
+                                       g_free(utf8_text);
                                        g_iconv_close(cd);
                                }
                                else
index 3355d6b43357692ad5bc3a616776f4db4fe1894b..1afb415c2f39ab8d9ec60587640ab50bebcce70e 100644 (file)
@@ -12171,7 +12171,8 @@ static tvbuff_t *try_decrypt_wep(tvbuff_t *tvb, guint32 offset, guint32 len) {
     }
   }
 
-  if ((!decr_tvb) && (tmp))    g_free(tmp);
+  if (!decr_tvb)
+       g_free(tmp);
 
 #if 0
   printf("de-wep %p\n", decr_tvb);
@@ -12275,7 +12276,7 @@ void set_airpdcap_keys(void)
         }
       }
     }
-    if(tmpk != NULL) g_free(tmpk);
+    g_free(tmpk);
   }
 
   /* Now set the keys */
@@ -12384,9 +12385,7 @@ static void init_wepkeys(void) {
       g_free(wep_keys[i]);
     g_free(wep_keys);
   }
-
-  if (wep_keylens)
-    g_free(wep_keylens);
+  g_free(wep_keylens);
 
 #ifdef USE_ENV
   guint8 *buf;
@@ -12437,9 +12436,7 @@ static void init_wepkeys(void) {
 #endif
 #endif
 
-      if (wep_keys[keyidx]) {
-        g_free(wep_keys[keyidx]);
-      }
+      g_free(wep_keys[keyidx]);
 
       res = wep_str_to_bytes(tmp, bytes);
       if (tmp && res && bytes->len > 0) {
index 58982518a1f2f56ffdae6643930776f2460f8b90..ca53bd2c0ea7b1b778d004083b1a471edb96aae4 100644 (file)
@@ -318,8 +318,7 @@ k12_update_cb(void* r, const char** err)
        for (num_protos = 0; protos[num_protos]; num_protos++)
                g_strstrip(protos[num_protos]);
 
-       if (h->handles) g_free(h->handles);
-
+       g_free(h->handles);
        h->handles = g_malloc0(sizeof(dissector_handle_t)*(num_protos < 2 ? 2 : num_protos));
 
        for (i = 0; i < num_protos; i++) {
@@ -355,9 +354,10 @@ static void
 k12_free_cb(void* r)
 {
        k12_handles_t* h = r;
-       if (h->match) g_free(h->match);
-       if (h->protos) g_free(h->protos);
-       if (h->handles) g_free(h->handles);
+
+       g_free(h->match);
+       g_free(h->protos);
+       g_free(h->handles);
 }
 
 
index 06f3d894546dd2576f6197b811267ba17be07098..42b994296371f1bfa39504b7b8f8eb93a800fb27 100644 (file)
@@ -533,9 +533,7 @@ decrypt_krb5_data(proto_tree *tree, packet_info *pinfo,
                input.ciphertext.data = (guint8 *)cryptotext;
 
                data.length = length;
-               if(data.data){
-                       g_free(data.data);
-               }
+               g_free(data.data);
                data.data = g_malloc(length);
 
                key.key.enctype=ek->keytype;
@@ -748,8 +746,10 @@ clear_keytab(void) {
 
        for(ske = service_key_list; ske != NULL; ske = g_slist_next(ske)){
                sk = (service_key_t *) ske->data;
-               if (sk && sk->contents) g_free(sk->contents);
-               if (sk) g_free(sk);
+               if (sk) {
+                       g_free(sk->contents);
+                       g_free(sk);
+               }
        }
        g_slist_free(service_key_list);
        service_key_list = NULL;
index e10af37a0ebb857a631b44682529a1b925799cd8..b41bfdd594f444185396b63bcd6d786d86adddfd 100644 (file)
@@ -435,8 +435,7 @@ cleanup_multipart_info(void *data)
 {
        multipart_info_t *m_info = data;
        if (m_info) {
-               if (m_info->boundary)
-                       g_free(m_info->boundary);
+               g_free(m_info->boundary);
                g_free(m_info);
        }
 }
@@ -792,10 +791,8 @@ process_body_part(proto_tree *tree, tvbuff_t *tvb, const guint8 *boundary,
                        }
                }
 
-               if(filename)
-                       g_free(filename);
-               if(typename)
-                       g_free(typename);
+               g_free(filename);
+               g_free(typename);
 
                return boundary_start + boundary_line_len;
        }
index 2ff4da4a1e2c1663894239e733d0087260703285..141e6a3dd4721e1038add84f512acecc8e62f46d 100644 (file)
@@ -1577,9 +1577,8 @@ static gint rtps_util_add_string(proto_tree *tree,      /* Can be NULL */
       g_snprintf(buffer, buffer_size, "%s", retVal);
     }
   }
-  if (retVal != NULL) {
-    g_free(retVal);
-  }
+  g_free(retVal);
+
   /* NDDS align strings at 4-bytes word. So:
    *  string_length: 4 -> buffer_length = 4;
    *  string_length: 5 -> buffer_length = 8;
index f64126a2f39a8aeebfd4e10aafca6be809096ae9..5e2eec8155829ab5b0baa3cb3ad5393227d61b62 100644 (file)
@@ -1795,9 +1795,8 @@ static gint rtps_util_add_string(proto_tree *tree,
       g_snprintf(buffer, buffer_size, "%s", retVal);
     }
   }
-  if (retVal != NULL) {
-    g_free(retVal);
-  }
+  g_free(retVal);
+
   /* NDDS align strings at 4-bytes word. So:
    *  string_length: 4 -> buffer_length = 4;
    *  string_length: 5 -> buffer_length = 8;
index d56019f9ae128a9bf3cb3e307c15f6dbe7d0db2e..864afef32971c8adca4db2f2674927c9bc9b5230 100644 (file)
@@ -3005,12 +3005,12 @@ static void* snmp_users_copy_cb(void* dest, const void* orig, unsigned len _U_)
 
 static void snmp_users_free_cb(void* p) {
        snmp_ue_assoc_t* ue = p;
-       if (ue->user.userName.data) g_free(ue->user.userName.data);
-       if (ue->user.authPassword.data) g_free(ue->user.authPassword.data);
-       if (ue->user.privPassword.data) g_free(ue->user.privPassword.data);
-       if (ue->user.authKey.data) g_free(ue->user.authKey.data);
-       if (ue->user.privKey.data) g_free(ue->user.privKey.data);
-       if (ue->engine.data) g_free(ue->engine.data);
+       g_free(ue->user.userName.data);
+       g_free(ue->user.authPassword.data);
+       g_free(ue->user.privPassword.data);
+       g_free(ue->user.authKey.data);
+       g_free(ue->user.privKey.data);
+       g_free(ue->engine.data);
 }
 
 static void snmp_users_update_cb(void* p _U_, const char** err) {
index ad6fd045b9099dcf8d425d4d6f5e94141761f197..be6c40707f5a89edf4916a75f9a9a832d56dd714 100644 (file)
@@ -2697,12 +2697,10 @@ ssl_common_init(GHashTable **session_hash, StringInfo *decrypted_data, StringInf
     g_hash_table_destroy(*session_hash);
   *session_hash = g_hash_table_new(ssl_hash, ssl_equal);
 
-  if (decrypted_data->data)
-    g_free(decrypted_data->data);
+  g_free(decrypted_data->data);
   ssl_data_alloc(decrypted_data, 32);
 
-  if (compressed_data->data)
-    g_free(compressed_data->data);
+  g_free(compressed_data->data);
   ssl_data_alloc(compressed_data, 32);
 }
 
index 26d54ebb82d39ec69ce37f33d2503859d24d4a46..7859883f5a8a25eb78d479d2d8f8879ff33abd66 100644 (file)
@@ -142,9 +142,9 @@ static void user_free_cb(void* record)
 {
   user_encap_t *u = record;
 
-  if (u->payload_proto_name) g_free(u->payload_proto_name);
-  if (u->header_proto_name)  g_free(u->header_proto_name);
-  if (u->trailer_proto_name) g_free(u->trailer_proto_name);
+  g_free(u->payload_proto_name);
+  g_free(u->header_proto_name);
+  g_free(u->trailer_proto_name);
 }
 
 UAT_VS_DEF(user_encap, encap, user_encap_t, WTAP_ENCAP_USER0, ENCAP0_STR)
index cc09fc0a02e61587212dc3f5e367103299c6cd1e..a2d6152b6069ab0b1b0540bb6b113e4467ed1509 100644 (file)
@@ -793,15 +793,13 @@ static void add_xmlpi_namespace(gpointer k _U_, gpointer v, gpointer p) {
 }
 
 static void destroy_dtd_data(dtd_build_data_t* dtd_data) {
-
-       if(dtd_data->proto_name) g_free(dtd_data->proto_name);
-       if(dtd_data->media_type) g_free(dtd_data->media_type);
-       if(dtd_data->description) g_free(dtd_data->description);
-       if(dtd_data->proto_root) g_free(dtd_data->proto_root);
+       g_free(dtd_data->proto_name);
+       g_free(dtd_data->media_type);
+       g_free(dtd_data->description);
+       g_free(dtd_data->proto_root);
 
        g_string_free(dtd_data->error,TRUE);
 
-
        while(dtd_data->elements->len) {
                dtd_named_list_t* nl = g_ptr_array_remove_index_fast(dtd_data->elements,0);
                g_ptr_array_free(nl->list,TRUE);
@@ -819,10 +817,8 @@ static void destroy_dtd_data(dtd_build_data_t* dtd_data) {
        g_ptr_array_free(dtd_data->attributes,TRUE);
 
        g_free(dtd_data);
-
 }
 
-
 static void copy_attrib_item(gpointer k, gpointer v _U_, gpointer p) {
        gchar* key = g_strdup(k);
        int* value = g_malloc(sizeof(int));
@@ -1036,8 +1032,7 @@ next_attribute:
 
        /* if a proto_root is defined in the dtd we'll use that as root */
        if( dtd_data->proto_root ) {
-               if(root_name)
-                       g_free(root_name);
+               g_free(root_name);
                root_name = g_strdup(dtd_data->proto_root);
        }
 
@@ -1186,9 +1181,7 @@ next_attribute:
        g_hash_table_destroy(elements);
 
        destroy_dtd_data(dtd_data);
-
-       if (root_name)
-               g_free(root_name);
+       g_free(root_name);
 }
 
 #  define DIRECTORY_T GDir
index cf1a347720bdfd8ab9b361396782e5f61348cbd4..5b522d6b76f8c095654d029800c09335ce0df7e4 100644 (file)
@@ -812,9 +812,7 @@ char *getenv_utf8(const char *varname)
 void
 set_profile_name(const gchar *profilename)
 {
-       if (persconfprofile) {
-               g_free (persconfprofile);
-       }
+       g_free (persconfprofile);
 
        if (profilename && strlen(profilename) > 0 &&
            strcmp(profilename, DEFAULT_PROFILE) != 0) {
@@ -934,10 +932,7 @@ get_profiles_dir(void)
 {
        static char *profiles_dir = NULL;
 
-       if (profiles_dir) {
-               g_free (profiles_dir);
-       }
-
+       g_free (profiles_dir);
        profiles_dir = g_strdup_printf ("%s%s%s", get_persconffile_dir_no_profile (),
                                        G_DIR_SEPARATOR_S, PROFILES_DIR);
 
@@ -949,9 +944,7 @@ get_persconffile_dir(const gchar *profilename)
 {
        static char *persconffile_profile_dir = NULL;
 
-       if (persconffile_profile_dir) {
-               g_free (persconffile_profile_dir);
-       }
+       g_free (persconffile_profile_dir);
 
        if (profilename && strlen(profilename) > 0 &&
            strcmp(profilename, DEFAULT_PROFILE) != 0) {
index 7b9c717a098dcc0c04cd61240c05ef13e99fc36c..01b01f1bb1d382555ea8746eb953baa65b5d3c9a 100644 (file)
@@ -86,10 +86,10 @@ static void
 pcre_tuple_free(pcre_tuple_t *tuple)
 {
        if (tuple) {
-               if (tuple->string) g_free(tuple->string);
-               if (tuple->re) g_free(tuple->re);
-               if (tuple->ex) g_free(tuple->ex);
-               if (tuple->error) g_free(tuple->error);
+               g_free(tuple->string);
+               g_free(tuple->re);
+               g_free(tuple->ex);
+               g_free(tuple->error);
                g_free(tuple);
        }
 }
index 4a41c55dcf22d2055d9d0f8dfd594b2bd37f05d9..0e60bc2a2a60a90aa0b941587ead7a7983a8d126 100644 (file)
@@ -45,9 +45,7 @@ string_fvalue_new(fvalue_t *fv)
 static void
 string_fvalue_free(fvalue_t *fv)
 {
-       if (fv->value.string) {
-               g_free(fv->value.string);
-       }
+       g_free(fv->value.string);
 }
 
 static void
index 8becf3e2327ef0c700032772cca7e5ea4c958053..b7339e324b7474cb976a03cebc7ba6fff7298e54 100644 (file)
@@ -118,7 +118,7 @@ static void* geoip_db_path_copy_cb(void* dest, const void* orig, unsigned len _U
 
 static void geoip_db_path_free_cb(void* p) {
        geoip_db_path_t *m = p;
-       if (m->path) g_free(m->path);
+       g_free(m->path);
 }
 
 /**
index 5fe49a0e7e534c603eee3ea8352be8f5361b3771..0472a5be3de0a74fe9e29736ea683b243af2626d 100644 (file)
@@ -49,8 +49,7 @@ ipv4_addr_new(void)
 void
 ipv4_addr_free(ipv4_addr *ipv4)
 {
-       if (ipv4)
-               g_free(ipv4);
+       g_free(ipv4);
 }
 
 void
index fd9bc5036037c4def68a982f68a8fce7bb8ffc9e..e4c40096f22ac2beb13f89edbd064f41ab481454 100644 (file)
@@ -243,7 +243,7 @@ static void* smi_mod_copy_cb(void* dest, const void* orig, unsigned len _U_) {
 
 static void smi_mod_free_cb(void* p) {
        smi_module_t* m = p;
-       if (m->name) g_free(m->name);
+       g_free(m->name);
 }
 
 
index c7269a670847f1c798bbf1782cd3575536754b45..e525a1ba9883bb14139917ab133c7479f6108bf5 100644 (file)
@@ -1206,33 +1206,21 @@ void
 prefs_reset(void)
 {
   prefs_initialized = FALSE;
-  if (prefs.pr_file)
-    g_free(prefs.pr_file);
-  if (prefs.pr_cmd)
-    g_free(prefs.pr_cmd);
+
+  g_free(prefs.pr_file);
+  g_free(prefs.pr_cmd);
   free_col_info(&prefs);
-  if (prefs.gui_font_name)
-    g_free(prefs.gui_font_name);
-  if (prefs.gui_colorized_fg)
-    g_free(prefs.gui_colorized_fg);
-  if (prefs.gui_colorized_bg)
-    g_free(prefs.gui_colorized_bg);
-  if (prefs.gui_fileopen_dir)
-    g_free(prefs.gui_fileopen_dir);
-  if (prefs.gui_webbrowser)
-    g_free(prefs.gui_webbrowser);
-  if (prefs.gui_window_title)
-    g_free(prefs.gui_window_title);
-  if (prefs.gui_start_title)
-    g_free(prefs.gui_start_title);
-  if (prefs.capture_device)
-    g_free(prefs.capture_device);
-  if (prefs.capture_devices_linktypes)
-    g_free(prefs.capture_devices_linktypes);
-  if (prefs.capture_devices_descr)
-    g_free(prefs.capture_devices_descr);
-  if (prefs.capture_devices_hide)
-    g_free(prefs.capture_devices_hide);
+  g_free(prefs.gui_font_name);
+  g_free(prefs.gui_colorized_fg);
+  g_free(prefs.gui_colorized_bg);
+  g_free(prefs.gui_fileopen_dir);
+  g_free(prefs.gui_webbrowser);
+  g_free(prefs.gui_window_title);
+  g_free(prefs.gui_start_title);
+  g_free(prefs.capture_device);
+  g_free(prefs.capture_devices_linktypes);
+  g_free(prefs.capture_devices_descr);
+  g_free(prefs.capture_devices_hide);
 
   uat_unload_all();
   init_prefs();
@@ -1788,10 +1776,10 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
       return PREFS_SET_SYNTAX_ERR;
     }
   } else if (strcmp(pref_name, PRS_PRINT_FILE) == 0) {
-    if (prefs.pr_file) g_free(prefs.pr_file);
+    g_free(prefs.pr_file);
     prefs.pr_file = g_strdup(value);
   } else if (strcmp(pref_name, PRS_PRINT_CMD) == 0) {
-    if (prefs.pr_cmd) g_free(prefs.pr_cmd);
+    g_free(prefs.pr_cmd);
     prefs.pr_cmd = g_strdup(value);
   } else if (strcmp(pref_name, PRS_COL_FMT) == 0) {
     col_l = prefs_get_string_list(value);
@@ -1927,8 +1915,7 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
   } else if (strcmp(pref_name, PRS_GUI_FONT_NAME_1) == 0) {
     /* GTK1 font name obsolete */
   } else if (strcmp(pref_name, PRS_GUI_FONT_NAME_2) == 0) {
-    if (prefs.gui_font_name != NULL)
-      g_free(prefs.gui_font_name);
+    g_free(prefs.gui_font_name);
     prefs.gui_font_name = g_strdup(value);
   } else if (strcmp(pref_name, PRS_GUI_MARKED_FG) == 0) {
     cval = strtoul(value, NULL, 16);
@@ -1943,12 +1930,10 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
     prefs.gui_marked_bg.green = GREEN_COMPONENT(cval);
     prefs.gui_marked_bg.blue  = BLUE_COMPONENT(cval);
   } else if (strcmp(pref_name, PRS_GUI_COLORIZED_FG) == 0) {
-    if (prefs.gui_colorized_fg != NULL)
-      g_free(prefs.gui_colorized_fg);
+    g_free(prefs.gui_colorized_fg);
     prefs.gui_colorized_fg = g_strdup(value);
   } else if (strcmp(pref_name, PRS_GUI_COLORIZED_BG) == 0) {
-    if (prefs.gui_colorized_bg != NULL)
-      g_free(prefs.gui_colorized_bg);
+    g_free(prefs.gui_colorized_bg);
     prefs.gui_colorized_bg = g_strdup(value);
   } else if (strcmp(pref_name, PRS_GUI_GEOMETRY_SAVE_POSITION) == 0) {
     if (g_ascii_strcasecmp(value, "true") == 0) {
@@ -2003,8 +1988,7 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
        find_index_from_string_array(value, gui_fileopen_style_text,
                                     FO_STYLE_LAST_OPENED);
   } else if (strcmp(pref_name, PRS_GUI_FILEOPEN_DIR) == 0) {
-    if (prefs.gui_fileopen_dir != NULL)
-      g_free(prefs.gui_fileopen_dir);
+    g_free(prefs.gui_fileopen_dir);
     prefs.gui_fileopen_dir = g_strdup(value);
   } else if (strcmp(pref_name, PRS_GUI_FILEOPEN_REMEMBERED_DIR) == 0) { /* deprecated */
   } else if (strcmp(pref_name, PRS_GUI_FILEOPEN_PREVIEW) == 0) {
@@ -2034,12 +2018,10 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
     g_free(prefs.gui_webbrowser);
     prefs.gui_webbrowser = g_strdup(value);
   } else if (strcmp(pref_name, PRS_GUI_WINDOW_TITLE) == 0) {
-    if (prefs.gui_window_title != NULL)
-      g_free(prefs.gui_window_title);
+    g_free(prefs.gui_window_title);
     prefs.gui_window_title = g_strdup(value);
   } else if (strcmp(pref_name, PRS_GUI_START_TITLE) == 0) {
-    if (prefs.gui_start_title != NULL)
-      g_free(prefs.gui_start_title);
+    g_free(prefs.gui_start_title);
     prefs.gui_start_title = g_strdup(value);
   } else if (strcmp(pref_name, PRS_GUI_VERSION_IN_START_PAGE) == 0) {
     if (g_ascii_strcasecmp(value, "true") == 0) {
@@ -2069,20 +2051,16 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
 
 /* handle the capture options */
   } else if (strcmp(pref_name, PRS_CAP_DEVICE) == 0) {
-    if (prefs.capture_device != NULL)
-      g_free(prefs.capture_device);
+    g_free(prefs.capture_device);
     prefs.capture_device = g_strdup(value);
   } else if (strcmp(pref_name, PRS_CAP_DEVICES_LINKTYPES) == 0) {
-    if (prefs.capture_devices_linktypes != NULL)
-      g_free(prefs.capture_devices_linktypes);
+    g_free(prefs.capture_devices_linktypes);
     prefs.capture_devices_linktypes = g_strdup(value);
   } else if (strcmp(pref_name, PRS_CAP_DEVICES_DESCR) == 0) {
-    if (prefs.capture_devices_descr != NULL)
-      g_free(prefs.capture_devices_descr);
+    g_free(prefs.capture_devices_descr);
     prefs.capture_devices_descr = g_strdup(value);
   } else if (strcmp(pref_name, PRS_CAP_DEVICES_HIDE) == 0) {
-    if (prefs.capture_devices_hide != NULL)
-      g_free(prefs.capture_devices_hide);
+    g_free(prefs.capture_devices_hide);
     prefs.capture_devices_hide = g_strdup(value);
   } else if (strcmp(pref_name, PRS_CAP_PROM_MODE) == 0) {
     prefs.capture_prom_mode = ((g_ascii_strcasecmp(value, "true") == 0)?TRUE:FALSE);
@@ -3127,11 +3105,10 @@ free_col_info(e_prefs *pr)
 
   while (pr->col_list != NULL) {
     cfmt = pr->col_list->data;
+
     g_free(cfmt->title);
     g_free(cfmt->fmt);
-    if (cfmt->custom_field) {
-      g_free(cfmt->custom_field);
-    }
+    g_free(cfmt->custom_field);
     g_free(cfmt);
     pr->col_list = g_list_remove_link(pr->col_list, pr->col_list);
   }
index 6a0673e66a88f1503688bcca105fc91a8e8249fc..fe81914cdead07edc3e6ca9ab00d83d0f3cd9542 100644 (file)
@@ -407,8 +407,7 @@ proto_cleanup(void)
                g_free(gpa_hfinfo.hfi);
                gpa_hfinfo.hfi=NULL;
        }
-       if (tree_is_expanded != NULL)
-               g_free(tree_is_expanded);
+       g_free(tree_is_expanded);
 
 }
 
index e3d21e6a3fdf41025fc294583c427d2e52aea546..7b75c210767c85e8abcfa19460cb69ed1945d93d 100644 (file)
@@ -850,8 +850,7 @@ fragment_add_work(fragment_data *fd_head, tvbuff_t *tvb, int offset,
                }
        }
 
-       if( old_data )
-               g_free(old_data);
+       g_free(old_data);
        /* mark this packet as defragmented.
            allows us to skip any trailing fragments */
        fd_head->flags |= FD_DEFRAGMENTED;
@@ -1134,9 +1133,7 @@ fragment_defragment_and_free (fragment_data *fd_head, fragment_data *fd,
                        g_free(fd_i->data);
                fd_i->data=NULL;
        }
-       
-       if( old_data )
-               g_free(old_data);
+       g_free(old_data);
        
        /* mark this packet as defragmented.
            allows us to skip any trailing fragments */
index ffdb0ae49c8097ad6d38c1cba33260c4d1a24828..d3f0fd1f783edc40fef9adf6923902a69f404b2e 100644 (file)
@@ -169,10 +169,8 @@ free_stat_node(stat_node *node)
        
        if (node->hash) g_hash_table_destroy(node->hash);
 
-       if (node->rng) g_free(node->rng);
-       
-       if (node->name) g_free(node->name);
-       
+       g_free(node->rng);
+       g_free(node->name);
        g_free(node);
 }
 
index 83e322c7e27d8f684cbcab412ef5c601819e7e56..a47d7792e634c69db43e9c3e590ed5212109dcea 100644 (file)
@@ -168,10 +168,8 @@ tvb_free(tvbuff_t* tvb)
 
                        g_slist_free(composite->tvbs);
 
-                       if (composite->start_offsets)
-                               g_free(composite->start_offsets);
-                       if (composite->end_offsets)
-                               g_free(composite->end_offsets);
+                       g_free(composite->start_offsets);
+                       g_free(composite->end_offsets);
                        if (tvb->real_data) {
                                /*
                                 * XXX - do this with a union?
index 1ba3bfa5e0a54fa0297afc27a6678c603969e5a3..7977e78e141d691d8c0ef1a4849c19ed2d0bba8f 100644 (file)
@@ -324,7 +324,7 @@ gboolean uat_fld_chk_str_ ## what (void* u1 _U_, const char* strptr, unsigned le
 #define UAT_CSTRING_CB_DEF(basename,field_name,rec_t) \
 static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, void* u1 _U_, void* u2 _U_) {\
     char* new_buf = g_strndup(buf,len); \
-       if ((((rec_t*)rec)->field_name)) g_free((((rec_t*)rec)->field_name)); \
+       g_free((((rec_t*)rec)->field_name)); \
        (((rec_t*)rec)->field_name) = new_buf; } \
 static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out_ptr, unsigned* out_len, void* u1 _U_, void* u2 _U_) {\
                if (((rec_t*)rec)->field_name ) { \
@@ -354,7 +354,7 @@ static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out
 #define UAT_LSTRING_CB_DEF(basename,field_name,rec_t,ptr_element,len_element) \
 static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, void* u1 _U_, void* u2 _U_) {\
        char* new_val = uat_unesc(buf,len,&(((rec_t*)rec)->len_element)); \
-    if ((((rec_t*)rec)->ptr_element)) g_free((((rec_t*)rec)->ptr_element)); \
+        g_free((((rec_t*)rec)->ptr_element)); \
        (((rec_t*)rec)->ptr_element) = new_val; }\
 static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out_ptr, unsigned* out_len, void* u1 _U_, void* u2 _U_) {\
        if (((rec_t*)rec)->ptr_element ) { \
@@ -376,9 +376,9 @@ static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out
 #define UAT_BUFFER_CB_DEF(basename,field_name,rec_t,ptr_element,len_element) \
 static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, void* u1 _U_, void* u2 _U_) {\
         char* new_buf = len ? g_memdup(buf,len) : NULL; \
-               if ((((rec_t*)rec)->ptr_element) ) g_free((((rec_t*)rec)->ptr_element)); \
-                       (((rec_t*)rec)->ptr_element) = new_buf; \
-                       (((rec_t*)rec)->len_element) = len; } \
+       g_free((((rec_t*)rec)->ptr_element)); \
+       (((rec_t*)rec)->ptr_element) = new_buf; \
+       (((rec_t*)rec)->len_element) = len; } \
 static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out_ptr, unsigned* out_len, void* u1 _U_, void* u2 _U_) {\
        *out_ptr = ((rec_t*)rec)->ptr_element ? ep_memdup(((rec_t*)rec)->ptr_element,((rec_t*)rec)->len_element) : ""; \
        *out_len = ((rec_t*)rec)->len_element; }
index bd103a95fec2c1a9d13f7f77028c6a0a80aba521..41931a5312070b64639182e71dad3f5ed5881b4b 100644 (file)
@@ -212,7 +212,7 @@ WSLUA_CONSTRUCTOR Listener_new(lua_State* L) {
     error = register_tap_listener(tap_type, tap, tap->filter, lua_tap_reset, lua_tap_packet, lua_tap_draw);
 
     if (error) {
-        if (tap->filter) g_free(tap->filter);
+        g_free(tap->filter);
         g_free(tap->name);
         g_free(tap);
                /* WSLUA_ERROR(new_tap,"tap registration error"); */
index ff0eaf0d9f410b4529cf80fddaf315e666638f23..5e03867eaef422f09f34ec733ed5923604c31ac1 100644 (file)
@@ -223,7 +223,7 @@ static int Address__gc(lua_State* L) {
     Address addr = checkAddress(L,1);
 
     if (addr) {
-        if (addr->data) g_free((void*)addr->data);
+        g_free((void*)addr->data);
         g_free((void*)addr);
     }
 
index 08841cc8bf7a475fe23af557fde28e8e3b2a6d6d..1cd0169f9a781c3e73dc4e1599340cc747a481c9 100644 (file)
@@ -225,9 +225,10 @@ static int Pref_gc(lua_State* L) {
     Pref pref = checkPref(L,1);
     
     if (pref && ! pref->name) {
-        if (pref->label) g_free(pref->label);
-        if (pref->desc) g_free(pref->desc);
-        if (pref->type == PREF_STRING) g_free((void*)pref->value.s);
+        g_free(pref->label);
+        g_free(pref->desc);
+        if (pref->type == PREF_STRING)
+           g_free((void*)pref->value.s);
         g_free(pref);
     }
     
index f527a429677ad8eb3a99b0aacfe68a527d80b8bd..95cdd88058eae81d59e3d3c7cb3c3b83622989b9 100644 (file)
@@ -2608,10 +2608,8 @@ capture_dlg_prep(gpointer parent_w) {
     g_free(entry_text);
     return FALSE;
   }
-  if (global_capture_opts.iface)
-    g_free(global_capture_opts.iface);
-  if (global_capture_opts.iface_descr)
-    g_free(global_capture_opts.iface_descr);
+  g_free(global_capture_opts.iface);
+  g_free(global_capture_opts.iface_descr);
   global_capture_opts.iface = g_strdup(if_name);
   global_capture_opts.iface_descr = get_interface_descriptive_name(global_capture_opts.iface);
   g_free(entry_text);
index 20decfe80b99ed20c720b0ad813421c92c8f9be5..aa5bf3a06346257b530125001978468fc7e1cdcd 100644 (file)
@@ -152,10 +152,8 @@ capture_do_cb(GtkWidget *capture_bt _U_, gpointer if_data)
   airpcap_if_selected = airpcap_if_active;
 #endif
 
-  if (global_capture_opts.iface)
-    g_free(global_capture_opts.iface);
-  if (global_capture_opts.iface_descr)
-    g_free(global_capture_opts.iface_descr);
+  g_free(global_capture_opts.iface);
+  g_free(global_capture_opts.iface_descr);
 
   global_capture_opts.iface = g_strdup(if_dlg_data->device);
   global_capture_opts.iface_descr = get_interface_descriptive_name(global_capture_opts.iface);
@@ -179,10 +177,8 @@ capture_prepare_cb(GtkWidget *prepare_bt _U_, gpointer if_data)
 {
   if_dlg_data_t *if_dlg_data = if_data;
 
-  if (global_capture_opts.iface)
-    g_free(global_capture_opts.iface);
-  if (global_capture_opts.iface_descr)
-    g_free(global_capture_opts.iface_descr);
+  g_free(global_capture_opts.iface);
+  g_free(global_capture_opts.iface_descr);
 
   global_capture_opts.iface = g_strdup(if_dlg_data->device);
   global_capture_opts.iface_descr = get_interface_descriptive_name(global_capture_opts.iface);
index 5f2bc1faa77273ff5729bc661e42d02683d629e6..7146f3511479a9ad2fcd9dfcc6fceefbee262bfb 100644 (file)
@@ -405,12 +405,12 @@ edit_color_filter_ok_cb                (GtkButton       *button,
         color_filters = (GtkWidget *)g_object_get_data(G_OBJECT(button), COLOR_FILTERS_CL);
         colorf = (color_filter_t *)g_object_get_data(G_OBJECT(button), COLOR_FILTER);
 
-        if (colorf->filter_name != NULL)
-            g_free(colorf->filter_name);
+        g_free(colorf->filter_name);
         colorf->filter_name = filter_name;
-        if (colorf->filter_text != NULL)
-            g_free(colorf->filter_text);
+
+        g_free(colorf->filter_text);
         colorf->filter_text = filter_text;
+
        colorf->disabled = filter_disabled;
         gdkcolor_to_color_t(&colorf->fg_color, &new_fg_color);
         gdkcolor_to_color_t(&colorf->bg_color, &new_bg_color);
index 3e5020674d0d6d29ce84470d59c63acf5a9e2fe5..789e36a7d052f0004d2c09e8721624376372d4e6 100644 (file)
@@ -84,8 +84,7 @@ decode_ber(GtkWidget *notebook_pg)
     } else {
       ber_decode_as(syntax);
     }
-    if (syntax != NULL)
-       g_free(syntax);
+    g_free(syntax);
 }
 
 
index e609af864cb9cd1692e4af1841a6b6336e09c52f..7592fa1e48363c49b68d01fbb8c9e6041dd4a5ed 100644 (file)
@@ -267,8 +267,7 @@ decode_change_one_dcerpc_binding(const gchar *table_name, decode_dcerpc_bind_val
                        binding->ver = key->ver;
                        decode_dcerpc_binding_change(table_name, binding);
     }
-    if (abbrev != NULL)
-       g_free(abbrev);
+    g_free(abbrev);
 }
 
 
index edb25a96f65dae13ab420785a20c97f64cb1740c..0c016d6dece18834f8109fc2dd2d7df81fb9620a 100644 (file)
@@ -652,8 +652,7 @@ decode_change_one_dissector(gchar *table_name, guint selector, GtkWidget *list)
     } else {
        dissector_change(table_name, selector, handle);
     }
-    if (abbrev != NULL)
-       g_free(abbrev);
+    g_free(abbrev);
 }
 
 
index 7c68620f08324f4e550bb07e707f0e4991694a63..3d8c7c4ea1e5e220d1982c7ffab93a1901ddd70e 100644 (file)
@@ -733,8 +733,7 @@ dfilter_expr_dlg_accept_cb(GtkWidget *w, gpointer filter_te_arg)
                           "Ranges of that field can't be tested with \"%s\".",
                           item_str);
         }
-        if (range_str != NULL)
-            g_free(range_str);
+        g_free(range_str);
         return;
     }
 
@@ -753,8 +752,7 @@ dfilter_expr_dlg_accept_cb(GtkWidget *w, gpointer filter_te_arg)
                           "That field must be compared with a value, "
                           "but you didn't specify a value with which to "
                           "compare it.");
-            if (range_str != NULL)
-                g_free(range_str);
+            g_free(range_str);
             g_free(value_str);
             return;
         }
@@ -781,8 +779,7 @@ dfilter_expr_dlg_accept_cb(GtkWidget *w, gpointer filter_te_arg)
              * The dialog box was already popped up by
              * "dfilter_report_bad_value()".
              */
-            if (range_str != NULL)
-                g_free(range_str);
+            g_free(range_str);
             g_free(value_str);
             return;
         }
index cd5339cd5a6e677e5ec1825d343e247fa067c786..1e92acb3d4eae4257ab7c92f99ee5d314a29c601 100644 (file)
@@ -247,9 +247,7 @@ set_last_open_dir(char *dirname)
                        updated_last_open_dir = TRUE;
        }
 
-       if (last_open_dir) {
-               g_free(last_open_dir);
-       }
+       g_free(last_open_dir);
        last_open_dir = new_last_open_dir;
 }
 
index 8e94789b9be6397030248001618e6711708ef59d..08b1c89f41326201bed16a7d494246f47f41f429 100644 (file)
@@ -310,8 +310,7 @@ autocompletion_list_lookup(GtkWidget *filter_te, GtkWidget *popup_win, GtkWidget
       return FALSE;
     }
 
-    if (first)
-      g_free (first);
+    g_free (first);
 
     gtk_widget_size_request(list, &requisition);
 
@@ -417,11 +416,8 @@ filter_string_te_key_pressed_cb(GtkWidget *filter_te, GdkEventKey *event)
       popup_win = filter_autocomplete_new(filter_te, name_with_period, FALSE, &stop_propagation);
       g_object_set_data(G_OBJECT(w_toplevel), E_FILT_AUTOCOMP_PTR_KEY, popup_win);
 
-      if(name_with_period)
-        g_free (name_with_period);
-
-      if(prefix_start)
-        g_free(prefix_start);
+      g_free(name_with_period);
+      g_free(prefix_start);
 
       return stop_propagation;
     }
@@ -439,8 +435,7 @@ filter_string_te_key_pressed_cb(GtkWidget *filter_te, GdkEventKey *event)
       }
     }
 
-    if(prefix_start)
-      g_free(prefix_start);
+    g_free(prefix_start);
 
     return FALSE;
   } else if(g_ascii_isalnum(ckey) && !popup_win) {
@@ -451,19 +446,15 @@ filter_string_te_key_pressed_cb(GtkWidget *filter_te, GdkEventKey *event)
       g_object_set_data(G_OBJECT(w_toplevel), E_FILT_AUTOCOMP_PTR_KEY, popup_win);
     }
 
-    if (name)
-      g_free (name);
-
-    if(prefix_start)
-      g_free(prefix_start);
+    g_free(name);
+    g_free(prefix_start);
 
     return stop_propagation;
   }
 
   /* If the popup window hasn't been constructed yet then we have nothing to do */
   if( !popup_win ) {
-    if(prefix_start)
-      g_free(prefix_start);
+    g_free(prefix_start);
 
     return FALSE;
   }
@@ -508,8 +499,7 @@ filter_string_te_key_pressed_cb(GtkWidget *filter_te, GdkEventKey *event)
         gtk_tree_path_free(path);
       }
 
-      if(prefix_start)
-        g_free(prefix_start);
+      g_free(prefix_start);
 
       /* stop event propagation */
       return TRUE;
@@ -549,8 +539,7 @@ filter_string_te_key_pressed_cb(GtkWidget *filter_te, GdkEventKey *event)
         gtk_tree_path_free(path);
       }
 
-      if(prefix_start)
-        g_free(prefix_start);
+      g_free(prefix_start);
 
       /* stop event propagation */
       return TRUE;
@@ -595,15 +584,12 @@ filter_string_te_key_pressed_cb(GtkWidget *filter_te, GdkEventKey *event)
         g_object_set_data(G_OBJECT(w_toplevel), E_FILT_AUTOCOMP_PTR_KEY, NULL);
       }
 
-      if(updated_str)
-        g_free(updated_str);
+      g_free(updated_str);
     }
 
   }
 
-
-  if(prefix_start)
-    g_free(prefix_start);
+  g_free(prefix_start);
 
   if(k == GDK_Return || k == GDK_KP_Enter)
     return TRUE;    /* stop event propagation */
index 16262b6614ead633208374ab360bc8da29883101..1a4b24d07eb11cb8a6f3f9a54d436d896164a672 100644 (file)
@@ -1025,10 +1025,8 @@ filter_sel_list_cb(GtkTreeSelection *sel, gpointer data _U_)
         gtk_widget_set_sensitive(copy_bt, sensitivity);
     if (del_bt != NULL)
         gtk_widget_set_sensitive(del_bt, sensitivity);
-    if (name != NULL)
-        g_free(name);
-    if (strval != NULL)
-        g_free(strval);
+    g_free(name);
+    g_free(strval);
 }
 
 /* To do: add input checking to each of these callbacks */
index 18bf1617438dc8c15fa8566a3251d4e6c6c3e9af..a41fe657bf2e7a77ade80fe465492c48a58b5a7b 100644 (file)
@@ -103,8 +103,5 @@ apply_selected_filter (guint callback_action, char *filter)
                color_display_with_filter(str);
                break;
        }
-
-       if (str) {
-               g_free (str);
-       }
+       g_free (str);
 }
index 2cf218581c0f476b2d41484d55735b33e20e4b84..59dcff6cc5a9e9e62551f0914ccf9490a477da34 100644 (file)
@@ -647,8 +647,7 @@ find_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
   /*
    * Remember the search parameters.
    */
-  if (cfile.sfilter)
-    g_free(cfile.sfilter);
+  g_free(cfile.sfilter);
   cfile.sfilter = g_strdup(filter_text);
   cfile.sbackward = GTK_TOGGLE_BUTTON (up_rb)->active;
   cfile.hex = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (hex_rb));
index c070d80b29f91c1951fcbb873e1ee5055e6e007a..745b6debe0d76d310673448eceded870ed50b5a4 100644 (file)
@@ -249,13 +249,10 @@ static int flow_graph_frame_add_to_graph(packet_info *pinfo)
        gai->comment=NULL;
        gai->frame_label=NULL;
 
-       if (gai->comment!=NULL){
-               g_free(gai->comment);
-       }
-       if (gai->frame_label!=NULL){
-               g_free(gai->frame_label);
-       }
-
+       /* this code doesn't make sense.
+       g_free(gai->comment);
+       g_free(gai->frame_label);
+       */
 
        if(pinfo->cinfo) {
                if (pinfo->cinfo->col_first[COL_INFO]>=0){
@@ -263,6 +260,7 @@ static int flow_graph_frame_add_to_graph(packet_info *pinfo)
                        for (i = pinfo->cinfo->col_first[COL_INFO]; i <= pinfo->cinfo->col_last[COL_INFO]; i++) {
                                if (pinfo->cinfo->fmt_matx[i][COL_INFO]) {
                                        colinfo = g_strdup(pinfo->cinfo->col_data[i]);
+                                       /* break; ? or g_free(colinfo); before g_strdup() */
                                }
                        }
                }
@@ -272,7 +270,7 @@ static int flow_graph_frame_add_to_graph(packet_info *pinfo)
                        for (i = pinfo->cinfo->col_first[COL_PROTOCOL]; i <= pinfo->cinfo->col_last[COL_PROTOCOL]; i++) {
                                if (pinfo->cinfo->fmt_matx[i][COL_PROTOCOL]) {
                                        protocol = g_strdup(pinfo->cinfo->col_data[i]);
-
+                                       /* break; ? or g_free(protocol); before g_strdup() */
                                }
                        }
                }
@@ -291,18 +289,11 @@ static int flow_graph_frame_add_to_graph(packet_info *pinfo)
                if (protocol != NULL) {
                        gai->frame_label = g_strdup_printf("%.19s", protocol);
                        gai->comment = g_strdup_printf("%s", protocol);
-               } else {
-                       gai->frame_label = NULL;
-                       gai->comment = NULL;
                }
        }
 
-       if (protocol!=NULL){
-               g_free(protocol);
-       }
-       if (colinfo!=NULL){
-               g_free(colinfo);
-       }
+       g_free(protocol);
+       g_free(colinfo);
 
        gai->line_style=1;
        gai->conv_num=0;
index 05b8f7f571d0027cf4dffb0232763e0814fcadea..3f84f6acd3d137e4bdee7d5771599fadd8420553 100644 (file)
@@ -692,9 +692,7 @@ void gtk_vumeter_free_scale_items(GList *scale_items)
     for (current = scale_items; current != NULL; current = g_list_next(current)) {
         GtkVUMeterScaleItem * item = current->data;
 
-        if(item->label != NULL) {
-            g_free((void *) item->label);
-        }
+        g_free((void *) item->label);
         g_free(item);
     }
 
index 4c3924387a3bd530165aaecb9a1c63ec6a0746f7..b991c036bdad841e3997a12c537b6c0ef4fa44c3 100644 (file)
@@ -537,8 +537,7 @@ set_main_window_name(const gchar *window_name)
 
   /* Attach the new un-decorated window name to the window. */
   old_window_name = g_object_get_data(G_OBJECT(top_level), MAIN_WINDOW_NAME_KEY);
-  if (old_window_name != NULL)
-    g_free(old_window_name);
+  g_free(old_window_name);
   g_object_set_data(G_OBJECT(top_level), MAIN_WINDOW_NAME_KEY, g_strdup(window_name));
 
   update_main_window_name();
index d2fd824a7edab067dfac71a6f211bb0c43a8265d..c4ba37026bca73c1ee836b5098daac461d1db815 100644 (file)
@@ -2039,9 +2039,7 @@ create_filter_box(io_stat_graph_t *gio, GtkWidget *box, int num)
        gio->filter_bt=gtk_button_new_from_stock(WIRESHARK_STOCK_DISPLAY_FILTER_ENTRY);
 
        g_snprintf(str, 256, "Wireshark: Display Filter  IO-Stat (Filter:%d)", num);
-       if(gio->args->title){
-               g_free( (gpointer) (gio->args->title) );
-       }
+       g_free( (gpointer) (gio->args->title) );
        gio->args->title=g_strdup(str);
 
        g_signal_connect(gio->filter_bt, "clicked", G_CALLBACK(filter_button_clicked), gio);
index 88f7eb6eb2ef8218c9bba6ec594734e2d717dc89..2bde44d5ec0110e64399b2f9b80ac6111fc5171a 100644 (file)
@@ -2210,8 +2210,7 @@ main(int argc, char *argv[])
 #endif
         break;
       case 'm':        /* Fixed-width font for the display */
-        if (prefs->gui_font_name != NULL)
-          g_free(prefs->gui_font_name);
+        g_free(prefs->gui_font_name);
         prefs->gui_font_name = g_strdup(optarg);
         break;
       case 'n':        /* No name resolution */
index 203eccd32c28eb83f38f906ceceaebbb3e262552..a091077a73fc4e19017090dc69c519f1c8147daf 100644 (file)
@@ -3110,9 +3110,7 @@ set_menus_for_selected_tree_row(capture_file *cf)
          rebuild_protocol_prefs_menu (prefs, properties);
 
          g_object_set_data(G_OBJECT(tree_view_menu_factory), "menu_abbrev", g_strdup(abbrev));
-         if (prev_abbrev) {
-           g_free (prev_abbrev);
-         }
+         g_free (prev_abbrev);
        }
   } else {
        set_menu_sensitivity(main_menu_factory,
index 1f4fce898eeace66cda009f7e726ee6ceab979ee..d7f6e049ff4b9e6af6fad6eac8f3ba8c6683f263 100644 (file)
@@ -475,10 +475,8 @@ main_welcome_add_recent_capture_files(const char *widget_cf_name)
 static gboolean
 welcome_if_press_cb(GtkWidget *widget _U_, GdkEvent *event _U_, gpointer data)
 {
-    if (global_capture_opts.iface)
-        g_free(global_capture_opts.iface);
-    if (global_capture_opts.iface_descr)
-        g_free(global_capture_opts.iface_descr);
+    g_free(global_capture_opts.iface);
+    g_free(global_capture_opts.iface_descr);
 
     global_capture_opts.iface = g_strdup(data);
     global_capture_opts.iface_descr = NULL;
index d8ea3de3901793e92acb1aa14c1e5e63ad701915..427708ad6e8f4153cbc0119d124913934688b376 100644 (file)
@@ -351,9 +351,7 @@ column_list_delete_cb(GtkWidget *w _U_, gpointer data) {
         cfmt = (fmt_data *) clp->data;
         g_free(cfmt->title);
         g_free(cfmt->fmt);
-        if (cfmt->custom_field) {
-          g_free (cfmt->custom_field);
-        }
+        g_free(cfmt->custom_field);
         g_free(cfmt);
         prefs.col_list = g_list_remove_link(prefs.col_list, clp);
 
@@ -406,9 +404,7 @@ column_field_changed_cb(GtkEditable *te, gpointer data) {
         fmt = g_strdup_printf("%s (%s)", col_format_desc(cur_fmt), field);
         gtk_list_store_set(GTK_LIST_STORE(model), &iter, 1, fmt, -1);
        g_free(fmt);
-        if (cfmt->custom_field) {
-          g_free(cfmt->custom_field);
-        }
+        g_free(cfmt->custom_field);
         cfmt->custom_field = field;
     }
     cfile.cinfo.columns_changed = TRUE;
index 18199d03f42d37c7d7ecc0c6fe3198e21f64a24a..f2de2e794b33477adf7731e12fa98a1f5078d143 100644 (file)
@@ -212,8 +212,7 @@ pref_show(pref_t *pref, gpointer user_data)
     break;
 
   case PREF_STRING:
-    if (pref->saved_val.string != NULL)
-      g_free(pref->saved_val.string);
+    g_free(pref->saved_val.string);
     pref->saved_val.string = g_strdup(*pref->varp.string);
     pref->control = create_preference_entry(main_tb, pref->ordinal,
                                            label_string, pref->description,
@@ -224,8 +223,7 @@ pref_show(pref_t *pref, gpointer user_data)
   {
     char *range_string;
 
-    if (pref->saved_val.range != NULL)
-      g_free(pref->saved_val.range);
+    g_free(pref->saved_val.range);
     pref->saved_val.range = range_copy(*pref->varp.range);
     range_string = range_convert_range(*pref->varp.range);
     pref->control = create_preference_entry(main_tb, pref->ordinal,
index 9f897bc3d2e59b65c4484f5293c6b706d0f085d1..054840146a3d1c8c76211fabb0dec0bf623e5d6c 100644 (file)
@@ -415,8 +415,7 @@ gui_prefs_fetch(GtkWidget *w)
        prefs.gui_fileopen_style = fetch_preference_radio_buttons_val(
            g_object_get_data(G_OBJECT(w), GUI_FILEOPEN_KEY), gui_fileopen_vals);
        
-       if (prefs.gui_fileopen_dir != NULL)
-               g_free(prefs.gui_fileopen_dir);
+       g_free(prefs.gui_fileopen_dir);
        prefs.gui_fileopen_dir = g_strdup(gtk_entry_get_text(
                                               GTK_ENTRY(g_object_get_data(G_OBJECT(w), GUI_FILEOPEN_DIR_KEY))));
 
@@ -446,8 +445,7 @@ gui_prefs_fetch(GtkWidget *w)
        if (font_fetch()) {
                if (strcmp(new_font_name, prefs.gui_font_name) != 0) {
                        font_changed = TRUE;
-                       if (prefs.gui_font_name != NULL)
-                               g_free(prefs.gui_font_name);
+                       g_free(prefs.gui_font_name);
                        prefs.gui_font_name = g_strdup(new_font_name);
                }
        }
index c97a15552ad5795cef5b8c268ec9326e2723a716..b7aa58317f819e10b59a92026b3b4cb8920634ed 100644 (file)
@@ -477,8 +477,7 @@ layout_prefs_fetch(GtkWidget *w)
     prefs.gui_toolbar_main_style = fetch_enum_value(
         g_object_get_data(G_OBJECT(w), GUI_TOOLBAR_STYLE_KEY), toolbar_style_vals);
 
-    if (prefs.gui_window_title != NULL)
-        g_free(prefs.gui_window_title);
+    g_free(prefs.gui_window_title);
     prefs.gui_window_title = g_strdup(gtk_entry_get_text(
                                           GTK_ENTRY(g_object_get_data(G_OBJECT(w), GUI_WINDOW_TITLE_KEY))));
 }
index f5eb6ed12dbf5d4546a96c61d7747528f505608d..95753b5bbea59a62de7cf390bfae9c5ed712c288 100644 (file)
@@ -152,14 +152,12 @@ printer_prefs_fetch(GtkWidget *w)
       g_object_get_data(G_OBJECT(w), E_PRINT_DESTINATION_KEY), print_dest_vals);
 
 #ifndef _WIN32
-  if (prefs.pr_cmd)
-    g_free(prefs.pr_cmd);
+  g_free(prefs.pr_cmd);
   prefs.pr_cmd = g_strdup(gtk_entry_get_text(
                               GTK_ENTRY(g_object_get_data(G_OBJECT(w), PRINT_CMD_TE_KEY))));
 #endif
 
-  if (prefs.pr_file)
-    g_free(prefs.pr_file);
+  g_free(prefs.pr_file);
   prefs.pr_file = g_strdup(gtk_entry_get_text(
                                GTK_ENTRY(g_object_get_data(G_OBJECT(w), PRINT_FILE_TE_KEY))));
 }
index ccfa7920a2cef14f62bbef108dcd2c5cbe8e2bc6..eeec1c00a5a5c877dd9f05440f2a9ed7c0a15976 100644 (file)
@@ -322,9 +322,8 @@ profile_apply(GtkWidget *main_w, GtkTreeView *profile_l, gboolean destroy)
          g_free(pf_dir_path);
        }
        profile1->status = PROF_STAT_EXISTS;
-       if (profile1->reference) {
-         g_free (profile1->reference);
-       }
+
+       g_free (profile1->reference);
        profile1->reference = g_strdup(profile1->name);
       }
     } else if (profile1->status == PROF_STAT_CHANGED) {
@@ -506,8 +505,7 @@ profile_sel_list_cb(GtkTreeSelection *sel, gpointer data _U_)
     gtk_widget_set_sensitive(copy_bt, sensitivity);
   if (del_bt != NULL)
     gtk_widget_set_sensitive(del_bt, sensitivity);
-  if (name != NULL)
-    g_free(name);
+  g_free(name);
 }
 
 static void
index 51642c8f5a81be3fd9433fef44a59d68f1f23415..a57f0e06dc1302d64cbea3bdd98e9da8f7549b0f 100644 (file)
@@ -120,9 +120,7 @@ free_col_width_info(recent_settings_t *rs)
 
   while (rs->col_width_list != NULL) {
     cfmt = rs->col_width_list->data;
-    if (cfmt->cfield) {
-      g_free(cfmt->cfield);
-    }
+    g_free(cfmt->cfield);
     g_free(cfmt);
     rs->col_width_list = g_list_remove_link(rs->col_width_list, rs->col_width_list);
   }
index 2b7c7744dc85e0ea27cb481cb6715ad3fa2a5c21..d8e45d787034946659bc020d7445b24eaab9a818 100644 (file)
@@ -636,7 +636,7 @@ static gboolean uat_window_delete_event_cb(GtkWindow *w _U_, GdkEvent* e _U_, gp
                gtk_widget_destroy(uat->rep->window);
 
                uat->rep = NULL;
-               if (rep) g_free(rep);
+               g_free(rep);
        }
        return TRUE;
 }
index b4012cbb1156d088f7e8db776e788e30202541de..a92763ca43ce157083d11f51daea214fd3b1631a 100644 (file)
@@ -150,15 +150,12 @@ void voip_calls_reset(voip_calls_tapinfo_t *tapinfo)
        while (list)
        {
                callsinfo = list->data;
-               if (callsinfo->call_id)
-                       g_free(callsinfo->call_id);
+               g_free(callsinfo->call_id);
                g_free(callsinfo->from_identity);
                g_free(callsinfo->to_identity);
                g_free((void *)(callsinfo->initial_speaker.data));
-               if (callsinfo->protocol_name)
-                       g_free(callsinfo->protocol_name);
-               if (callsinfo->call_comment)
-                       g_free(callsinfo->call_comment);
+               g_free(callsinfo->protocol_name);
+               g_free(callsinfo->call_comment);
 
                if (callsinfo->free_prot_info && callsinfo->prot_info)
                        callsinfo->free_prot_info(callsinfo->prot_info);
@@ -864,7 +861,7 @@ static guint32 sdp_frame_num = 0;
 static void free_sip_info(gpointer p) {
        sip_calls_info_t *si = p;
 
-       if (si->call_identifier) g_free(si->call_identifier);
+       g_free(si->call_identifier);
        g_free(si);
 }
 
@@ -1705,7 +1702,7 @@ static void add_h245_Address(h323_calls_info_t *h323info,  h245_address_t *h245_
 static void free_h225_info(gpointer p) {
        h323_calls_info_t *tmp_h323info = p;
 
-       if (tmp_h323info->guid) g_free(tmp_h323info->guid);
+       g_free(tmp_h323info->guid);
 
        if (tmp_h323info->h245_list) {
                GList *list2 = g_list_first(tmp_h323info->h245_list);
@@ -2948,12 +2945,12 @@ static int sccp_calls(packet_info *pinfo, const void *prot_info) {
        } else {
 
                if ( assoc->calling_party ) {
-                       if (callsinfo->from_identity) g_free(callsinfo->from_identity );
+                       g_free(callsinfo->from_identity);
                        callsinfo->from_identity =  g_strdup(assoc->calling_party);
                }
 
                if ( assoc->called_party ) {
-                       if (callsinfo->to_identity) g_free(callsinfo->to_identity );
+                       g_free(callsinfo->to_identity);
                        callsinfo->to_identity =  g_strdup(assoc->called_party);
                }