Skip to content

Commit

Permalink
[NETFILTER]: Remove redundant parentheses/braces
Browse files Browse the repository at this point in the history
Removes redundant parentheses and braces (And add one pair in a
xt_tcpudp.c macro).

Signed-off-by: Jan Engelhardt <[email protected]>
Signed-off-by: Patrick McHardy <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Jan Engelhardt authored and David S. Miller committed Jul 11, 2007
1 parent 170b197 commit 7c4e36b
Show file tree
Hide file tree
Showing 28 changed files with 90 additions and 110 deletions.
11 changes: 4 additions & 7 deletions net/ipv4/netfilter/ipt_CLUSTERIP.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,8 @@ __clusterip_config_find(__be32 clusterip)
list_for_each(pos, &clusterip_configs) {
struct clusterip_config *c = list_entry(pos,
struct clusterip_config, list);
if (c->clusterip == clusterip) {
if (c->clusterip == clusterip)
return c;
}
}

return NULL;
Expand Down Expand Up @@ -155,9 +154,8 @@ clusterip_config_init_nodelist(struct clusterip_config *c,
{
int n;

for (n = 0; n < i->num_local_nodes; n++) {
for (n = 0; n < i->num_local_nodes; n++)
set_bit(i->local_nodes[n] - 1, &c->local_nodes);
}
}

static struct clusterip_config *
Expand Down Expand Up @@ -255,10 +253,9 @@ clusterip_hashfn(const struct sk_buff *skb,
dport = ports[1];
break;
default:
if (net_ratelimit()) {
if (net_ratelimit())
printk(KERN_NOTICE "CLUSTERIP: unknown protocol `%u'\n",
iph->protocol);
}
sport = dport = 0;
}

Expand Down Expand Up @@ -286,7 +283,7 @@ clusterip_hashfn(const struct sk_buff *skb,
}

/* node numbers are 1..n, not 0..n */
return ((hashval % config->num_total_nodes)+1);
return (hashval % config->num_total_nodes) + 1;
}

static inline int
Expand Down
4 changes: 2 additions & 2 deletions net/ipv4/netfilter/ipt_ECN.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ set_ect_tcp(struct sk_buff **pskb, const struct ipt_ECN_info *einfo)

if ((!(einfo->operation & IPT_ECN_OP_SET_ECE) ||
tcph->ece == einfo->proto.tcp.ece) &&
((!(einfo->operation & IPT_ECN_OP_SET_CWR) ||
tcph->cwr == einfo->proto.tcp.cwr)))
(!(einfo->operation & IPT_ECN_OP_SET_CWR) ||
tcph->cwr == einfo->proto.tcp.cwr))
return true;

