From: Arushi Singhal <arushisinghal19971997@gmail.com>
To: pablo@netfilter.org
Cc: kadlec@blackhole.kfki.hu, davem@davemloft.net,
kuznet@ms2.inr.ac.ru, jmorris@namei.org, yoshfuji@linux-ipv6.org,
kaber@trash.net, netfilter-devel@vger.kernel.org,
coreteam@netfilter.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
Arushi Singhal <arushisinghal19971997@gmail.com>
Subject: [PATCH 1/2] iptables: extensions: unnecessary cast on void pointer
Date: Sun, 2 Apr 2017 19:21:03 +0530 [thread overview]
Message-ID: <20170402135104.24342-1-arushisinghal19971997@gmail.com> (raw)
The following Coccinelle script was used to detect this:
@r@
expression x;
void* e;
type T;
identifier f;
@@
(
*((T *)e)
|
((T *)x)[...]
|
((T*)x)->f
|
- (T*)
e
)
Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
---
extensions/libarpt_mangle.c | 2 +-
extensions/libip6t_rt.c | 2 +-
extensions/libxt_hashlimit.c | 2 +-
extensions/libxt_mangle.c | 16 ++++++++--------
4 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/extensions/libarpt_mangle.c b/extensions/libarpt_mangle.c
index 358b35d..8d81cb5 100644
--- a/extensions/libarpt_mangle.c
+++ b/extensions/libarpt_mangle.c
@@ -55,7 +55,7 @@ arpmangle_parse(int c, char **argv, int invert, unsigned int *flags,
struct arpt_mangle *mangle = (struct arpt_mangle *)(*target)->data;
struct in_addr *ipaddr, mask;
struct ether_addr *macaddr;
- const struct arpt_entry *e = (const struct arpt_entry *)entry;
+ const struct arpt_entry *e = entry;
unsigned int nr;
int ret = 1;
diff --git a/extensions/libip6t_rt.c b/extensions/libip6t_rt.c
index 3cb3b24..2e0aeb4 100644
--- a/extensions/libip6t_rt.c
+++ b/extensions/libip6t_rt.c
@@ -64,7 +64,7 @@ numeric_to_addr(const char *num)
#endif
xtables_error(PARAMETER_PROBLEM, "bad address: %s", num);
- return (struct in6_addr *)NULL;
+ return NULL;
}
diff --git a/extensions/libxt_hashlimit.c b/extensions/libxt_hashlimit.c
index 52fc4fa..bd72970 100644
--- a/extensions/libxt_hashlimit.c
+++ b/extensions/libxt_hashlimit.c
@@ -186,7 +186,7 @@ static int
cfg_copy(struct hashlimit_cfg2 *to, const void *from, int revision)
{
if (revision == 1) {
- struct hashlimit_cfg1 *cfg = (struct hashlimit_cfg1 *)from;
+ struct hashlimit_cfg1 *cfg = from;
to->mode = cfg->mode;
to->avg = cfg->avg;
diff --git a/extensions/libxt_mangle.c b/extensions/libxt_mangle.c
index 360742b..012037b 100644
--- a/extensions/libxt_mangle.c
+++ b/extensions/libxt_mangle.c
@@ -59,12 +59,12 @@ static struct in_addr *network_to_addr(const char *name)
if ((net = getnetbyname(name)) != NULL) {
if (net->n_addrtype != AF_INET)
- return (struct in_addr *) NULL;
+ return NULL;
addr.s_addr = htonl((unsigned long) net->n_net);
return &addr;
}
- return (struct in_addr *) NULL;
+ return NULL;
}
static void inaddrcpy(struct in_addr *dst, struct in_addr *src)
@@ -101,7 +101,7 @@ static struct in_addr *host_to_addr(const char *name, unsigned int *naddr)
return addr;
}
- return (struct in_addr *) NULL;
+ return NULL;
}
static int string_to_number(const char *s, unsigned int min,
@@ -139,11 +139,11 @@ static struct in_addr *dotted_to_addr(const char *dotted)
p = buf;
for (i = 0; i < 3; i++) {
if ((q = strchr(p, '.')) == NULL)
- return (struct in_addr *) NULL;
+ return NULL;
*q = '\0';
if (string_to_number(p, 0, 255, &onebyte) == -1)
- return (struct in_addr *) NULL;
+ return NULL;
addrp[i] = (unsigned char) onebyte;
p = q + 1;
@@ -151,7 +151,7 @@ static struct in_addr *dotted_to_addr(const char *dotted)
/* we've checked 3 bytes, now we check the last one */
if (string_to_number(p, 0, 255, &onebyte) == -1)
- return (struct in_addr *) NULL;
+ return NULL;
addrp[3] = (unsigned char) onebyte;
@@ -300,7 +300,7 @@ static char *addr_to_host(const struct in_addr *addr)
sizeof(struct in_addr), AF_INET)) != NULL)
return (char *) host->h_name;
- return (char *) NULL;
+ return NULL;
}
static char *addr_to_network(const struct in_addr *addr)
@@ -310,7 +310,7 @@ static char *addr_to_network(const struct in_addr *addr)
if ((net = getnetbyaddr((long) ntohl(addr->s_addr), AF_INET)) != NULL)
return (char *) net->n_name;
- return (char *) NULL;
+ return NULL;
}
static char *addr_to_anyname(const struct in_addr *addr)
--
2.11.0
next reply other threads:[~2017-04-02 13:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-02 13:51 Arushi Singhal [this message]
2017-04-02 13:51 ` [PATCH 2/2] iptables: iptables: unnecessary cast on void pointer Arushi Singhal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170402135104.24342-1-arushisinghal19971997@gmail.com \
--to=arushisinghal19971997@gmail.com \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=jmorris@namei.org \
--cc=kaber@trash.net \
--cc=kadlec@blackhole.kfki.hu \
--cc=kuznet@ms2.inr.ac.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=yoshfuji@linux-ipv6.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).