aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmad Fatoum <ahmad@a3f.at>2017-08-26 10:30:47 +0200
committerJoão Valverde <j@v6e.pt>2017-10-15 12:38:51 +0000
commit9d49e1316689ae05d31efc866f04ac12cd051085 (patch)
treef51b835fd490fe6be49268a114014f597f47c252
parent37ccb77a1ab845075465c2d86eea9e8e21abc273 (diff)
Remove superfluous null-checks before strdup/free
NULL checks were removed for following free functions: - g_free "If mem is NULL it simply returns" https://developer.gnome.org/glib/stable/glib-Memory-Allocation.html#g-free - g_slist_free(_full)? "NULL is considered to be the empty list" https://developer.gnome.org/glib/stable/glib-Singly-Linked-Lists.html - g_strfreev "If str_array is NULL, this function simply returns." https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strfreev - g_slice_free "If mem is NULL, this macro does nothing." https://developer.gnome.org/glib/stable/glib-Memory-Slices.html#g-slice-free - g_match_info_free "not NULL... otherwise does nothing" https://developer.gnome.org/glib/stable/glib-Perl-compatible-regular-expressions.html#g-match-info-free - dfilter_free defined in Wireshark code. Returns early when passed NULL epan/dfilter/dfilter.c They were also removed around calls to g_strdup where applicable: - g_strdup "If str is NULL it returns NULL." https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strdup Change-Id: Ie80c2db89bef531edc3aed7b7c9f654e1d654d04 Reviewed-on: https://code.wireshark.org/review/23406 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: João Valverde <j@v6e.pt>
-rw-r--r--capture_opts.c3
-rw-r--r--caputils/airpcap_loader.c20
-rw-r--r--epan/color_filters.c15
-rw-r--r--epan/crypt/airpdcap.c3
-rw-r--r--epan/dfilter/dfilter-macro.c2
-rw-r--r--epan/dissectors/asn1/kerberos/packet-kerberos-template.c11
-rw-r--r--epan/dissectors/asn1/ldap/packet-ldap-template.c4
-rw-r--r--epan/dissectors/packet-ber.c9
-rw-r--r--epan/dissectors/packet-bootp.c8
-rw-r--r--epan/dissectors/packet-corosync-totemnet.c5
-rw-r--r--epan/dissectors/packet-dcerpc.c7
-rw-r--r--epan/dissectors/packet-dof.c88
-rw-r--r--epan/dissectors/packet-dvbci.c10
-rw-r--r--epan/dissectors/packet-epl.c4
-rw-r--r--epan/dissectors/packet-gsm_sms.c4
-rw-r--r--epan/dissectors/packet-http.c19
-rw-r--r--epan/dissectors/packet-ieee80211.c9
-rw-r--r--epan/dissectors/packet-ipsec.c17
-rw-r--r--epan/dissectors/packet-kerberos.c11
-rw-r--r--epan/dissectors/packet-l2tp.c3
-rw-r--r--epan/dissectors/packet-ldap.c4
-rw-r--r--epan/dissectors/packet-pdcp-lte.c6
-rw-r--r--epan/dissectors/packet-reload.c9
-rw-r--r--epan/dissectors/packet-sctp.c8
-rw-r--r--epan/dissectors/packet-sip.c33
-rw-r--r--epan/dissectors/packet-smb.c3
-rw-r--r--epan/dissectors/packet-udp-nm.c37
-rw-r--r--epan/dissectors/packet-umts_fp.c4
-rw-r--r--epan/dissectors/packet-zbee-nwk-gp.c21
-rw-r--r--epan/dissectors/packet-zbee-security.c18
-rw-r--r--epan/dtd_grammar.lemon7
-rw-r--r--epan/dtd_parse.l13
-rw-r--r--epan/dtd_preparse.l2
-rw-r--r--epan/expert.c9
-rw-r--r--epan/geoip_db.c8
-rw-r--r--epan/plugin_if.c3
-rw-r--r--epan/prefs.c24
-rw-r--r--epan/radius_dict.l3
-rw-r--r--epan/reassemble.c8
-rw-r--r--epan/srt_table.c6
-rw-r--r--epan/tap.c4
-rw-r--r--epan/wslua/lrexlib_glib.c3
-rw-r--r--epan/wslua/wslua_capture_info.c6
-rw-r--r--epan/wslua/wslua_dir.c6
-rw-r--r--epan/wslua/wslua_file.c3
-rw-r--r--epan/wslua/wslua_frame_info.c6
-rw-r--r--epan/wslua/wslua_listener.c2
-rw-r--r--extcap/sshdump.c3
-rw-r--r--extcap_parser.c8
-rw-r--r--file.c12
-rw-r--r--plugins/mate/mate_grammar.lemon2
-rw-r--r--tools/lemon/lemon.c7
-rw-r--r--ui/cli/tap-comparestat.c6
-rw-r--r--ui/cli/tap-httpstat.c6
-rw-r--r--ui/cli/tap-icmpstat.c6
-rw-r--r--ui/cli/tap-icmpv6stat.c6
-rw-r--r--ui/cli/tap-iostat.c3
-rw-r--r--ui/cli/tap-protohierstat.c7
-rw-r--r--ui/cli/tap-rtspstat.c6
-rw-r--r--ui/cli/tap-sipstat.c6
-rw-r--r--ui/cli/tap-wspstat.c7
-rw-r--r--ui/gtk/airpcap_gui_utils.c13
-rw-r--r--ui/gtk/capture_dlg.c14
-rw-r--r--ui/gtk/capture_file_dlg.c6
-rw-r--r--ui/gtk/color_edit_dlg.c4
-rw-r--r--ui/gtk/extcap_gtk.c6
-rw-r--r--ui/gtk/funnel_stat.c2
-rw-r--r--ui/gtk/io_stat.c3
-rw-r--r--ui/gtk/mac_lte_stat_dlg.c7
-rw-r--r--ui/gtk/main.c3
-rw-r--r--ui/gtk/main_welcome.c3
-rw-r--r--ui/gtk/prefs_capture.c6
-rw-r--r--ui/gtk/rlc_lte_stat_dlg.c8
-rw-r--r--ui/iface_lists.c6
-rw-r--r--ui/language.c3
-rw-r--r--ui/proto_hier_stats.c5
-rw-r--r--ui/qt/main_window.cpp6
-rw-r--r--ui/qt/main_window_preferences_frame.cpp3
-rw-r--r--ui/qt/main_window_slots.cpp3
-rw-r--r--ui/recent.c16
-rw-r--r--ui/voip_calls.c32
-rw-r--r--ui/win32/file_dlg_win32.c11
-rw-r--r--wiretap/catapult_dct2000.c4
-rw-r--r--wiretap/file_access.c6
-rw-r--r--wiretap/ngsniffer.c9
-rw-r--r--wiretap/pppdump.c3
-rw-r--r--wiretap/visual.c3
-rw-r--r--wiretap/wtap.c3
-rw-r--r--wsutil/interface.c3
89 files changed, 220 insertions, 564 deletions
diff --git a/capture_opts.c b/capture_opts.c
index 2b527af..458152e 100644
--- a/capture_opts.c
+++ b/capture_opts.c
@@ -1152,8 +1152,7 @@ capture_opts_del_iface(capture_options *capture_opts, guint if_index)
g_free(interface_opts->name);
g_free(interface_opts->descr);
- if (interface_opts->console_display_name != NULL)
- g_free(interface_opts->console_display_name);
+ g_free(interface_opts->console_display_name);
g_free(interface_opts->cfilter);
g_free(interface_opts->timestamp_type);
#ifdef HAVE_EXTCAP
diff --git a/caputils/airpcap_loader.c b/caputils/airpcap_loader.c
index 1d290b4..8896bf0 100644
--- a/caputils/airpcap_loader.c
+++ b/caputils/airpcap_loader.c
@@ -780,11 +780,9 @@ free_airpcap_if_cb(gpointer data, gpointer user_data _U_)
if (NULL == if_info)
return;
- if (if_info->name != NULL)
- g_free(if_info->name);
+ g_free(if_info->name);
- if (if_info->description != NULL)
- g_free(if_info->description);
+ g_free(if_info->description);
/* XXX - FREE THE WEP KEY LIST HERE!!!*/
if (if_info->keysCollection != NULL)
@@ -793,8 +791,7 @@ free_airpcap_if_cb(gpointer data, gpointer user_data _U_)
if_info->keysCollection = NULL;
}
- if (if_info->ip_addr != NULL)
- g_slist_free(if_info->ip_addr);
+ g_slist_free(if_info->ip_addr);
g_free(if_info);
}
@@ -1107,11 +1104,9 @@ airpcap_if_info_free(airpcap_if_info_t *if_info)
{
if (if_info != NULL)
{
- if (if_info->name != NULL)
- g_free(if_info->name);
+ g_free(if_info->name);
- if (if_info->description != NULL)
- g_free(if_info->description);
+ g_free(if_info->description);
if (if_info->keysCollection != NULL)
{
@@ -1125,10 +1120,7 @@ airpcap_if_info_free(airpcap_if_info_t *if_info)
if_info->ip_addr = NULL;
}
- if (if_info != NULL)
- {
- g_free(if_info);
- }
+ g_free(if_info);
}
}
diff --git a/epan/color_filters.c b/epan/color_filters.c
index 3a184bb..da0dd96 100644
--- a/epan/color_filters.c
+++ b/epan/color_filters.c
@@ -173,10 +173,8 @@ color_filters_set_tmp(guint8 filt_nr, const gchar *filter, gboolean disabled, gc
g_free(local_err_msg);
return FALSE;
} else {
- if (colorf->filter_text != NULL)
- g_free(colorf->filter_text);
- if (colorf->c_colorfilter != NULL)
- dfilter_free(colorf->c_colorfilter);
+ g_free(colorf->filter_text);
+ dfilter_free(colorf->c_colorfilter);
colorf->filter_text = g_strdup(tmpfilter);
colorf->c_colorfilter = compiled_filter;
colorf->disabled = ((i!=filt_nr) ? TRUE : disabled);
@@ -225,12 +223,9 @@ color_filters_reset_tmp(gchar **err_msg)
void
color_filter_delete(color_filter_t *colorf)
{
- if (colorf->filter_name != NULL)
- g_free(colorf->filter_name);
- if (colorf->filter_text != NULL)
- g_free(colorf->filter_text);
- if (colorf->c_colorfilter != NULL)
- dfilter_free(colorf->c_colorfilter);
+ g_free(colorf->filter_name);
+ g_free(colorf->filter_text);
+ dfilter_free(colorf->c_colorfilter);
g_free(colorf);
}
diff --git a/epan/crypt/airpdcap.c b/epan/crypt/airpdcap.c
index 2b8c291..577b1a3 100644
--- a/epan/crypt/airpdcap.c
+++ b/epan/crypt/airpdcap.c
@@ -2088,8 +2088,7 @@ parse_key_string(gchar* input_string, guint8 key_type)
g_byte_array_free(ssid_ba, TRUE);
g_free(key);
- if(ssid != NULL)
- g_free(ssid);
+ g_free(ssid);
/* Free the array of strings */
g_strfreev(tokens);
diff --git a/epan/dfilter/dfilter-macro.c b/epan/dfilter/dfilter-macro.c
index 51babd2..dbfbcc1 100644
--- a/epan/dfilter/dfilter-macro.c
+++ b/epan/dfilter/dfilter-macro.c
@@ -184,7 +184,7 @@ static gchar* dfilter_macro_apply_recurse(const gchar* text, guint depth, gchar*
FGS(name); \
FGS(arg); \
if (args) { \
- while(args->len) { void* p = g_ptr_array_remove_index_fast(args,0); if (p) g_free(p); } \
+ while(args->len) { void* p = g_ptr_array_remove_index_fast(args,0); g_free(p); } \
g_ptr_array_free(args,TRUE); \
args = NULL; \
} \
diff --git a/epan/dissectors/asn1/kerberos/packet-kerberos-template.c b/epan/dissectors/asn1/kerberos/packet-kerberos-template.c
index 6ce5988..4412fb1 100644
--- a/epan/dissectors/asn1/kerberos/packet-kerberos-template.c
+++ b/epan/dissectors/asn1/kerberos/packet-kerberos-template.c
@@ -251,10 +251,7 @@ read_keytab_file_from_preferences(void)
return;
}
- if (last_keytab != NULL) {
- g_free(last_keytab);
- last_keytab = NULL;
- }
+ g_free(last_keytab);
last_keytab = g_strdup(keytab_filename);
read_keytab_file(last_keytab);
@@ -620,9 +617,9 @@ clear_keytab(void) {
for(ske = service_key_list; ske != NULL; ske = g_slist_next(ske)){
sk = (service_key_t *) ske->data;
if (sk) {
- g_free(sk->contents);
- g_free(sk);
- }
+ g_free(sk->contents);
+ g_free(sk);
+ }
}
g_slist_free(service_key_list);
service_key_list = NULL;
diff --git a/epan/dissectors/asn1/ldap/packet-ldap-template.c b/epan/dissectors/asn1/ldap/packet-ldap-template.c
index 544cf07..10832a8 100644
--- a/epan/dissectors/asn1/ldap/packet-ldap-template.c
+++ b/epan/dissectors/asn1/ldap/packet-ldap-template.c
@@ -515,8 +515,8 @@ attribute_types_free_cb(void*r)
{
attribute_type_t* rec = (attribute_type_t*)r;
- if (rec->attribute_type) g_free(rec->attribute_type);
- if (rec->attribute_desc) g_free(rec->attribute_desc);
+ g_free(rec->attribute_type);
+ g_free(rec->attribute_desc);
}
UAT_CSTRING_CB_DEF(attribute_types, attribute_type, attribute_type_t)
diff --git a/epan/dissectors/packet-ber.c b/epan/dissectors/packet-ber.c
index 6d8b6db..2e1baa8 100644
--- a/epan/dissectors/packet-ber.c
+++ b/epan/dissectors/packet-ber.c
@@ -513,13 +513,8 @@ void
ber_decode_as(const gchar *syntax)
{
- if (decode_as_syntax) {
- g_free(decode_as_syntax);
- decode_as_syntax = NULL;
- }
-
- if (syntax)
- decode_as_syntax = g_strdup(syntax);
+ g_free(decode_as_syntax);
+ decode_as_syntax = g_strdup(syntax);
}
/* Get oid syntax from hash table to get translation in proto dissection(packet-per.c) */
diff --git a/epan/dissectors/packet-bootp.c b/epan/dissectors/packet-bootp.c
index 133511b..94240b2 100644
--- a/epan/dissectors/packet-bootp.c
+++ b/epan/dissectors/packet-bootp.c
@@ -1487,11 +1487,7 @@ static void* uat_bootp_record_copy_cb(void* n, const void* o, size_t siz _U_) {
uat_bootp_record_t* new_record = (uat_bootp_record_t *)n;
const uat_bootp_record_t* old_record = (const uat_bootp_record_t *)o;
- if (old_record->text) {
- new_record->text = g_strdup(old_record->text);
- } else {
- new_record->text = NULL;
- }
+ new_record->text = g_strdup(old_record->text);
return new_record;
}
@@ -1509,7 +1505,7 @@ static gboolean uat_bootp_record_update_cb(void* r, char** err) {
static void uat_bootp_record_free_cb(void*r) {
uat_bootp_record_t* rec = (uat_bootp_record_t *)r;
- if (rec->text) g_free(rec->text);
+ g_free(rec->text);
}
UAT_DEC_CB_DEF(uat_bootp_records, opt, uat_bootp_record_t)
diff --git a/epan/dissectors/packet-corosync-totemnet.c b/epan/dissectors/packet-corosync-totemnet.c
index a0e5df2..640b414 100644
--- a/epan/dissectors/packet-corosync-totemnet.c
+++ b/epan/dissectors/packet-corosync-totemnet.c
@@ -481,10 +481,7 @@ proto_reg_handoff_corosync_totemnet(void)
initialized = TRUE;
}
- if (corosync_totemnet_private_keys_list) {
- g_strfreev(corosync_totemnet_private_keys_list);
- corosync_totemnet_private_keys_list = NULL;
- }
+ g_strfreev(corosync_totemnet_private_keys_list);
corosync_totemnet_private_keys_list = g_strsplit(corosync_totemnet_private_keys, ";", 0);
}
diff --git a/epan/dissectors/packet-dcerpc.c b/epan/dissectors/packet-dcerpc.c
index 4d715da..d958bbc 100644
--- a/epan/dissectors/packet-dcerpc.c
+++ b/epan/dissectors/packet-dcerpc.c
@@ -1128,8 +1128,7 @@ dcerpc_fragment_free_temporary_key(gpointer ptr)
{
dcerpc_fragment_key *key = (dcerpc_fragment_key *)ptr;
- if (key)
- g_slice_free(dcerpc_fragment_key, key);
+ g_slice_free(dcerpc_fragment_key, key);
}
static void
@@ -3118,9 +3117,7 @@ dissect_deferred_pointers(packet_info *pinfo, tvbuff_t *tvb, int offset, dcerpc_
} while (found_new_pointer);
DISSECTOR_ASSERT(original_depth == current_depth);
- if (ndr_pointer_list) {
- g_slist_free_full(ndr_pointer_list, g_free);
- }
+ g_slist_free_full(ndr_pointer_list, g_free);
ndr_pointer_list = (GSList *)g_slist_nth_data(list_ndr_pointer_list, current_depth);
len_ndr_pointer_list = g_slist_length(ndr_pointer_list);
diff --git a/epan/dissectors/packet-dof.c b/epan/dissectors/packet-dof.c
index ab48f6e..2d18a06 100644
--- a/epan/dissectors/packet-dof.c
+++ b/epan/dissectors/packet-dof.c
@@ -3409,32 +3409,9 @@ static void* secmode_list_copy_cb(void *n, const void *o, size_t siz _U_)
secmode_field_t *new_rec = (secmode_field_t *)n;
const secmode_field_t *old_rec = (const secmode_field_t *)o;
- if (old_rec->domain)
- {
- new_rec->domain = g_strdup(old_rec->domain);
- }
- else
- {
- new_rec->domain = NULL;
- }
-
- if (old_rec->identity)
- {
- new_rec->identity = g_strdup(old_rec->identity);
- }
- else
- {
- new_rec->identity = NULL;
- }
-
- if (old_rec->kek)
- {
- new_rec->kek = g_strdup(old_rec->kek);
- }
- else
- {
- new_rec->kek = NULL;
- }
+ new_rec->domain = g_strdup(old_rec->domain);
+ new_rec->identity = g_strdup(old_rec->identity);
+ new_rec->kek = g_strdup(old_rec->kek);
return new_rec;
}
@@ -3443,12 +3420,9 @@ static void secmode_list_free_cb(void *r)
{
secmode_field_t *rec = (secmode_field_t *)r;
- if (rec->domain)
- g_free(rec->domain);
- if (rec->identity)
- g_free(rec->identity);
- if (rec->kek)
- g_free(rec->kek);
+ g_free(rec->domain);
+ g_free(rec->identity);
+ g_free(rec->kek);
}
@@ -3477,14 +3451,7 @@ static void* seckey_list_copy_cb(void *n, const void *o, size_t siz _U_)
seckey_field_t *new_rec = (seckey_field_t *)n;
const seckey_field_t *old_rec = (const seckey_field_t *)o;
- if (old_rec->key)
- {
- new_rec->key = g_strdup(old_rec->key);
- }
- else
- {
- new_rec->key = NULL;
- }
+ new_rec->key = g_strdup(old_rec->key);
return new_rec;
}
@@ -3493,8 +3460,7 @@ static void seckey_list_free_cb(void *r)
{
seckey_field_t *rec = (seckey_field_t *)r;
- if (rec->key)
- g_free(rec->key);
+ g_free(rec->key);
}
@@ -3557,32 +3523,9 @@ static void* identsecret_list_copy_cb(void *n, const void *o, size_t siz _U_)
identsecret_field_t *new_rec = (identsecret_field_t *)n;
const identsecret_field_t *old_rec = (const identsecret_field_t *)o;
- if (old_rec->domain)
- {
- new_rec->domain = g_strdup(old_rec->domain);
- }
- else
- {
- new_rec->domain = NULL;
- }
-
- if (old_rec->identity)
- {
- new_rec->identity = g_strdup(old_rec->identity);
- }
- else
- {
- new_rec->identity = NULL;
- }
-
- if (old_rec->secret)
- {
- new_rec->secret = g_strdup(old_rec->secret);
- }
- else
- {
- new_rec->secret = NULL;
- }
+ new_rec->domain = g_strdup(old_rec->domain);
+ new_rec->identity = g_strdup(old_rec->identity);
+ new_rec->secret = g_strdup(old_rec->secret);
return new_rec;
}
@@ -3591,12 +3534,9 @@ static void identsecret_list_free_cb(void *r)
{
identsecret_field_t *rec = (identsecret_field_t *)r;
- if (rec->domain)
- g_free(rec->domain);
- if (rec->identity)
- g_free(rec->identity);
- if (rec->secret)
- g_free(rec->secret);
+ g_free(rec->domain);
+ g_free(rec->identity);
+ g_free(rec->secret);
}
static void init_addr_port_tables(void);
diff --git a/epan/dissectors/packet-dvbci.c b/epan/dissectors/packet-dvbci.c
index cc61d3d..ec984da 100644
--- a/epan/dissectors/packet-dvbci.c
+++ b/epan/dissectors/packet-dvbci.c
@@ -6351,14 +6351,8 @@ proto_reg_handoff_dvbci(void)
tcp_dissector_table = find_dissector_table("tcp.port");
udp_dissector_table = find_dissector_table("udp.port");
- if (dvbci_sek_bin) {
- g_free(dvbci_sek_bin);
- dvbci_sek_bin = NULL;
- }
- if (dvbci_siv_bin) {
- g_free(dvbci_siv_bin);
- dvbci_siv_bin = NULL;
- }
+ g_free(dvbci_sek_bin);
+ g_free(dvbci_siv_bin);
pref_key_string_to_bin(dvbci_sek, &dvbci_sek_bin);
pref_key_string_to_bin(dvbci_siv, &dvbci_siv_bin);
}
diff --git a/epan/dissectors/packet-epl.c b/epan/dissectors/packet-epl.c
index 0147b94..162ce20 100644
--- a/epan/dissectors/packet-epl.c
+++ b/epan/dissectors/packet-epl.c
@@ -2324,9 +2324,7 @@ static void
free_key(gpointer ptr)
{
duplication_key *key = (duplication_key *)ptr;
-
- if(key)
- g_slice_free(duplication_key, key);
+ g_slice_free(duplication_key, key);
}
/* removes the table entries of a specific transfer */
diff --git a/epan/dissectors/packet-gsm_sms.c b/epan/dissectors/packet-gsm_sms.c
index 56d7efa..a12e8a2 100644
--- a/epan/dissectors/packet-gsm_sms.c
+++ b/epan/dissectors/packet-gsm_sms.c
@@ -445,9 +445,7 @@ static void
sm_fragment_free_temporary_key(gpointer ptr)
{
sm_fragment_key *key = (sm_fragment_key *)ptr;
-
- if(key)
- g_slice_free(sm_fragment_key, key);
+ g_slice_free(sm_fragment_key, key);
}
static void
diff --git a/epan/dissectors/packet-http.c b/epan/dissectors/packet-http.c
index 3fa12a6..afba5ec 100644
--- a/epan/dissectors/packet-http.c
+++ b/epan/dissectors/packet-http.c
@@ -211,17 +211,8 @@ header_fields_copy_cb(void* n, const void* o, size_t siz _U_)
header_field_t* new_rec = (header_field_t*)n;
const header_field_t* old_rec = (const header_field_t*)o;
- if (old_rec->header_name) {
- new_rec->header_name = g_strdup(old_rec->header_name);
- } else {
- new_rec->header_name = NULL;
- }
-
- if (old_rec->header_desc) {
- new_rec->header_desc = g_strdup(old_rec->header_desc);
- } else {
- new_rec->header_desc = NULL;
- }
+ new_rec->header_name = g_strdup(old_rec->header_name);
+ new_rec->header_desc = g_strdup(old_rec->header_desc);
return new_rec;
}
@@ -231,10 +222,8 @@ header_fields_free_cb(void*r)
{
header_field_t* rec = (header_field_t*)r;
- if (rec->header_name)
- g_free(rec->header_name);
- if (rec->header_desc)
- g_free(rec->header_desc);
+ g_free(rec->header_name);
+ g_free(rec->header_desc);
}
UAT_CSTRING_CB_DEF(header_fields, header_name, header_field_t)
diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c
index ed0e7d4..574cb45 100644
--- a/epan/dissectors/packet-ieee80211.c
+++ b/epan/dissectors/packet-ieee80211.c
@@ -146,11 +146,7 @@ uat_wep_key_record_copy_cb(void* n, const void* o, size_t siz _U_)
uat_wep_key_record_t* new_key = (uat_wep_key_record_t *)n;
const uat_wep_key_record_t* old_key = (const uat_wep_key_record_t *)o;
- if (old_key->string) {
- new_key->string = g_strdup(old_key->string);
- } else {
- new_key->string = NULL;
- }
+ new_key->string = g_strdup(old_key->string);
return new_key;
}
@@ -210,8 +206,7 @@ static void
uat_wep_key_record_free_cb(void*r)
{
uat_wep_key_record_t* key = (uat_wep_key_record_t *)r;
-
- if (key->string) g_free(key->string);
+ g_free(key->string);
}
UAT_VS_DEF(uat_wep_key_records, key, uat_wep_key_record_t, guint8, 0, STRING_KEY_TYPE_WEP)
diff --git a/epan/dissectors/packet-ipsec.c b/epan/dissectors/packet-ipsec.c
index 35b0523..b930639 100644
--- a/epan/dissectors/packet-ipsec.c
+++ b/epan/dissectors/packet-ipsec.c
@@ -354,13 +354,13 @@ static void* uat_esp_sa_record_copy_cb(void* n, const void* o, size_t siz _U_) {
/* Copy UAT fields */
new_rec->protocol = old_rec->protocol;
- new_rec->srcIP = (old_rec->srcIP) ? g_strdup(old_rec->srcIP) : NULL;
- new_rec->dstIP = (old_rec->dstIP) ? g_strdup(old_rec->dstIP) : NULL;
- new_rec->spi = (old_rec->spi) ? g_strdup(old_rec->spi) : NULL;
+ new_rec->srcIP = g_strdup(old_rec->srcIP);
+ new_rec->dstIP = g_strdup(old_rec->dstIP);
+ new_rec->spi = g_strdup(old_rec->spi);
new_rec->encryption_algo = old_rec->encryption_algo;
- new_rec->encryption_key_string = (old_rec->encryption_key_string) ? g_strdup(old_rec->encryption_key_string) : NULL;
+ new_rec->encryption_key_string = g_strdup(old_rec->encryption_key_string);
new_rec->authentication_algo = old_rec->authentication_algo;
- new_rec->authentication_key_string = (old_rec->authentication_key_string) ? g_strdup(old_rec->authentication_key_string) : NULL;
+ new_rec->authentication_key_string = g_strdup(old_rec->authentication_key_string);
/* Parse keys as in an update */
uat_esp_sa_record_update_cb(new_rec, NULL);
@@ -431,12 +431,7 @@ void esp_sa_record_add_from_dissector(guint8 protocol, const gchar *srcIP, const
/* Authentication */
record->authentication_algo = authentication_algo;
- if (authentication_key) {
- record->authentication_key_string = g_strdup(authentication_key);
- }
- else {
- record->authentication_key_string = NULL;
- }
+ record->authentication_key_string = g_strdup(authentication_key);
/* Parse keys */
uat_esp_sa_record_update_cb(record, NULL);
diff --git a/epan/dissectors/packet-kerberos.c b/epan/dissectors/packet-kerberos.c
index a94bbed..8cfd0c3 100644
--- a/epan/dissectors/packet-kerberos.c
+++ b/epan/dissectors/packet-kerberos.c
@@ -510,10 +510,7 @@ read_keytab_file_from_preferences(void)
return;
}
- if (last_keytab != NULL) {
- g_free(last_keytab);
- last_keytab = NULL;
- }
+ g_free(last_keytab);
last_keytab = g_strdup(keytab_filename);
read_keytab_file(last_keytab);
@@ -879,9 +876,9 @@ clear_keytab(void) {
for(ske = service_key_list; ske != NULL; ske = g_slist_next(ske)){
sk = (service_key_t *) ske->data;
if (sk) {
- g_free(sk->contents);
- g_free(sk);
- }
+ g_free(sk->contents);
+ g_free(sk);
+ }
}
g_slist_free(service_key_list);
service_key_list = NULL;
diff --git a/epan/dissectors/packet-l2tp.c b/epan/dissectors/packet-l2tp.c
index d6637a6..476f54b 100644
--- a/epan/dissectors/packet-l2tp.c
+++ b/epan/dissectors/packet-l2tp.c
@@ -3197,8 +3197,7 @@ static void l2tp_cleanup(void)
GSList *iterator = list_heads;
while (iterator) {
- if (iterator->data != NULL)
- g_slist_free((GSList *)iterator->data);
+ g_slist_free((GSList *)iterator->data);
iterator = g_slist_next(iterator);
}
diff --git a/epan/dissectors/packet-ldap.c b/epan/dissectors/packet-ldap.c
index 6756af3..6adb41d 100644
--- a/epan/dissectors/packet-ldap.c
+++ b/epan/dissectors/packet-ldap.c
@@ -729,8 +729,8 @@ attribute_types_free_cb(void*r)
{
attribute_type_t* rec = (attribute_type_t*)r;
- if (rec->attribute_type) g_free(rec->attribute_type);
- if (rec->attribute_desc) g_free(rec->attribute_desc);
+ g_free(rec->attribute_type);
+ g_free(rec->attribute_desc);
}
UAT_CSTRING_CB_DEF(attribute_types, attribute_type, attribute_type_t)
diff --git a/epan/dissectors/packet-pdcp-lte.c b/epan/dissectors/packet-pdcp-lte.c
index 5d64a96..3ef2d67 100644
--- a/epan/dissectors/packet-pdcp-lte.c
+++ b/epan/dissectors/packet-pdcp-lte.c
@@ -204,9 +204,9 @@ static void* uat_ue_keys_record_copy_cb(void* n, const void* o, size_t siz _U_)
const uat_ue_keys_record_t* old_rec = (const uat_ue_keys_record_t *)o;
new_rec->ueid = old_rec->ueid;
- new_rec->rrcCipherKeyString = (old_rec->rrcCipherKeyString) ? g_strdup(old_rec->rrcCipherKeyString) : NULL;
- new_rec->upCipherKeyString = (old_rec->upCipherKeyString) ? g_strdup(old_rec->upCipherKeyString) : NULL;
- new_rec->rrcIntegrityKeyString = (old_rec->rrcIntegrityKeyString) ? g_strdup(old_rec->rrcIntegrityKeyString) : NULL;
+ new_rec->rrcCipherKeyString = g_strdup(old_rec->rrcCipherKeyString);
+ new_rec->upCipherKeyString = g_strdup(old_rec->upCipherKeyString);
+ new_rec->rrcIntegrityKeyString = g_strdup(old_rec->rrcIntegrityKeyString);
return new_rec;
}
diff --git a/epan/dissectors/packet-reload.c b/epan/dissectors/packet-reload.c
index 0268e1f..db9fa63 100644
--- a/epan/dissectors/packet-reload.c
+++ b/epan/dissectors/packet-reload.c
@@ -748,19 +748,14 @@ static void* uat_kindid_copy_cb(void* n, const void* o, size_t siz _U_) {
kind_t * new_record = (kind_t *)n;
const kind_t* old_record = (const kind_t *)o;
- if (old_record->name) {
- new_record->name = g_strdup(old_record->name);
- } else {
- new_record->name = NULL;
- }
+ new_record->name = g_strdup(old_record->name);
return new_record;
}
static void uat_kindid_record_free_cb(void*r) {
kind_t* rec = (kind_t *)r;
-
- if (rec->name) g_free(rec->name);
+ g_free(rec->name);
}
UAT_DEC_CB_DEF(kindidlist_uats,id,kind_t)
diff --git a/epan/dissectors/packet-sctp.c b/epan/dissectors/packet-sctp.c
index 4ddd592..0d2ee5f 100644
--- a/epan/dissectors/packet-sctp.c
+++ b/epan/dissectors/packet-sctp.c
@@ -521,11 +521,7 @@ static void *sctp_chunk_type_copy_cb(void* n, const void* o, size_t siz _U_)
{
type_field_t* new_rec = (type_field_t*)n;
const type_field_t* old_rec = (const type_field_t*)o;
- if (old_rec->type_name) {
- new_rec->type_name = g_strdup(old_rec->type_name);
- } else {
- new_rec->type_name = NULL;
- }
+ new_rec->type_name = g_strdup(old_rec->type_name);
return new_rec;
}
@@ -534,7 +530,7 @@ static void
sctp_chunk_type_free_cb(void* r)
{
type_field_t* rec = (type_field_t*)r;
- if (rec->type_name) g_free(rec->type_name);
+ g_free(rec->type_name);
}
static gboolean
diff --git a/epan/dissectors/packet-sip.c b/epan/dissectors/packet-sip.c
index 022233d..429c72f 100644
--- a/epan/dissectors/packet-sip.c
+++ b/epan/dissectors/packet-sip.c
@@ -954,17 +954,8 @@ header_fields_copy_cb(void* n, const void* o, size_t siz _U_)
header_field_t* new_rec = (header_field_t*)n;
const header_field_t* old_rec = (const header_field_t*)o;
- if (old_rec->header_name) {
- new_rec->header_name = g_strdup(old_rec->header_name);
- } else {
- new_rec->header_name = NULL;
- }
-
- if (old_rec->header_desc) {
- new_rec->header_desc = g_strdup(old_rec->header_desc);
- } else {
- new_rec->header_desc = NULL;
- }
+ new_rec->header_name = g_strdup(old_rec->header_name);
+ new_rec->header_desc = g_strdup(old_rec->header_desc);
return new_rec;
}
@@ -1078,23 +1069,9 @@ authorization_users_copy_cb(void* n, const void* o, size_t siz _U_)
authorization_user_t* new_rec = (authorization_user_t*)n;
const authorization_user_t* old_rec = (const authorization_user_t*)o;
- if (old_rec->username) {
- new_rec->username = g_strdup(old_rec->username);
- } else {
- new_rec->username = NULL;
- }
-
- if (old_rec->realm) {
- new_rec->realm = g_strdup(old_rec->realm);
- } else {
- new_rec->realm = NULL;
- }
-
- if (old_rec->password) {
- new_rec->password = g_strdup(old_rec->password);
- } else {
- new_rec->password = NULL;
- }
+ new_rec->username = g_strdup(old_rec->username);
+ new_rec->realm = g_strdup(old_rec->realm);
+ new_rec->password = g_strdup(old_rec->password);
return new_rec;
}
diff --git a/epan/dissectors/packet-smb.c b/epan/dissectors/packet-smb.c
index aedc6bb..42fd1a6 100644
--- a/epan/dissectors/packet-smb.c
+++ b/epan/dissectors/packet-smb.c
@@ -17348,8 +17348,7 @@ free_hash_tables(gpointer ctarg, gpointer user_data _U_)
g_hash_table_destroy(ct->primaries);
if (ct->tid_service)
g_hash_table_destroy(ct->tid_service);
- if (ct->GSL_fid_info)
- g_slist_free(ct->GSL_fid_info);
+ g_slist_free(ct->GSL_fid_info);
g_free(ct);
}
diff --git a/epan/dissectors/packet-udp-nm.c b/epan/dissectors/packet-udp-nm.c
index 7bc94c0..f827f95 100644
--- a/epan/dissectors/packet-udp-nm.c
+++ b/epan/dissectors/packet-udp-nm.c
@@ -147,31 +147,12 @@ user_data_fields_copy_cb(void* n, const void* o, size_t siz _U_)
user_data_field_t* new_rec = (user_data_field_t*)n;
const user_data_field_t* old_rec = (const user_data_field_t*)o;
- if (old_rec->udf_name) {
- new_rec->udf_name = g_strdup(old_rec->udf_name);
- }
- else {
- new_rec->udf_name = NULL;
- }
-
- if (old_rec->udf_desc) {
- new_rec->udf_desc = g_strdup(old_rec->udf_desc);
- }
- else {
- new_rec->udf_desc = NULL;
- }
-
- new_rec->udf_offset = old_rec->udf_offset;
- new_rec->udf_length = old_rec->udf_length;
-
- new_rec->udf_mask = old_rec->udf_mask;
-
- if (old_rec->udf_value_desc) {
- new_rec->udf_value_desc = g_strdup(old_rec->udf_value_desc);
- }
- else {
- new_rec->udf_value_desc = NULL;
- }
+ new_rec->udf_name = g_strdup(old_rec->udf_name);
+ new_rec->udf_desc = g_strdup(old_rec->udf_desc);
+ new_rec->udf_offset = old_rec->udf_offset;
+ new_rec->udf_length = old_rec->udf_length;
+ new_rec->udf_mask = old_rec->udf_mask;
+ new_rec->udf_value_desc = g_strdup(old_rec->udf_value_desc);
return new_rec;
}
@@ -181,9 +162,9 @@ user_data_fields_free_cb(void*r)
{
user_data_field_t* rec = (user_data_field_t*)r;
- if (rec->udf_name) g_free(rec->udf_name);
- if (rec->udf_desc) g_free(rec->udf_desc);
- if (rec->udf_value_desc) g_free(rec->udf_value_desc);
+ g_free(rec->udf_name);
+ g_free(rec->udf_desc);
+ g_free(rec->udf_value_desc);
}
UAT_CSTRING_CB_DEF(user_data_fields, udf_name, user_data_field_t)
diff --git a/epan/dissectors/packet-umts_fp.c b/epan/dissectors/packet-umts_fp.c
index fb6a8d9..9e60cce 100644
--- a/epan/dissectors/packet-umts_fp.c
+++ b/epan/dissectors/packet-umts_fp.c
@@ -5834,8 +5834,8 @@ static void *uat_umts_fp_record_copy_cb(void *n, const void *o, size_t siz _U_)
uat_umts_fp_ep_and_ch_record_t *new_rec = (uat_umts_fp_ep_and_ch_record_t *)n;
const uat_umts_fp_ep_and_ch_record_t *old_rec = (const uat_umts_fp_ep_and_ch_record_t *)o;
- new_rec->srcIP = (old_rec->srcIP) ? g_strdup(old_rec->srcIP) : NULL;
- new_rec->dstIP = (old_rec->dstIP) ? g_strdup(old_rec->dstIP) : NULL;
+ new_rec->srcIP = g_strdup(old_rec->srcIP);
+ new_rec->dstIP = g_strdup(old_rec->dstIP);
return new_rec;
}
diff --git a/epan/dissectors/packet-zbee-nwk-gp.c b/epan/dissectors/packet-zbee-nwk-gp.c
index 4a98d8a..354a871 100644
--- a/epan/dissectors/packet-zbee-nwk-gp.c
+++ b/epan/dissectors/packet-zbee-nwk-gp.c
@@ -550,16 +550,9 @@ uat_key_record_copy_cb(void *n, const void *o, size_t siz _U_)
uat_key_record_t *new_key = (uat_key_record_t *)n;
const uat_key_record_t *old_key = (const uat_key_record_t *)o;
- if (old_key->string) {
- new_key->string = g_strdup(old_key->string);
- } else {
- new_key->string = NULL;
- }
- if (old_key->label) {
- new_key->label = g_strdup(old_key->label);
- } else {
- new_key->label = NULL;
- }
+ new_key->string = g_strdup(old_key->string);
+ new_key->label = g_strdup(old_key->label);
+
return new_key;
}
@@ -568,12 +561,8 @@ static void
uat_key_record_free_cb(void *r)
{
uat_key_record_t *key = (uat_key_record_t *)r;
- if (key->string) {
- g_free(key->string);
- }
- if (key->label) {
- g_free(key->label);
- }
+ g_free(key->string);
+ g_free(key->label);
}
/**
diff --git a/epan/dissectors/packet-zbee-security.c b/epan/dissectors/packet-zbee-security.c
index f9ffbb4..be76a86 100644
--- a/epan/dissectors/packet-zbee-security.c
+++ b/epan/dissectors/packet-zbee-security.c
@@ -139,18 +139,8 @@ static void* uat_key_record_copy_cb(void* n, const void* o, size_t siz _U_) {
uat_key_record_t* new_key = (uat_key_record_t *)n;
const uat_key_record_t* old_key = (const uat_key_record_t *)o;
- if (old_key->string) {
- new_key->string = g_strdup(old_key->string);
- } else {
- new_key->string = NULL;
- }
-
- if (old_key->label) {
- new_key->label = g_strdup(old_key->label);
- } else {
- new_key->label = NULL;
- }
-
+ new_key->string = g_strdup(old_key->string);
+ new_key->label = g_strdup(old_key->label);
new_key->byte_order = old_key->byte_order;
return new_key;
@@ -184,8 +174,8 @@ static gboolean uat_key_record_update_cb(void* r, char** err) {
static void uat_key_record_free_cb(void*r) {
uat_key_record_t* key = (uat_key_record_t *)r;
- if (key->string) g_free(key->string);
- if (key->label) g_free(key->label);
+ g_free(key->string);
+ g_free(key->label);
}
static void uat_key_record_post_update(void) {
diff --git a/epan/dtd_grammar.lemon b/epan/dtd_grammar.lemon
index 9010bf9..fe855d8 100644
--- a/epan/dtd_grammar.lemon
+++ b/epan/dtd_grammar.lemon
@@ -62,8 +62,8 @@ static GPtrArray* g_ptr_array_join(GPtrArray* a, GPtrArray* b){
%token_destructor {
(void) bd; /* Mark unused, similar to Q_UNUSED */
if ($$) {
- if ($$->text) g_free($$->text);
- if ($$->location) g_free($$->location);
+ g_free($$->text);
+ g_free($$->location);
g_free($$);
}
}
@@ -96,8 +96,7 @@ doctype ::= TAG_START DOCTYPE_KW NAME(Name) OPEN_BRACKET dtd_parts CLOSE_BRACKET
bd->proto_name = Name->text;
}
- if(bd->proto_root)
- g_free(bd->proto_root);
+ g_free(bd->proto_root);
bd->proto_root = Name->text;
diff --git a/epan/dtd_parse.l b/epan/dtd_parse.l
index 37f3bcf..4c250c2 100644
--- a/epan/dtd_parse.l
+++ b/epan/dtd_parse.l
@@ -110,10 +110,10 @@ DIAG_OFF(sign-compare)
static dtd_build_data_t* build_data;
- static void set_proto_name (gchar* val) { if(build_data->proto_name) g_free(build_data->proto_name); build_data->proto_name = g_strdup(val); }
- static void set_media_type (gchar* val) { if(build_data->media_type) g_free(build_data->media_type); build_data->media_type = g_strdup(val); }
- static void set_proto_root (gchar* val) { if(build_data->proto_root) g_free(build_data->proto_root); build_data->proto_root = g_strdup(val); }
- static void set_description (gchar* val) { if(build_data->description) g_free(build_data->description); build_data->description = g_strdup(val); }
+ static void set_proto_name (gchar* val) { g_free(build_data->proto_name); build_data->proto_name = g_strdup(val); }
+ static void set_media_type (gchar* val) { g_free(build_data->media_type); build_data->media_type = g_strdup(val); }
+ static void set_proto_root (gchar* val) { g_free(build_data->proto_root); build_data->proto_root = g_strdup(val); }
+ static void set_description (gchar* val) { g_free(build_data->description); build_data->description = g_strdup(val); }
static void set_recursive (gchar* val) { build_data->recursion = ( g_ascii_strcasecmp(val,"yes") == 0 ) ? TRUE : FALSE; }
#ifdef DEBUG_DTD_PARSER
@@ -244,7 +244,7 @@ squoted ['][^\']*[']
<XMLPI>{stop_xmlpi} BEGIN DTD;
<LOCATION>{get_location_xmlpi} {
- if(yyextra->location) g_free(yyextra->location);
+ g_free(yyextra->location);
yyextra->location = g_strdup(yytext);
BEGIN DONE;
}
@@ -421,8 +421,7 @@ extern dtd_build_data_t* dtd_parse(GString* s) {
Dtd_Parse_lex_destroy(scanner);
- if (state.location)
- g_free(state.location);
+ g_free(state.location);
DtdParseFree(state.pParser, g_free);
diff --git a/epan/dtd_preparse.l b/epan/dtd_preparse.l
index d28137c..f18e44a 100644
--- a/epan/dtd_preparse.l
+++ b/epan/dtd_preparse.l
@@ -233,7 +233,7 @@ static const gchar* replace_entity(Dtd_PreParse_scanner_state_t* state, gchar* e
const gchar* dtd_location(Dtd_PreParse_scanner_state_t* state) {
static gchar* loc = NULL;
- if (loc) g_free(loc);
+ g_free(loc);
if (!state) return NULL;
diff --git a/epan/expert.c b/epan/expert.c
index c757634..4cf909c 100644
--- a/epan/expert.c
+++ b/epan/expert.c
@@ -145,11 +145,7 @@ static void *uat_expert_copy_cb(void *n, const void *o, size_t siz _U_)
expert_level_entry_t *new_record = (expert_level_entry_t*)n;
const expert_level_entry_t *old_record = (const expert_level_entry_t *)o;
- if (old_record->field) {
- new_record->field = g_strdup(old_record->field);
- } else {
- new_record->field = NULL;
- }
+ new_record->field = g_strdup(old_record->field);
new_record->severity = old_record->severity;
@@ -160,8 +156,7 @@ static void uat_expert_free_cb(void*r)
{
expert_level_entry_t *rec = (expert_level_entry_t *)r;
- if (rec->field)
- g_free(rec->field);
+ g_free(rec->field);
}
static void uat_expert_post_update_cb(void)
diff --git a/epan/geoip_db.c b/epan/geoip_db.c
index d4de2cc..65a728d 100644
--- a/epan/geoip_db.c
+++ b/epan/geoip_db.c
@@ -165,13 +165,9 @@ static void geoip_dat_cleanup(void) {
* databases as they weren't created by GeoIP_new()
* or GeoIP_open() */
gi = g_array_index(geoip_dat_arr, GeoIP *, i);
- if (gi) {
- g_free(gi);
- }
+ g_free(gi);
gi = g_array_index(geoip_dat_arr, GeoIP *, i+1);
- if (gi) {
- g_free(gi);
- }
+ g_free(gi);
/* finally, free the array itself */
g_array_free(geoip_dat_arr, TRUE);
geoip_dat_arr = NULL;
diff --git a/epan/plugin_if.c b/epan/plugin_if.c
index 7006802..e14b9a8 100644
--- a/epan/plugin_if.c
+++ b/epan/plugin_if.c
@@ -353,8 +353,7 @@ ext_toolbar_add_entry( ext_toolbar_t * parent, ext_toolbar_item_t type, const gc
if ( value_list != NULL && g_list_length(value_list) > 0 )
entry->values = g_list_copy(value_list);
- if ( regex )
- entry->regex = g_strdup(regex);
+ entry->regex = g_strdup(regex);
entry->is_required = is_required;
entry->capture_only = capture_only;
diff --git a/epan/prefs.c b/epan/prefs.c
index 6dde102..168fa29 100644
--- a/epan/prefs.c
+++ b/epan/prefs.c
@@ -3944,9 +3944,9 @@ pre_init_prefs(void)
prefs.pr_format = PR_FMT_TEXT;
prefs.pr_dest = PR_DEST_CMD;
- if (prefs.pr_file) g_free(prefs.pr_file);
+ g_free(prefs.pr_file);
prefs.pr_file = g_strdup("wireshark.out");
- if (prefs.pr_cmd) g_free(prefs.pr_cmd);
+ g_free(prefs.pr_cmd);
prefs.pr_cmd = g_strdup("lpr");
prefs.gui_altern_colors = FALSE;
@@ -3959,14 +3959,14 @@ pre_init_prefs(void)
prefs.gui_toolbar_main_style = TB_STYLE_ICONS;
prefs.gui_toolbar_filter_style = TB_STYLE_TEXT;
/* These will be g_freed, so they must be g_mallocated. */
- if (prefs.gui_gtk2_font_name) g_free(prefs.gui_gtk2_font_name);
+ g_free(prefs.gui_gtk2_font_name);
#ifdef _WIN32
prefs.gui_gtk2_font_name = g_strdup("Lucida Console 10");
#else
prefs.gui_gtk2_font_name = g_strdup("Monospace 10");
#endif
/* We try to find the best font in the Qt code */
- if (prefs.gui_qt_font_name) g_free(prefs.gui_qt_font_name);
+ g_free(prefs.gui_qt_font_name);
prefs.gui_qt_font_name = g_strdup("");
prefs.gui_marked_fg.red = 65535;
prefs.gui_marked_fg.green = 65535;
@@ -3980,9 +3980,9 @@ pre_init_prefs(void)
prefs.gui_ignored_bg.red = 65535;
prefs.gui_ignored_bg.green = 65535;
prefs.gui_ignored_bg.blue = 65535;
- if (prefs.gui_colorized_fg) g_free(prefs.gui_colorized_fg);
+ g_free(prefs.gui_colorized_fg);
prefs.gui_colorized_fg = g_strdup("000000,000000,000000,000000,000000,000000,000000,000000,000000,000000");
- if (prefs.gui_colorized_bg) g_free(prefs.gui_colorized_bg);
+ g_free(prefs.gui_colorized_bg);
prefs.gui_colorized_bg = g_strdup("ffc0c0,ffc0ff,e0c0e0,c0c0ff,c0e0e0,c0ffff,c0ffc0,ffffc0,e0e0c0,e0e0e0");
prefs.st_client_fg.red = 32767;
prefs.st_client_fg.green = 0;
@@ -4029,7 +4029,7 @@ pre_init_prefs(void)
prefs.gui_fileopen_style = FO_STYLE_LAST_OPENED;
prefs.gui_recent_df_entries_max = 10;
prefs.gui_recent_files_count_max = 10;
- if (prefs.gui_fileopen_dir) g_free(prefs.gui_fileopen_dir);
+ g_free(prefs.gui_fileopen_dir);
prefs.gui_fileopen_dir = g_strdup(get_persdatafile_dir());
prefs.gui_fileopen_preview = 3;
prefs.gui_ask_unsaved = TRUE;
@@ -4038,13 +4038,13 @@ pre_init_prefs(void)
prefs.gui_update_enabled = TRUE;
prefs.gui_update_channel = UPDATE_CHANNEL_STABLE;
prefs.gui_update_interval = 60*60*24; /* Seconds */
- if (prefs.gui_webbrowser) g_free(prefs.gui_webbrowser);
+ g_free(prefs.gui_webbrowser);
prefs.gui_webbrowser = g_strdup("");
- if (prefs.gui_window_title) g_free(prefs.gui_window_title);
+ g_free(prefs.gui_window_title);
prefs.gui_window_title = g_strdup("");
- if (prefs.gui_prepend_window_title) g_free(prefs.gui_prepend_window_title);
+ g_free(prefs.gui_prepend_window_title);
prefs.gui_prepend_window_title = g_strdup("");
- if (prefs.gui_start_title) g_free(prefs.gui_start_title);
+ g_free(prefs.gui_start_title);
prefs.gui_start_title = g_strdup("The World's Most Popular Network Protocol Analyzer");
prefs.gui_version_placement = version_both;
prefs.gui_auto_scroll_on_expand = FALSE;
@@ -4057,7 +4057,7 @@ pre_init_prefs(void)
prefs.gui_packet_list_elide_mode = ELIDE_RIGHT;
prefs.gui_packet_list_show_related = TRUE;
prefs.gui_packet_list_show_minimap = TRUE;
- if (prefs.gui_interfaces_hide_types) g_free (prefs.gui_interfaces_hide_types);
+ g_free (prefs.gui_interfaces_hide_types);
prefs.gui_interfaces_hide_types = g_strdup("");
prefs.gui_interfaces_show_hidden = FALSE;
#ifdef HAVE_PCAP_REMOTE
diff --git a/epan/radius_dict.l b/epan/radius_dict.l
index e2dd13f..043c91e 100644
--- a/epan/radius_dict.l
+++ b/epan/radius_dict.l
@@ -787,8 +787,7 @@ gboolean radius_load_dictionary (radius_dictionary_t* d, gchar* dir, const gchar
*/
for (i = 0; i < MAX_INCLUDE_DEPTH; i++) {
- if (state.fullpaths[i])
- g_free(state.fullpaths[i]);
+ g_free(state.fullpaths[i]);
}
g_hash_table_foreach(state.dict->attrs_by_id,setup_attrs,&state);
diff --git a/epan/reassemble.c b/epan/reassemble.c
index 231f911..205bf26 100644
--- a/epan/reassemble.c
+++ b/epan/reassemble.c
@@ -130,9 +130,7 @@ static void
fragment_addresses_free_temporary_key(gpointer ptr)
{
fragment_addresses_key *key = (fragment_addresses_key *)ptr;
-
- if(key)
- g_slice_free(fragment_addresses_key, key);
+ g_slice_free(fragment_addresses_key, key);
}
static void
@@ -268,9 +266,7 @@ static void
fragment_addresses_ports_free_temporary_key(gpointer ptr)
{
fragment_addresses_ports_key *key = (fragment_addresses_ports_key *)ptr;
-
- if(key)
- g_slice_free(fragment_addresses_ports_key, key);
+ g_slice_free(fragment_addresses_ports_key, key);
}
static void
diff --git a/epan/srt_table.c b/epan/srt_table.c
index 341a350..6c98bf9 100644
--- a/epan/srt_table.c
+++ b/epan/srt_table.c
@@ -224,11 +224,7 @@ init_srt_table(const char *name, const char *short_name, GArray *srt_array, int
int i;
srt_stat_table *table = g_new(srt_stat_table, 1);
- if(filter_string){
- table->filter_string=g_strdup(filter_string);
- } else {
- table->filter_string=NULL;
- }
+ table->filter_string = g_strdup(filter_string);
table->name = name;
table->short_name = short_name;
diff --git a/epan/tap.c b/epan/tap.c
index 4760a3b..b942383 100644
--- a/epan/tap.c
+++ b/epan/tap.c
@@ -516,9 +516,7 @@ free_tap_listener(volatile tap_listener_t *tl)
{
if(!tl)
return;
- if(tl->code){
- dfilter_free(tl->code);
- }
+ dfilter_free(tl->code);
g_free(tl->fstring);
DIAG_OFF(cast-qual)
g_free((gpointer)tl);
diff --git a/epan/wslua/lrexlib_glib.c b/epan/wslua/lrexlib_glib.c
index 6426dfb..a19d31a 100644
--- a/epan/wslua/lrexlib_glib.c
+++ b/epan/wslua/lrexlib_glib.c
@@ -161,8 +161,7 @@ typedef struct {
} TGrgx;
static void minfo_free(TGrgx* ud) {
- if (ud->match_info)
- g_match_info_free (ud->match_info);
+ g_match_info_free (ud->match_info);
ud->match_info = NULL;
}
diff --git a/epan/wslua/wslua_capture_info.c b/epan/wslua/wslua_capture_info.c
index 9014552..323ca80 100644
--- a/epan/wslua/wslua_capture_info.c
+++ b/epan/wslua/wslua_capture_info.c
@@ -90,8 +90,7 @@ WSLUA_METAMETHOD CaptureInfo__tostring(lua_State* L) {
static int CaptureInfo__gc(lua_State* L) {
CaptureInfo fc = toCaptureInfo(L,1);
- if (fc)
- g_free(fc);
+ g_free(fc);
return 0;
}
@@ -484,8 +483,7 @@ static int CaptureInfoConst_set_private_table(lua_State* L) {
static int CaptureInfoConst__gc(lua_State* L) {
CaptureInfoConst fi = toCaptureInfoConst(L,1);
- if (fi)
- g_free(fi);
+ g_free(fi);
return 0;
}
diff --git a/epan/wslua/wslua_dir.c b/epan/wslua/wslua_dir.c
index 3a9d50b..5c12ca1 100644
--- a/epan/wslua/wslua_dir.c
+++ b/epan/wslua/wslua_dir.c
@@ -210,7 +210,7 @@ WSLUA_CONSTRUCTOR Dir_open(lua_State* L) {
dir = (Dir)g_malloc(sizeof(struct _wslua_dir));
dir->dir = g_dir_open(dirname_clean, 0, dir->dummy);
g_free(dirname_clean);
- dir->ext = extension ? g_strdup(extension) : NULL;
+ dir->ext = g_strdup(extension);
dir->dummy = (GError **)g_malloc(sizeof(GError *));
*(dir->dummy) = NULL;
@@ -348,9 +348,7 @@ static int Dir__gc(lua_State* L) {
}
g_free(dir->dummy);
-
- if (dir->ext) g_free(dir->ext);
-
+ g_free(dir->ext);
g_free(dir);
return 0;
diff --git a/epan/wslua/wslua_file.c b/epan/wslua/wslua_file.c
index cc11d07..79bf4f7 100644
--- a/epan/wslua/wslua_file.c
+++ b/epan/wslua/wslua_file.c
@@ -474,8 +474,7 @@ WSLUA_METAMETHOD File__tostring(lua_State* L) {
/* We free the struct we malloc'ed, but not the FILE_T/dumper in it of course */
static int File__gc(lua_State* L) {
File f = toFile(L,1);
- if (f)
- g_free(f);
+ g_free(f);
return 0;
}
diff --git a/epan/wslua/wslua_frame_info.c b/epan/wslua/wslua_frame_info.c
index 0918505..bca83fd 100644
--- a/epan/wslua/wslua_frame_info.c
+++ b/epan/wslua/wslua_frame_info.c
@@ -112,8 +112,7 @@ WSLUA_METHOD FrameInfo_read_data(lua_State* L) {
/* free the struct we created, but not the phdr/buf it points to */
static int FrameInfo__gc(lua_State* L) {
FrameInfo fi = toFrameInfo(L,1);
- if (fi)
- g_free(fi);
+ g_free(fi);
return 0;
}
@@ -322,8 +321,7 @@ WSLUA_METHOD FrameInfoConst_write_data(lua_State* L) {
/* free the struct we created, but not the wtap_pkthdr it points to */
static int FrameInfoConst__gc(lua_State* L) {
FrameInfoConst fi = toFrameInfoConst(L,1);
- if (fi)
- g_free(fi);
+ g_free(fi);
return 0;
}
diff --git a/epan/wslua/wslua_listener.c b/epan/wslua/wslua_listener.c
index 0acb279..0110774 100644
--- a/epan/wslua/wslua_listener.c
+++ b/epan/wslua/wslua_listener.c
@@ -216,7 +216,7 @@ WSLUA_CONSTRUCTOR Listener_new(lua_State* L) {
tap = (Listener)g_malloc(sizeof(struct _wslua_tap));
tap->name = g_strdup(tap_type);
- tap->filter = filter ? g_strdup(filter) : NULL;
+ tap->filter = g_strdup(filter);
tap->extractor = wslua_get_tap_extractor(tap_type);
tap->L = L;
tap->packet_ref = LUA_NOREF;
diff --git a/extcap/sshdump.c b/extcap/sshdump.c
index 575ae49..e29b515 100644
--- a/extcap/sshdump.c
+++ b/extcap/sshdump.c
@@ -177,8 +177,7 @@ static ssh_channel run_ssh_command(ssh_session sshs, const char* capture_command
g_free(quoted_iface);
g_free(quoted_filter);
g_free(cmdline);
- if (count_str)
- g_free(count_str);
+ g_free(count_str);
return channel;
}
diff --git a/extcap_parser.c b/extcap_parser.c
index 9ca8a7a..16d58a8 100644
--- a/extcap_parser.c
+++ b/extcap_parser.c
@@ -691,14 +691,10 @@ static iface_toolbar_control *extcap_parse_control_sentence(GList *control_items
}
param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_TOOLTIP));
- if (param_value != NULL) {
- control->tooltip = g_strdup(param_value);
- }
+ control->tooltip = g_strdup(param_value);
param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_PLACEHOLDER));
- if (param_value != NULL) {
- control->placeholder = g_strdup(param_value);
- }
+ control->placeholder = g_strdup(param_value);
param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_TYPE));
if (param_value == NULL) {
diff --git a/file.c b/file.c
index bc45860..0ea3e90 100644
--- a/file.c
+++ b/file.c
@@ -681,9 +681,7 @@ cf_read(capture_file *cf, gboolean reloading)
g_free(name_ptr);
/* Cleanup and release all dfilter resources */
- if (dfcode != NULL) {
- dfilter_free(dfcode);
- }
+ dfilter_free(dfcode);
epan_dissect_cleanup(&edt);
@@ -849,9 +847,7 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
cf->lnk_t = wtap_file_encap(cf->wth);
/* Cleanup and release all dfilter resources */
- if (dfcode != NULL) {
- dfilter_free(dfcode);
- }
+ dfilter_free(dfcode);
epan_dissect_cleanup(&edt);
@@ -963,9 +959,7 @@ cf_finish_tail(capture_file *cf, int *err)
}
/* Cleanup and release all dfilter resources */
- if (dfcode != NULL) {
- dfilter_free(dfcode);
- }
+ dfilter_free(dfcode);
epan_dissect_cleanup(&edt);
diff --git a/plugins/mate/mate_grammar.lemon b/plugins/mate/mate_grammar.lemon
index b788ac4..4b9ac31 100644
--- a/plugins/mate/mate_grammar.lemon
+++ b/plugins/mate/mate_grammar.lemon
@@ -187,7 +187,7 @@ static gchar* recolonize(mate_config* mc, gchar* s) {
%token_type { gchar* }
%token_destructor {
(void) mc; /* Mark unused, similar to Q_UNUSED */
- if ($$) g_free($$);
+ g_free($$);
}
%extra_argument { mate_config* mc }
diff --git a/tools/lemon/lemon.c b/tools/lemon/lemon.c
index 399196b..fdafede 100644
--- a/tools/lemon/lemon.c
+++ b/tools/lemon/lemon.c
@@ -3047,7 +3047,7 @@ PRIVATE FILE *file_open(
){
FILE *fp;
- if( lemp->outname ) free(lemp->outname);
+ free(lemp->outname);
lemp->outname = file_makename_using_basename(lemp, suffix);
fp = fopen(lemp->outname,mode);
if( fp==0 && *mode=='w' ){
@@ -3459,9 +3459,8 @@ PRIVATE FILE *tplt_open(struct lemon *lemp)
fprintf(stderr,"Can't open the template file \"%s\".\n",templatename);
lemp->errorcnt++;
}
- if (tpltname_alloc) {
- free(tpltname_alloc);
- }
+ free(tpltname_alloc);
+
return in;
}
diff --git a/ui/cli/tap-comparestat.c b/ui/cli/tap-comparestat.c
index 3fb1fbb..4d826da 100644
--- a/ui/cli/tap-comparestat.c
+++ b/ui/cli/tap-comparestat.c
@@ -565,11 +565,7 @@ comparestat_init(const char *opt_arg, void *userdata _U_)
cs->zebra_time.nsecs = 1;
cs->nr_set = g_hash_table_new(NULL, NULL);
- if (filter) {
- cs->filter = g_strdup(filter);
- } else {
- cs->filter = NULL;
- }
+ cs->filter = g_strdup(filter);
/* create a Hash to count the packets with the same ip.id */
cs->packet_set = g_hash_table_new_full(NULL, NULL, NULL, frame_info_free);
diff --git a/ui/cli/tap-httpstat.c b/ui/cli/tap-httpstat.c
index 6b7334b..2944933 100644
--- a/ui/cli/tap-httpstat.c
+++ b/ui/cli/tap-httpstat.c
@@ -293,11 +293,7 @@ httpstat_init(const char *opt_arg, void *userdata _U_)
}
sp = g_new(httpstat_t, 1);
- if (filter) {
- sp->filter = g_strdup(filter);
- } else {
- sp->filter = NULL;
- }
+ sp->filter = g_strdup(filter);
/*g_hash_table_foreach(http_status, (GHFunc)http_reset_hash_responses, NULL);*/
diff --git a/ui/cli/tap-icmpstat.c b/ui/cli/tap-icmpstat.c
index 9102cf3..db0e3ff 100644
--- a/ui/cli/tap-icmpstat.c
+++ b/ui/cli/tap-icmpstat.c
@@ -283,8 +283,7 @@ icmpstat_init(const char *opt_arg, void *userdata _U_)
memset(icmpstat, 0, sizeof(icmpstat_t));
icmpstat->min_msecs = 1.0 * G_MAXUINT;
- if (filter)
- icmpstat->filter = g_strdup(filter);
+ icmpstat->filter = g_strdup(filter);
/* It is possible to create a filter and attach it to the callbacks. Then the
* callbacks would only be invoked if the filter matched.
@@ -300,8 +299,7 @@ icmpstat_init(const char *opt_arg, void *userdata _U_)
TL_REQUIRES_NOTHING, icmpstat_reset, icmpstat_packet, icmpstat_draw);
if (error_string) {
/* error, we failed to attach to the tap. clean up */
- if (icmpstat->filter)
- g_free(icmpstat->filter);
+ g_free(icmpstat->filter);
g_free(icmpstat);
fprintf(stderr, "tshark: Couldn't register icmp,srt tap: %s\n",
diff --git a/ui/cli/tap-icmpv6stat.c b/ui/cli/tap-icmpv6stat.c
index 6c2a59d..4a7bf16 100644
--- a/ui/cli/tap-icmpv6stat.c
+++ b/ui/cli/tap-icmpv6stat.c
@@ -284,8 +284,7 @@ icmpv6stat_init(const char *opt_arg, void *userdata _U_)
memset(icmpv6stat, 0, sizeof(icmpv6stat_t));
icmpv6stat->min_msecs = 1.0 * G_MAXUINT;
- if (filter)
- icmpv6stat->filter = g_strdup(filter);
+ icmpv6stat->filter = g_strdup(filter);
/* It is possible to create a filter and attach it to the callbacks. Then the
* callbacks would only be invoked if the filter matched.
@@ -301,8 +300,7 @@ icmpv6stat_init(const char *opt_arg, void *userdata _U_)
TL_REQUIRES_NOTHING, icmpv6stat_reset, icmpv6stat_packet, icmpv6stat_draw);
if (error_string) {
/* error, we failed to attach to the tap. clean up */
- if (icmpv6stat->filter)
- g_free(icmpv6stat->filter);
+ g_free(icmpv6stat->filter);
g_free(icmpv6stat);
fprintf(stderr, "tshark: Couldn't register icmpv6,srt tap: %s\n",
diff --git a/ui/cli/tap-iostat.c b/ui/cli/tap-iostat.c
index d3bc760..b9035a3 100644
--- a/ui/cli/tap-iostat.c
+++ b/ui/cli/tap-iostat.c
@@ -1202,8 +1202,7 @@ iostat_draw(void *arg)
}
if (last_row) {
- if (fmt)
- g_free(fmt);
+ g_free(fmt);
} else {
item_in_column[j] = item_in_column[j]->next;
}
diff --git a/ui/cli/tap-protohierstat.c b/ui/cli/tap-protohierstat.c
index 6fe4096..3ef2c56 100644
--- a/ui/cli/tap-protohierstat.c
+++ b/ui/cli/tap-protohierstat.c
@@ -184,12 +184,7 @@ protohierstat_init(const char *opt_arg, void *userdata _U_)
}
rs = new_phs_t(NULL);
-
- if (filter) {
- rs->filter = g_strdup(filter);
- } else {
- rs->filter = NULL;
- }
+ rs->filter = g_strdup(filter);
error_string = register_tap_listener("frame", rs, filter, TL_REQUIRES_PROTO_TREE, NULL, protohierstat_packet, protohierstat_draw);
if (error_string) {
diff --git a/ui/cli/tap-rtspstat.c b/ui/cli/tap-rtspstat.c
index 20d15e4..163fe12 100644
--- a/ui/cli/tap-rtspstat.c
+++ b/ui/cli/tap-rtspstat.c
@@ -245,11 +245,7 @@ rtspstat_init(const char *opt_arg, void *userdata _U_)
}
sp = (rtspstat_t *)g_malloc( sizeof(rtspstat_t) );
- if (filter) {
- sp->filter = g_strdup(filter);
- } else {
- sp->filter = NULL;
- }
+ sp->filter = g_strdup(filter);
/*g_hash_table_foreach( rtsp_status, (GHFunc)rtsp_reset_hash_responses, NULL);*/
diff --git a/ui/cli/tap-sipstat.c b/ui/cli/tap-sipstat.c
index c1902f10..75859c1 100644
--- a/ui/cli/tap-sipstat.c
+++ b/ui/cli/tap-sipstat.c
@@ -422,11 +422,7 @@ sipstat_init(const char *opt_arg, void *userdata _U_)
}
sp = g_new0(sipstat_t, 1);
- if (filter) {
- sp->filter = g_strdup(filter);
- } else {
- sp->filter = NULL;
- }
+ sp->filter = g_strdup(filter);
/*g_hash_table_foreach( sip_status, (GHFunc)sip_reset_hash_responses, NULL);*/
diff --git a/ui/cli/tap-wspstat.c b/ui/cli/tap-wspstat.c
index b2a0ba4..754eeaf 100644
--- a/ui/cli/tap-wspstat.c
+++ b/ui/cli/tap-wspstat.c
@@ -245,11 +245,8 @@ wspstat_init(const char *opt_arg, void *userdata _U_)
}
sp->num_pdus = 16;
sp->pdu_stats = g_new(wsp_pdu_t, (sp->num_pdus+1));
- if (filter) {
- sp->filter = g_strdup(filter);
- } else {
- sp->filter = NULL;
- }
+ sp->filter = g_strdup(filter);
+
for (i=0; i<sp->num_pdus; i++)
{
sp->pdu_stats[i].packets = 0;
diff --git a/ui/gtk/airpcap_gui_utils.c b/ui/gtk/airpcap_gui_utils.c
index c1341ed..8e46b34 100644
--- a/ui/gtk/airpcap_gui_utils.c
+++ b/ui/gtk/airpcap_gui_utils.c
@@ -510,8 +510,7 @@ write_wlan_driver_wep_keys_to_registry(GList* key_list)
/*
* Free the old adapter key collection!
*/
- if (fake_info_if->keysCollection != NULL)
- g_free(fake_info_if->keysCollection);
+ g_free(fake_info_if->keysCollection);
/*
* Set this collection ad the new one
@@ -647,8 +646,7 @@ write_wlan_wep_keys_to_registry(airpcap_if_info_t* info_if, GList* key_list)
/*
* Free the old adapter key collection!
*/
- if (info_if->keysCollection != NULL)
- g_free(info_if->keysCollection);
+ g_free(info_if->keysCollection);
/*
* Set this collection ad the new one
@@ -1028,7 +1026,7 @@ get_airpcap_driver_keys(void)
/* KEY */
tmp_key = airpcap_get_key_string(fake_info_if->keysCollection->Keys[i]);
new_key->key = g_string_new(tmp_key);
- if (tmp_key != NULL) g_free(tmp_key);
+ g_free(tmp_key);
/* BITS */
new_key->bits = (guint) new_key->key->len *4; /* every char is 4 bits in WEP keys (it is an hexadecimal number) */
@@ -1243,7 +1241,7 @@ free_key_list(GList *list)
g_string_free(curr_key->key, TRUE);
if (curr_key->ssid != NULL)
- g_byte_array_free(curr_key->ssid, TRUE);
+ g_byte_array_free(curr_key->ssid, TRUE);
/* free the decryption_key_t structure*/
g_free(curr_key);
@@ -2077,8 +2075,7 @@ airpcap_add_keys_to_driver_from_list(GtkListStore *key_list_store, airpcap_if_in
/*
* Free the old adapter key collection!
*/
- if (fake_if_info->keysCollection != NULL)
- g_free(fake_if_info->keysCollection);
+ g_free(fake_if_info->keysCollection);
/*
* Set this collection ad the new one
diff --git a/ui/gtk/capture_dlg.c b/ui/gtk/capture_dlg.c
index f1e66cb..5f15166 100644
--- a/ui/gtk/capture_dlg.c
+++ b/ui/gtk/capture_dlg.c
@@ -2480,8 +2480,7 @@ save_options_cb(GtkWidget *win _U_, gpointer user_data _U_)
device.snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
}
filter_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(filter_cm));
- if (device.cfilter)
- g_free(device.cfilter);
+ g_free(device.cfilter);
g_assert(filter_text != NULL);
device.cfilter = filter_text;
@@ -4523,9 +4522,7 @@ update_properties_all(void)
if (strcmp(device.cfilter, filter_str) != 0) {
/* No, so not all selected interfaces have the same capture
filter. */
- if (filter_str != NULL) {
- g_free(filter_str);
- }
+ g_free(filter_str);
filter_str = NULL;
filter_all = FALSE;
}
@@ -5445,11 +5442,8 @@ capture_start_cb(GtkWidget *w _U_, gpointer d _U_)
the same as the one the other interfaces we've looked
at have? */
if (strcmp(interface_opts.cfilter, filter_str) != 0) {
- /* No, so not all selected interfaces have the same capture
- filter. */
- if (filter_str != NULL) {
- g_free(filter_str);
- }
+ /* No, so not all selected interfaces have the same capture filter. */
+ g_free(filter_str);
filter_str = NULL;
}
}
diff --git a/ui/gtk/capture_file_dlg.c b/ui/gtk/capture_file_dlg.c
index c1c5d7a..5738f23 100644
--- a/ui/gtk/capture_file_dlg.c
+++ b/ui/gtk/capture_file_dlg.c
@@ -930,8 +930,7 @@ file_merge_cmd(GtkWidget *w _U_)
}
if (merge_status != CF_OK) {
- if (rfcode != NULL)
- dfilter_free(rfcode);
+ dfilter_free(rfcode);
g_free(tmpname);
continue;
}
@@ -941,8 +940,7 @@ file_merge_cmd(GtkWidget *w _U_)
/* Try to open the merged capture file. This closes the current file if it succeeds. */
if (cf_open(&cfile, tmpname, WTAP_TYPE_AUTO, TRUE /* temporary file */, &err) != CF_OK) {
/* We couldn't open it; fail. */
- if (rfcode != NULL)
- dfilter_free(rfcode);
+ dfilter_free(rfcode);
g_free(tmpname);
g_string_free(file_name, TRUE);
g_string_free(display_filter, TRUE);
diff --git a/ui/gtk/color_edit_dlg.c b/ui/gtk/color_edit_dlg.c
index 66a4563..8713af5 100644
--- a/ui/gtk/color_edit_dlg.c
+++ b/ui/gtk/color_edit_dlg.c
@@ -448,9 +448,7 @@ color_edit_dlg_ok_cb(GtkWidget *w _U_, gpointer user_data)
1, filter_text, 2, fg_str, 3, bg_str,
4, filter_disabled, -1);
- if (colorf->c_colorfilter != NULL) {
- dfilter_free(colorf->c_colorfilter);
- }
+ dfilter_free(colorf->c_colorfilter);
colorf->c_colorfilter = compiled_filter;
/* Destroy the dialog box. */
diff --git a/ui/gtk/extcap_gtk.c b/ui/gtk/extcap_gtk.c
index cdd7946..0df5526 100644
--- a/ui/gtk/extcap_gtk.c
+++ b/ui/gtk/extcap_gtk.c
@@ -741,8 +741,7 @@ GtkWidget *extcap_create_gtk_multicheckwidget(extcap_arg *argument,
EXTCAP_GTK_MULTI_COL_ACTIVATABLE, v->enabled, -1);
}
- if (prev_list != NULL)
- g_strfreev(prev_list);
+ g_strfreev(prev_list);
renderer = gtk_cell_renderer_text_new();
togglerenderer = gtk_cell_renderer_toggle_new();
@@ -866,8 +865,7 @@ GSList *extcap_populate_gtk_vbox(GList *arguments, GtkWidget *vbox,
gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.1f);
item = extcap_create_gtk_fileselect(arg_iter, prev_map, default_str);
- if (default_str != NULL)
- g_free(default_str);
+ g_free(default_str);
break;
case EXTCAP_ARG_TIMESTAMP:
default_str = NULL;
diff --git a/ui/gtk/funnel_stat.c b/ui/gtk/funnel_stat.c
index 29e36bc..d9c3f2f 100644
--- a/ui/gtk/funnel_stat.c
+++ b/ui/gtk/funnel_stat.c
@@ -516,7 +516,7 @@ static gboolean funnel_open_file(funnel_ops_id_t *ops_id _U_, const char* fname,
/* This closes the current file if it succeeds. */
if (cf_open(&cfile, fname, WTAP_TYPE_AUTO, FALSE, &err) != CF_OK) {
*err_str = g_strdup(g_strerror(err));
- if (rfcode != NULL) dfilter_free(rfcode);
+ dfilter_free(rfcode);
return FALSE;
}
diff --git a/ui/gtk/io_stat.c b/ui/gtk/io_stat.c
index 2f16332..a5afd6f 100644
--- a/ui/gtk/io_stat.c
+++ b/ui/gtk/io_stat.c
@@ -1826,8 +1826,7 @@ filter_callback(GtkWidget *widget, gpointer user_data)
io_stat_redraw(gio->io);
return;
}
- if (dfilter != NULL)
- dfilter_free(dfilter);
+ dfilter_free(dfilter);
/* ok, we have a valid filter and the graph is active.
first just try to delete any previous settings and then apply
diff --git a/ui/gtk/mac_lte_stat_dlg.c b/ui/gtk/mac_lte_stat_dlg.c
index 5bb9472..6986a53 100644
--- a/ui/gtk/mac_lte_stat_dlg.c
+++ b/ui/gtk/mac_lte_stat_dlg.c
@@ -1052,12 +1052,7 @@ static void gtk_mac_lte_stat_init(const char *opt_arg, void *userdata _U_)
hs->ep_list = NULL;
/* Copy filter (so can be used for window title at reset) */
- if (filter) {
- hs->filter = g_strdup(filter);
- }
- else {
- hs->filter = NULL;
- }
+ hs->filter = g_strdup(filter);
/* Set title */
display_name = cf_get_display_name(&cfile);
diff --git a/ui/gtk/main.c b/ui/gtk/main.c
index 1343ef2..9777d44 100644
--- a/ui/gtk/main.c
+++ b/ui/gtk/main.c
@@ -2584,8 +2584,7 @@ main(int argc, char *argv[])
g_free(global_commandline_info.cf_name);
global_commandline_info.cf_name = NULL;
} else {
- if (rfcode != NULL)
- dfilter_free(rfcode);
+ dfilter_free(rfcode);
cfile.rfcode = NULL;
show_main_window(FALSE);
/* Don't call check_and_warn_user_startup(): we did it above */
diff --git a/ui/gtk/main_welcome.c b/ui/gtk/main_welcome.c
index 3ad0729..202ece3 100644
--- a/ui/gtk/main_welcome.c
+++ b/ui/gtk/main_welcome.c
@@ -1123,8 +1123,7 @@ fill_capture_box(void)
label_text = g_strdup_printf("Error = %d; this \"can't happen\".", error);
break;
}
- if (err_str != NULL)
- g_free(err_str);
+ g_free(err_str);
w = gtk_label_new(label_text);
gtk_label_set_markup(GTK_LABEL(w), label_text);
gtk_label_set_line_wrap(GTK_LABEL(w), TRUE);
diff --git a/ui/gtk/prefs_capture.c b/ui/gtk/prefs_capture.c
index 4f938b655..03a78a5 100644
--- a/ui/gtk/prefs_capture.c
+++ b/ui/gtk/prefs_capture.c
@@ -273,10 +273,6 @@ capture_prefs_fetch(GtkWidget *w)
auto_scroll_cb = (GtkWidget *)g_object_get_data(G_OBJECT(w), AUTO_SCROLL_KEY);
show_info_cb = (GtkWidget *)g_object_get_data(G_OBJECT(w), SHOW_INFO_KEY);
- if (prefs.capture_device != NULL) {
- g_free(prefs.capture_device);
- prefs.capture_device = NULL;
- }
if_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(if_cbxe)))));
/* Strip out white space */
g_strstrip(if_text);
@@ -291,6 +287,8 @@ capture_prefs_fetch(GtkWidget *w)
/* Ensure capture device is not NULL */
if (if_text == NULL)
if_text = g_strdup("");
+
+ g_free(prefs.capture_device);
prefs.capture_device = if_text;
prefs.capture_prom_mode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(promisc_cb));
diff --git a/ui/gtk/rlc_lte_stat_dlg.c b/ui/gtk/rlc_lte_stat_dlg.c
index 16939fa..fde6cf5 100644
--- a/ui/gtk/rlc_lte_stat_dlg.c
+++ b/ui/gtk/rlc_lte_stat_dlg.c
@@ -1308,13 +1308,7 @@ static void gtk_rlc_lte_stat_init(const char *opt_arg, void *userdata _U_)
hs->ep_list = NULL;
/* Copy filter (so can be used for window title at reset) */
- if (filter) {
- hs->filter = g_strdup(filter);
- }
- else {
- hs->filter = NULL;
- }
-
+ hs->filter = g_strdup(filter);
/* Set title */
display_name = cf_get_display_name(&cfile);
diff --git a/ui/iface_lists.c b/ui/iface_lists.c
index a989317..a1b6674 100644
--- a/ui/iface_lists.c
+++ b/ui/iface_lists.c
@@ -176,11 +176,7 @@ scan_local_interfaces(void (*update_cb)(void))
continue;
}
device.name = g_strdup(if_info->name);
- if (if_info->friendly_name != NULL) {
- device.friendly_name = g_strdup(if_info->friendly_name);
- } else {
- device.friendly_name = NULL;
- }
+ device.friendly_name = g_strdup(if_info->friendly_name);
device.hidden = FALSE;
memset(&temp, 0, sizeof(temp));
temp.name = g_strdup(if_info->name);
diff --git a/ui/language.c b/ui/language.c
index 2bc721a..d8da1fe 100644
--- a/ui/language.c
+++ b/ui/language.c
@@ -46,8 +46,7 @@ read_language_pref(gchar *key, const gchar *value,
void *private_data _U_, gboolean return_range_errors _U_)
{
if (strcmp(key, LANGUAGE_PREF_LANGUAGE) == 0) {
- if (language)
- g_free(language);
+ g_free(language);
/*
* For backwards compatibility, treat "auto" as meaning "use the
* system language".
diff --git a/ui/proto_hier_stats.c b/ui/proto_hier_stats.c
index 3275e16..5722a26 100644
--- a/ui/proto_hier_stats.c
+++ b/ui/proto_hier_stats.c
@@ -345,10 +345,7 @@ static gboolean
stat_node_free(GNode *node, gpointer data _U_)
{
ph_stats_node_t *stats = (ph_stats_node_t *)node->data;
-
- if (stats) {
- g_free(stats);
- }
+ g_free(stats);
return FALSE;
}
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index 380ef7e..0336b27 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -1276,8 +1276,7 @@ void MainWindow::mergeCaptureFile()
g_free(in_filenames[1]);
if (merge_status != CF_OK) {
- if (rfcode != NULL)
- dfilter_free(rfcode);
+ dfilter_free(rfcode);
g_free(tmpname);
continue;
}
@@ -1289,8 +1288,7 @@ void MainWindow::mergeCaptureFile()
if (cf_open(CaptureFile::globalCapFile(), tmpname, WTAP_TYPE_AUTO, TRUE /* temporary file */, &err) != CF_OK) {
/* We couldn't open it; fail. */
CaptureFile::globalCapFile()->window = NULL;
- if (rfcode != NULL)
- dfilter_free(rfcode);
+ dfilter_free(rfcode);
g_free(tmpname);
return;
}
diff --git a/ui/qt/main_window_preferences_frame.cpp b/ui/qt/main_window_preferences_frame.cpp
index 3a40e70..3bd0eac 100644
--- a/ui/qt/main_window_preferences_frame.cpp
+++ b/ui/qt/main_window_preferences_frame.cpp
@@ -226,8 +226,7 @@ void MainWindowPreferencesFrame::on_mainToolbarComboBox_currentIndexChanged(int
void MainWindowPreferencesFrame::on_languageComboBox_currentIndexChanged(int index)
{
- if (language)
- g_free(language);
+ g_free(language);
language = g_strdup(ui->languageComboBox->itemData(index).toString().toStdString().c_str());
}
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index c71b116..518bd39 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -250,8 +250,7 @@ bool MainWindow::openCaptureFile(QString cf_path, QString read_filter, unsigned
dismiss the alert box popped up for the open error,
try again. */
CaptureFile::globalCapFile()->window = NULL;
- if (rfcode != NULL)
- dfilter_free(rfcode);
+ dfilter_free(rfcode);
cf_path.clear();
continue;
}
diff --git a/ui/recent.c b/ui/recent.c
index ce3ab48..7aab5e3 100644
--- a/ui/recent.c
+++ b/ui/recent.c
@@ -1123,9 +1123,7 @@ read_set_recent_pair_static(gchar *key, const gchar *value,
}
prefs_clear_string_list(col_l);
} else if (strcmp(key, RECENT_GUI_FILEOPEN_REMEMBERED_DIR) == 0) {
- if (recent.gui_fileopen_remembered_dir) {
- g_free (recent.gui_fileopen_remembered_dir);
- }
+ g_free(recent.gui_fileopen_remembered_dir);
recent.gui_fileopen_remembered_dir = g_strdup(value);
} else if (strcmp(key, RECENT_GUI_TOOLBAR_SHOW) == 0) {
recent.gui_additional_toolbars = prefs_get_string_list(value);
@@ -1446,11 +1444,7 @@ recent_set_column_width(gint col, gint width)
if (!found) {
col_w = (col_width_data *) g_malloc(sizeof(col_width_data));
col_w->cfmt = cfmt;
- if (cfield) {
- col_w->cfield = g_strdup(cfield);
- } else {
- col_w->cfield = NULL;
- }
+ col_w->cfield = g_strdup(cfield);
col_w->width = width;
col_w->xalign = COLUMN_XALIGN_DEFAULT;
recent.col_width_list = g_list_append(recent.col_width_list, col_w);
@@ -1514,11 +1508,7 @@ recent_set_column_xalign(gint col, gchar xalign)
if (!found) {
col_w = (col_width_data *) g_malloc(sizeof(col_width_data));
col_w->cfmt = cfmt;
- if (cfield) {
- col_w->cfield = g_strdup(cfield);
- } else {
- col_w->cfield = NULL;
- }
+ col_w->cfield = g_strdup(cfield);
col_w->width = 40;
col_w->xalign = xalign;
recent.col_width_list = g_list_append(recent.col_width_list, col_w);
diff --git a/ui/voip_calls.c b/ui/voip_calls.c
index afa816d..4ab23e1 100644
--- a/ui/voip_calls.c
+++ b/ui/voip_calls.c
@@ -1377,25 +1377,21 @@ isup_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt,
callsinfo->call_active_state = VOIP_ACTIVE;
callsinfo->call_state = VOIP_UNKNOWN;
copy_address(&(callsinfo->initial_speaker),&(pinfo->src));
- callsinfo->selected=FALSE;
- callsinfo->start_fd=pinfo->fd;
- callsinfo->start_rel_ts=pinfo->rel_ts;
- callsinfo->protocol=VOIP_ISUP;
- if (pi->calling_number!=NULL) {
- callsinfo->from_identity=g_strdup(pi->calling_number);
- }
- if (pi->called_number!=NULL) {
- callsinfo->to_identity=g_strdup(pi->called_number);
- }
- callsinfo->prot_info=g_malloc(sizeof(isup_calls_info_t));
+ callsinfo->selected = FALSE;
+ callsinfo->start_fd = pinfo->fd;
+ callsinfo->start_rel_ts = pinfo->rel_ts;
+ callsinfo->protocol = VOIP_ISUP;
+ callsinfo->from_identity = g_strdup(pi->calling_number);
+ callsinfo->to_identity = g_strdup(pi->called_number);
+ callsinfo->prot_info = g_malloc(sizeof(isup_calls_info_t));
callsinfo->free_prot_info = g_free;
- tmp_isupinfo=(isup_calls_info_t *)callsinfo->prot_info;
- tmp_isupinfo->opc = tapinfo->mtp3_opc;
- tmp_isupinfo->dpc = tapinfo->mtp3_dpc;
- tmp_isupinfo->ni = tapinfo->mtp3_ni;
- tmp_isupinfo->cic = pi->circuit_id;
- callsinfo->npackets = 0;
- callsinfo->call_num = tapinfo->ncalls++;
+ tmp_isupinfo = (isup_calls_info_t *)callsinfo->prot_info;
+ tmp_isupinfo->opc = tapinfo->mtp3_opc;
+ tmp_isupinfo->dpc = tapinfo->mtp3_dpc;
+ tmp_isupinfo->ni = tapinfo->mtp3_ni;
+ tmp_isupinfo->cic = pi->circuit_id;
+ callsinfo->npackets = 0;
+ callsinfo->call_num = tapinfo->ncalls++;
g_queue_push_tail(tapinfo->callsinfos, callsinfo);
}
diff --git a/ui/win32/file_dlg_win32.c b/ui/win32/file_dlg_win32.c
index de5fd9c..84b0174 100644
--- a/ui/win32/file_dlg_win32.c
+++ b/ui/win32/file_dlg_win32.c
@@ -1323,8 +1323,7 @@ filter_tb_syntax_check(HWND hwnd, TCHAR *filter_text) {
SendMessage(hwnd, EM_SETBKGNDCOLOR, (WPARAM) 1, COLOR_WINDOW);
return;
} else if (dfilter_compile(utf_16to8(strval), &dfp, NULL)) { /* colorize filter string entry */
- if (dfp != NULL)
- dfilter_free(dfp);
+ dfilter_free(dfp);
/* Valid (light green) */
SendMessage(hwnd, EM_SETBKGNDCOLOR, 0, RGB(0xe4, 0xff, 0xc7)); /* tango_chameleon_1 */
} else {
@@ -1332,7 +1331,7 @@ filter_tb_syntax_check(HWND hwnd, TCHAR *filter_text) {
SendMessage(hwnd, EM_SETBKGNDCOLOR, 0, RGB(0xff, 0xcc, 0xcc)); /* tango_scarlet_red_1 */
}
- if (strval) g_free(strval);
+ g_free(strval);
}
@@ -1365,8 +1364,7 @@ open_file_hook_proc(HWND of_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
case CDN_FILEOK:
/* Fetch the read filter */
cur_ctrl = GetDlgItem(of_hwnd, EWFD_FILTER_EDIT);
- if (g_dfilter_str)
- g_free(g_dfilter_str);
+ g_free(g_dfilter_str);
g_dfilter_str = filter_tb_get(cur_ctrl);
cur_ctrl = GetDlgItem(of_hwnd, EWFD_FORMAT_TYPE);
@@ -2220,8 +2218,7 @@ merge_file_hook_proc(HWND mf_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
case CDN_FILEOK:
/* Fetch the read filter */
cur_ctrl = GetDlgItem(mf_hwnd, EWFD_FILTER_EDIT);
- if (g_dfilter_str)
- g_free(g_dfilter_str);
+ g_free(g_dfilter_str);
g_dfilter_str = filter_tb_get(cur_ctrl);
cur_ctrl = GetDlgItem(mf_hwnd, EWFD_MERGE_CHRONO_BTN);
diff --git a/wiretap/catapult_dct2000.c b/wiretap/catapult_dct2000.c
index 04013d5..22b051b 100644
--- a/wiretap/catapult_dct2000.c
+++ b/wiretap/catapult_dct2000.c
@@ -1670,9 +1670,7 @@ free_line_prefix_info(gpointer key, gpointer value,
/* Free the strings inside */
g_free(info->before_time);
- if (info->after_time) {
- g_free(info->after_time);
- }
+ g_free(info->after_time);
/* And the structure itself */
g_free(info);
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index ce9195f..8740756 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -523,8 +523,7 @@ wtap_deregister_open_info(const gchar *name)
for (i = 0; i < open_info_arr->len; i++) {
if (open_routines[i].name && strcmp(open_routines[i].name, name) == 0) {
- if (open_routines[i].extensions_set != NULL)
- g_strfreev(open_routines[i].extensions_set);
+ g_strfreev(open_routines[i].extensions_set);
open_info_arr = g_array_remove_index(open_info_arr, i);
set_heuristic_routine();
return;
@@ -2590,8 +2589,7 @@ wtap_dump_close(wtap_dumper *wdh, int *err)
}
ret = FALSE;
}
- if (wdh->priv != NULL)
- g_free(wdh->priv);
+ g_free(wdh->priv);
wtap_block_array_free(wdh->interface_data);
g_free(wdh);
return ret;
diff --git a/wiretap/ngsniffer.c b/wiretap/ngsniffer.c
index 83cf880..199c059 100644
--- a/wiretap/ngsniffer.c
+++ b/wiretap/ngsniffer.c
@@ -1938,12 +1938,9 @@ ngsniffer_close(wtap *wth)
ngsniffer_t *ngsniffer;
ngsniffer = (ngsniffer_t *)wth->priv;
- if (ngsniffer->rand.buf != NULL)
- g_free(ngsniffer->rand.buf);
- if (ngsniffer->first_blob != NULL) {
- g_list_foreach(ngsniffer->first_blob, free_blob, NULL);
- g_list_free(ngsniffer->first_blob);
- }
+ g_free(ngsniffer->rand.buf);
+ g_list_foreach(ngsniffer->first_blob, free_blob, NULL);
+ g_list_free(ngsniffer->first_blob);
}
typedef struct {
diff --git a/wiretap/pppdump.c b/wiretap/pppdump.c
index ca6177e..9f0ef0f 100644
--- a/wiretap/pppdump.c
+++ b/wiretap/pppdump.c
@@ -354,8 +354,7 @@ pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
if (!collate(state, wth->fh, err, err_info, buf, &num_bytes, &direction,
pid, 0)) {
- if (pid != NULL)
- g_free(pid);
+ g_free(pid);
return FALSE;
}
diff --git a/wiretap/visual.c b/wiretap/visual.c
index 240e10e..90e607e 100644
--- a/wiretap/visual.c
+++ b/wiretap/visual.c
@@ -852,8 +852,7 @@ static void visual_dump_free(wtap_dumper *wdh)
if (visual)
{
/* Free the index table memory. */
- if (visual->index_table)
- g_free(visual->index_table);
+ g_free(visual->index_table);
}
}
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index 4354600..4d81d98 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -1236,8 +1236,7 @@ wtap_close(wtap *wth)
if (wth->random_fh != NULL)
file_close(wth->random_fh);
- if (wth->priv != NULL)
- g_free(wth->priv);
+ g_free(wth->priv);
if (wth->fast_seek != NULL) {
g_ptr_array_foreach(wth->fast_seek, g_fast_seek_item_free, NULL);
diff --git a/wsutil/interface.c b/wsutil/interface.c
index 11104f1..45921cc 100644
--- a/wsutil/interface.c
+++ b/wsutil/interface.c
@@ -154,8 +154,7 @@ static GSList* local_interfaces_to_list_win(void)
pCurrAddresses = pCurrAddresses->Next;
}
end:
- if (pAddresses)
- g_free(pAddresses);
+ g_free(pAddresses);
return interfaces;
}