if (!skb_make_writable(pskb, ip_hdrlen(*pskb) + sizeof(*tcph)))
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/netfilter/ipt_TTL.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static bool ipt_ttl_checkentry(const char *tablename,
info->mode);
return false;
}
if ((info->mode != IPT_TTL_SET) && (info->ttl == 0))
if (info->mode != IPT_TTL_SET && info->ttl == 0)
return false;
return true;
}
Expand Down
9 changes: 3 additions & 6 deletions net/ipv4/netfilter/ipt_ULOG.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,10 @@ static void ipt_ulog_packet(unsigned int hooknum,
unsigned int groupnum = ffs(loginfo->nl_group) - 1;

/* calculate the size of the skb needed */
if ((loginfo->copy_range == 0) ||
(loginfo->copy_range > skb->len)) {
if (loginfo->copy_range == 0 || loginfo->copy_range > skb->len)
copy_len = skb->len;
} else {
else
copy_len = loginfo->copy_range;
}

size = NLMSG_SPACE(sizeof(*pm) + copy_len);

Expand Down Expand Up @@ -257,9 +255,8 @@ static void ipt_ulog_packet(unsigned int hooknum,
BUG();

/* check if we are building multi-part messages */
if (ub->qlen > 1) {
if (ub->qlen > 1)
ub->lastnlh->nlmsg_flags |= NLM_F_MULTI;
}

ub->lastnlh = nlh;

Expand Down
8 changes: 4 additions & 4 deletions net/ipv4/netfilter/ipt_iprange.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ match(const struct sk_buff *skb,
const struct iphdr *iph = ip_hdr(skb);

if (info->flags & IPRANGE_SRC) {
if (((ntohl(iph->saddr) < ntohl(info->src.min_ip))
|| (ntohl(iph->saddr) > ntohl(info->src.max_ip)))
if ((ntohl(iph->saddr) < ntohl(info->src.min_ip)
|| ntohl(iph->saddr) > ntohl(info->src.max_ip))
^ !!(info->flags & IPRANGE_SRC_INV)) {
DEBUGP("src IP %u.%u.%u.%u NOT in range %s"
"%u.%u.%u.%u-%u.%u.%u.%u\n",
Expand All @@ -48,8 +48,8 @@ match(const struct sk_buff *skb,
}
}
if (info->flags & IPRANGE_DST) {
if (((ntohl(iph->daddr) < ntohl(info->dst.min_ip))
|| (ntohl(iph->daddr) > ntohl(info->dst.max_ip)))
if ((ntohl(iph->daddr) < ntohl(info->dst.min_ip)
|| ntohl(iph->daddr) > ntohl(info->dst.max_ip))
^ !!(info->flags & IPRANGE_DST_INV)) {
DEBUGP("dst IP %u.%u.%u.%u NOT in range %s"
"%u.%u.%u.%u-%u.%u.%u.%u\n",
Expand Down
9 changes: 3 additions & 6 deletions net/ipv4/netfilter/ipt_recent.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,9 @@ static void recent_table_flush(struct recent_table *t)
struct recent_entry *e, *next;
unsigned int i;

for (i = 0; i < ip_list_hash_size; i++) {
for (i = 0; i < ip_list_hash_size; i++)
list_for_each_entry_safe(e, next, &t->iphash[i], list)
recent_entry_remove(t, e);
}
}

static bool
Expand Down Expand Up @@ -329,12 +328,10 @@ static void *recent_seq_start(struct seq_file *seq, loff_t *pos)

spin_lock_bh(&recent_lock);

for (st->bucket = 0; st->bucket < ip_list_hash_size; st->bucket++) {
list_for_each_entry(e, &t->iphash[st->bucket], list) {
for (st->bucket = 0; st->bucket < ip_list_hash_size; st->bucket++)
list_for_each_entry(e, &t->iphash[st->bucket], list)
if (p-- == 0)
return e;
}
}
return NULL;
}

Expand Down
12 changes: 4 additions & 8 deletions net/ipv4/netfilter/ipt_ttl.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,13 @@ static bool match(const struct sk_buff *skb,

switch (info->mode) {
case IPT_TTL_EQ:
return (ttl == info->ttl);
break;
return ttl == info->ttl;
case IPT_TTL_NE:
return (!(ttl == info->ttl));
break;
return ttl != info->ttl;
case IPT_TTL_LT:
return (ttl < info->ttl);
break;
return ttl < info->ttl;
case IPT_TTL_GT:
return (ttl > info->ttl);
break;
return ttl > info->ttl;
default:
printk(KERN_WARNING "ipt_ttl: unknown mode %d\n",
info->mode);
Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/netfilter/ip6t_HL.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static bool ip6t_hl_checkentry(const char *tablename,
info->mode);
return false;
}
if ((info->mode != IP6T_HL_SET) && (info->hop_limit == 0)) {
if (info->mode != IP6T_HL_SET && info->hop_limit == 0) {
printk(KERN_WARNING "ip6t_HL: increment/decrement doesn't "
"make sense with value 0\n");
return false;
Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/netfilter/ip6t_REJECT.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static void send_reset(struct sk_buff *oldskb)
otcplen = oldskb->len - tcphoff;

/* IP header checks: fragment, too short. */
if ((proto != IPPROTO_TCP) || (otcplen < sizeof(struct tcphdr))) {
if (proto != IPPROTO_TCP || otcplen < sizeof(struct tcphdr)) {
DEBUGP("ip6t_REJECT: proto(%d) != IPPROTO_TCP, or too short. otcplen = %d\n",
proto, otcplen);
return;
Expand Down
12 changes: 6 additions & 6 deletions net/ipv6/netfilter/ip6t_ah.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ match(const struct sk_buff *skb,
DEBUGP("SPI %u %08X\n", ntohl(ah->spi), ntohl(ah->spi));

DEBUGP("IPv6 AH spi %02X ",
(spi_match(ahinfo->spis[0], ahinfo->spis[1],
ntohl(ah->spi),
!!(ahinfo->invflags & IP6T_AH_INV_SPI))));
spi_match(ahinfo->spis[0], ahinfo->spis[1],
ntohl(ah->spi),
!!(ahinfo->invflags & IP6T_AH_INV_SPI)));
DEBUGP("len %02X %04X %02X ",
ahinfo->hdrlen, hdrlen,
(!ahinfo->hdrlen ||
Expand All @@ -92,9 +92,9 @@ match(const struct sk_buff *skb,

return (ah != NULL)
&&
(spi_match(ahinfo->spis[0], ahinfo->spis[1],
ntohl(ah->spi),
!!(ahinfo->invflags & IP6T_AH_INV_SPI)))
spi_match(ahinfo->spis[0], ahinfo->spis[1],
ntohl(ah->spi),
!!(ahinfo->invflags & IP6T_AH_INV_SPI))
&&
(!ahinfo->hdrlen ||
(ahinfo->hdrlen == hdrlen) ^
Expand Down
6 changes: 3 additions & 3 deletions net/ipv6/netfilter/ip6t_eui64.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ match(const struct sk_buff *skb,
int i = 0;

if (!(skb_mac_header(skb) >= skb->head &&
(skb_mac_header(skb) + ETH_HLEN) <= skb->data) &&
skb_mac_header(skb) + ETH_HLEN <= skb->data) &&
offset != 0) {
*hotdrop = true;
return false;
Expand All @@ -50,8 +50,8 @@ match(const struct sk_buff *skb,
eui64[0] |= 0x02;

i = 0;
while ((ipv6_hdr(skb)->saddr.s6_addr[8 + i] == eui64[i])
&& (i < 8))
while (ipv6_hdr(skb)->saddr.s6_addr[8 + i] == eui64[i]
&& i < 8)
i++;

if (i == 8)
Expand Down
18 changes: 9 additions & 9 deletions net/ipv6/netfilter/ip6t_frag.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,35 +77,35 @@ match(const struct sk_buff *skb,
ntohl(fh->identification));

DEBUGP("IPv6 FRAG id %02X ",
(id_match(fraginfo->ids[0], fraginfo->ids[1],
id_match(fraginfo->ids[0], fraginfo->ids[1],
ntohl(fh->identification),
!!(fraginfo->invflags & IP6T_FRAG_INV_IDS))));
!!(fraginfo->invflags & IP6T_FRAG_INV_IDS)));
DEBUGP("res %02X %02X%04X %02X ",
(fraginfo->flags & IP6T_FRAG_RES), fh->reserved,
fraginfo->flags & IP6T_FRAG_RES, fh->reserved,
ntohs(fh->frag_off) & 0x6,
!((fraginfo->flags & IP6T_FRAG_RES)
&& (fh->reserved || (ntohs(fh->frag_off) & 0x06))));
DEBUGP("first %02X %02X %02X ",
(fraginfo->flags & IP6T_FRAG_FST),
fraginfo->flags & IP6T_FRAG_FST,
ntohs(fh->frag_off) & ~0x7,
!((fraginfo->flags & IP6T_FRAG_FST)
&& (ntohs(fh->frag_off) & ~0x7)));
DEBUGP("mf %02X %02X %02X ",
(fraginfo->flags & IP6T_FRAG_MF),
fraginfo->flags & IP6T_FRAG_MF,
ntohs(fh->frag_off) & IP6_MF,
!((fraginfo->flags & IP6T_FRAG_MF)
&& !((ntohs(fh->frag_off) & IP6_MF))));
DEBUGP("last %02X %02X %02X\n",
(fraginfo->flags & IP6T_FRAG_NMF),
fraginfo->flags & IP6T_FRAG_NMF,
ntohs(fh->frag_off) & IP6_MF,
!((fraginfo->flags & IP6T_FRAG_NMF)
&& (ntohs(fh->frag_off) & IP6_MF)));

return (fh != NULL)
&&
(id_match(fraginfo->ids[0], fraginfo->ids[1],
ntohl(fh->identification),
!!(fraginfo->invflags & IP6T_FRAG_INV_IDS)))
id_match(fraginfo->ids[0], fraginfo->ids[1],
ntohl(fh->identification),
!!(fraginfo->invflags & IP6T_FRAG_INV_IDS))
&&
!((fraginfo->flags & IP6T_FRAG_RES)
&& (fh->reserved || (ntohs(fh->frag_off) & 0x6)))
Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/netfilter/ip6t_hbh.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ match(const struct sk_buff *skb,
DEBUGP("len%04X \n", optlen);

if ((ptr > skb->len - optlen || hdrlen < optlen) &&
(temp < optinfo->optsnr - 1)) {
temp < optinfo->optsnr - 1) {
DEBUGP("new pointer is too large! \n");
break;
}
Expand Down
8 changes: 4 additions & 4 deletions net/ipv6/netfilter/ip6t_hl.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ static bool match(const struct sk_buff *skb,

switch (info->mode) {
case IP6T_HL_EQ:
return (ip6h->hop_limit == info->hop_limit);
return ip6h->hop_limit == info->hop_limit;
break;
case IP6T_HL_NE:
return (!(ip6h->hop_limit == info->hop_limit));
return ip6h->hop_limit != info->hop_limit;
break;
case IP6T_HL_LT:
return (ip6h->hop_limit < info->hop_limit);
return ip6h->hop_limit < info->hop_limit;
break;
case IP6T_HL_GT:
return (ip6h->hop_limit > info->hop_limit);
return ip6h->hop_limit > info->hop_limit;
break;
default:
printk(KERN_WARNING "ip6t_hl: unknown mode %d\n",
Expand Down
6 changes: 3 additions & 3 deletions net/ipv6/netfilter/ip6t_ipv6header.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ ipv6header_match(const struct sk_buff *skb,
BUG_ON(hp == NULL);

/* Calculate the header length */
if (nexthdr == NEXTHDR_FRAGMENT) {
if (nexthdr == NEXTHDR_FRAGMENT)
hdrlen = 8;
} else if (nexthdr == NEXTHDR_AUTH)
else if (nexthdr == NEXTHDR_AUTH)
hdrlen = (hp->hdrlen + 2) << 2;
else
hdrlen = ipv6_optlen(hp);
Expand Down Expand Up @@ -110,7 +110,7 @@ ipv6header_match(const struct sk_buff *skb,
break;
}

if ((nexthdr != NEXTHDR_NONE) && (nexthdr != NEXTHDR_ESP))
if (nexthdr != NEXTHDR_NONE && nexthdr != NEXTHDR_ESP)
temp |= MASK_PROTO;

if (info->modeflag)
Expand Down
6 changes: 2 additions & 4 deletions net/ipv6/netfilter/ip6t_owner.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,15 @@ match(const struct sk_buff *skb,
if (!skb->sk || !skb->sk->sk_socket || !skb->sk->sk_socket->file)
return false;

if (info->match & IP6T_OWNER_UID) {
if (info->match & IP6T_OWNER_UID)
if ((skb->sk->sk_socket->file->f_uid != info->uid) ^
!!(info->invert & IP6T_OWNER_UID))
return false;
}

if (info->match & IP6T_OWNER_GID) {
if (info->match & IP6T_OWNER_GID)
if ((skb->sk->sk_socket->file->f_gid != info->gid) ^
!!(info->invert & IP6T_OWNER_GID))
return false;
}

return true;
}
Expand Down
16 changes: 8 additions & 8 deletions net/ipv6/netfilter/ip6t_rt.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,21 @@ match(const struct sk_buff *skb,
DEBUGP("SGS_LEFT %u %02X\n", rh->segments_left, rh->segments_left);

DEBUGP("IPv6 RT segsleft %02X ",
(segsleft_match(rtinfo->segsleft[0], rtinfo->segsleft[1],
rh->segments_left,
!!(rtinfo->invflags & IP6T_RT_INV_SGS))));
segsleft_match(rtinfo->segsleft[0], rtinfo->segsleft[1],
rh->segments_left,
!!(rtinfo->invflags & IP6T_RT_INV_SGS)));
DEBUGP("type %02X %02X %02X ",
rtinfo->rt_type, rh->type,
(!(rtinfo->flags & IP6T_RT_TYP) ||
((rtinfo->rt_type == rh->type) ^
!!(rtinfo->invflags & IP6T_RT_INV_TYP))));
DEBUGP("len %02X %04X %02X ",
rtinfo->hdrlen, hdrlen,
(!(rtinfo->flags & IP6T_RT_LEN) ||
!(rtinfo->flags & IP6T_RT_LEN) ||
((rtinfo->hdrlen == hdrlen) ^
!!(rtinfo->invflags & IP6T_RT_INV_LEN))));
!!(rtinfo->invflags & IP6T_RT_INV_LEN)));
DEBUGP("res %02X %02X %02X ",
(rtinfo->flags & IP6T_RT_RES),
rtinfo->flags & IP6T_RT_RES,
((const struct rt0_hdr *)rh)->reserved,
!((rtinfo->flags & IP6T_RT_RES) &&
(((const struct rt0_hdr *)rh)->reserved)));
Expand Down Expand Up @@ -188,8 +188,8 @@ match(const struct sk_buff *skb,
break;
}
DEBUGP("temp=%d #%d\n", temp, rtinfo->addrnr);
if ((temp == rtinfo->addrnr) &&
(temp == (unsigned int)((hdrlen - 8) / 16)))
if (temp == rtinfo->addrnr &&
temp == (unsigned int)((hdrlen - 8) / 16))
return ret;
else
return false;
Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/xt_DSCP.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static bool checkentry(const char *tablename,
{
const u_int8_t dscp = ((struct xt_DSCP_info *)targinfo)->dscp;

if ((dscp > XT_DSCP_MAX)) {
if (dscp > XT_DSCP_MAX) {
printk(KERN_WARNING "DSCP: dscp %x out of range\n", dscp);
return false;
}
Expand Down
Loading

0 comments on commit 7c4e36b

Please sign in to comment.