aboutsummaryrefslogtreecommitdiffstats
path: root/ui/cli
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 /ui/cli
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>
Diffstat (limited to 'ui/cli')
-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
9 files changed, 12 insertions, 41 deletions
diff --git a/ui/cli/tap-comparestat.c b/ui/cli/tap-comparestat.c
index 3fb1fbb109..4d826da89e 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 6b7334b223..294493348e 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 9102cf32fe..db0e3ffda3 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 6c2a59d0d7..4a7bf161d0 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 d3bc760e76..b9035a3e73 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 6fe4096a69..3ef2c56814 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 20d15e4640..163fe1271c 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 c1902f1060..75859c13c5 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 b2a0ba46a8..754eeaf3a0 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;