summaryrefslogtreecommitdiff
path: root/tc
diff options
context:
space:
mode:
authorStephen Hemminger <stephen@networkplumber.org>2023-05-10 08:16:40 -0700
committerStephen Hemminger <stephen@networkplumber.org>2023-05-10 08:16:40 -0700
commitcfb60ba56bf35f28505e7ff67f1efd9bd3e1d5c6 (patch)
treed95beebba6ec05f33ffefbbcb9f9cd1e5ace5a6e /tc
parenteb64e268354ab68b4737187200b8769ae158a455 (diff)
downloadiproute2-cfb60ba56bf35f28505e7ff67f1efd9bd3e1d5c6.tar.gz
remove unnecessary checks for NULL before calling free()
The function free() handles the case wher argument is NULL by doing nothing. So the extra checks are not needed. Found by modified version of kernel coccinelle script. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Diffstat (limited to 'tc')
-rw-r--r--tc/m_ipt.c3
-rw-r--r--tc/m_xt.c3
-rw-r--r--tc/m_xt_old.c3
-rw-r--r--tc/tc_qdisc.c3
4 files changed, 4 insertions, 8 deletions
diff --git a/tc/m_ipt.c b/tc/m_ipt.c
index 465d1b80..3fe70faf 100644
--- a/tc/m_ipt.c
+++ b/tc/m_ipt.c
@@ -412,8 +412,7 @@ static int parse_ipt(struct action_util *a, int *argc_p,
m->tflags = 0;
m->used = 0;
/* Free allocated memory */
- if (m->t)
- free(m->t);
+ free(m->t);
return 0;
diff --git a/tc/m_xt.c b/tc/m_xt.c
index 8a6fd3ce..65808437 100644
--- a/tc/m_xt.c
+++ b/tc/m_xt.c
@@ -299,8 +299,7 @@ static int parse_ipt(struct action_util *a, int *argc_p,
m->tflags = 0;
m->used = 0;
/* Free allocated memory */
- if (m->t)
- free(m->t);
+ free(m->t);
}
return 0;
diff --git a/tc/m_xt_old.c b/tc/m_xt_old.c
index efa084c5..7c6b79b9 100644
--- a/tc/m_xt_old.c
+++ b/tc/m_xt_old.c
@@ -337,8 +337,7 @@ static int parse_ipt(struct action_util *a, int *argc_p,
m->tflags = 0;
m->used = 0;
/* Free allocated memory */
- if (m->t)
- free(m->t);
+ free(m->t);
return 0;
diff --git a/tc/tc_qdisc.c b/tc/tc_qdisc.c
index 92ceb4c2..129ad9d9 100644
--- a/tc/tc_qdisc.c
+++ b/tc/tc_qdisc.c
@@ -187,8 +187,7 @@ static int tc_qdisc_modify(int cmd, unsigned int flags, int argc, char **argv)
addattr_l(&req.n, sizeof(req), TCA_STAB_DATA, stab.data,
stab.szopts.tsize * sizeof(__u16));
addattr_nest_end(&req.n, tail);
- if (stab.data)
- free(stab.data);
+ free(stab.data);
}
if (d[0]) {