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/voip_calls.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/voip_calls.c')
-rw-r--r-- | ui/voip_calls.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/ui/voip_calls.c b/ui/voip_calls.c index afa816d356..4ab23e18ef 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); } |