diff options
author | Ahmad Fatoum <ahmad@a3f.at> | 2017-08-26 10:30:47 +0200 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2017-10-15 12:38:51 +0000 |
commit | 9d49e1316689ae05d31efc866f04ac12cd051085 (patch) | |
tree | f51b835fd490fe6be49268a114014f597f47c252 /ui/gtk/airpcap_gui_utils.c | |
parent | 37ccb77a1ab845075465c2d86eea9e8e21abc273 (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>
Diffstat (limited to 'ui/gtk/airpcap_gui_utils.c')
-rw-r--r-- | ui/gtk/airpcap_gui_utils.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/ui/gtk/airpcap_gui_utils.c b/ui/gtk/airpcap_gui_utils.c index c1341eda32..8e46b347b3 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 |