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 /epan/dissectors/packet-zbee-nwk-gp.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 'epan/dissectors/packet-zbee-nwk-gp.c')
-rw-r--r-- | epan/dissectors/packet-zbee-nwk-gp.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/epan/dissectors/packet-zbee-nwk-gp.c b/epan/dissectors/packet-zbee-nwk-gp.c index 4a98d8a9df..354a87118b 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); } /** |