Skip to content

Commit 7c4e36b

Browse files
Jan EngelhardtDavid S. Miller
authored andcommitted
[NETFILTER]: Remove redundant parentheses/braces
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]>
1 parent 170b197 commit 7c4e36b

28 files changed

+90
-110
lines changed

net/ipv4/netfilter/ipt_CLUSTERIP.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,8 @@ __clusterip_config_find(__be32 clusterip)
122122
list_for_each(pos, &clusterip_configs) {
123123
struct clusterip_config *c = list_entry(pos,
124124
struct clusterip_config, list);
125-
if (c->clusterip == clusterip) {
125+
if (c->clusterip == clusterip)
126126
return c;
127-
}
128127
}
129128

130129
return NULL;
@@ -155,9 +154,8 @@ clusterip_config_init_nodelist(struct clusterip_config *c,
155154
{
156155
int n;
157156

158-
for (n = 0; n < i->num_local_nodes; n++) {
157+
for (n = 0; n < i->num_local_nodes; n++)
159158
set_bit(i->local_nodes[n] - 1, &c->local_nodes);
160-
}
161159
}
162160

163161
static struct clusterip_config *
@@ -255,10 +253,9 @@ clusterip_hashfn(const struct sk_buff *skb,
255253
dport = ports[1];
256254
break;
257255
default:
258-
if (net_ratelimit()) {
256+
if (net_ratelimit())
259257
printk(KERN_NOTICE "CLUSTERIP: unknown protocol `%u'\n",
260258
iph->protocol);
261-
}
262259
sport = dport = 0;
263260
}
264261

@@ -286,7 +283,7 @@ clusterip_hashfn(const struct sk_buff *skb,
286283
}
287284

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

292289
static inline int

net/ipv4/netfilter/ipt_ECN.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ set_ect_tcp(struct sk_buff **pskb, const struct ipt_ECN_info *einfo)
5858

5959
if ((!(einfo->operation & IPT_ECN_OP_SET_ECE) ||
6060
tcph->ece == einfo->proto.tcp.ece) &&
61-
((!(einfo->operation & IPT_ECN_OP_SET_CWR) ||
62-
tcph->cwr == einfo->proto.tcp.cwr)))
61+
(!(einfo->operation & IPT_ECN_OP_SET_CWR) ||
62+
tcph->cwr == einfo->proto.tcp.cwr))
6363
return true;
6464

6565
if (!skb_make_writable(pskb, ip_hdrlen(*pskb) + sizeof(*tcph)))

net/ipv4/netfilter/ipt_TTL.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static bool ipt_ttl_checkentry(const char *tablename,
7575
info->mode);
7676
return false;
7777
}
78-
if ((info->mode != IPT_TTL_SET) && (info->ttl == 0))
78+
if (info->mode != IPT_TTL_SET && info->ttl == 0)
7979
return false;
8080
return true;
8181
}

net/ipv4/netfilter/ipt_ULOG.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,10 @@ static void ipt_ulog_packet(unsigned int hooknum,
179179
unsigned int groupnum = ffs(loginfo->nl_group) - 1;
180180

181181
/* calculate the size of the skb needed */
182-
if ((loginfo->copy_range == 0) ||
183-
(loginfo->copy_range > skb->len)) {
182+
if (loginfo->copy_range == 0 || loginfo->copy_range > skb->len)
184183
copy_len = skb->len;
185-
} else {
184+
else
186185
copy_len = loginfo->copy_range;
187-
}
188186

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

@@ -257,9 +255,8 @@ static void ipt_ulog_packet(unsigned int hooknum,
257255
BUG();
258256

259257
/* check if we are building multi-part messages */
260-
if (ub->qlen > 1) {
258+
if (ub->qlen > 1)
261259
ub->lastnlh->nlmsg_flags |= NLM_F_MULTI;
262-
}
263260

264261
ub->lastnlh = nlh;
265262

net/ipv4/netfilter/ipt_iprange.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ match(const struct sk_buff *skb,
3535
const struct iphdr *iph = ip_hdr(skb);
3636

3737
if (info->flags & IPRANGE_SRC) {
38-
if (((ntohl(iph->saddr) < ntohl(info->src.min_ip))
39-
|| (ntohl(iph->saddr) > ntohl(info->src.max_ip)))
38+
if ((ntohl(iph->saddr) < ntohl(info->src.min_ip)
39+
|| ntohl(iph->saddr) > ntohl(info->src.max_ip))
4040
^ !!(info->flags & IPRANGE_SRC_INV)) {
4141
DEBUGP("src IP %u.%u.%u.%u NOT in range %s"
4242
"%u.%u.%u.%u-%u.%u.%u.%u\n",
@@ -48,8 +48,8 @@ match(const struct sk_buff *skb,
4848
}
4949
}
5050
if (info->flags & IPRANGE_DST) {
51-
if (((ntohl(iph->daddr) < ntohl(info->dst.min_ip))
52-
|| (ntohl(iph->daddr) > ntohl(info->dst.max_ip)))
51+
if ((ntohl(iph->daddr) < ntohl(info->dst.min_ip)
52+
|| ntohl(iph->daddr) > ntohl(info->dst.max_ip))
5353
^ !!(info->flags & IPRANGE_DST_INV)) {
5454
DEBUGP("dst IP %u.%u.%u.%u NOT in range %s"
5555
"%u.%u.%u.%u-%u.%u.%u.%u\n",

net/ipv4/netfilter/ipt_recent.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,9 @@ static void recent_table_flush(struct recent_table *t)
163163
struct recent_entry *e, *next;
164164
unsigned int i;
165165

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

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

330329
spin_lock_bh(&recent_lock);
331330

332-
for (st->bucket = 0; st->bucket < ip_list_hash_size; st->bucket++) {
333-
list_for_each_entry(e, &t->iphash[st->bucket], list) {
331+
for (st->bucket = 0; st->bucket < ip_list_hash_size; st->bucket++)
332+
list_for_each_entry(e, &t->iphash[st->bucket], list)
334333
if (p-- == 0)
335334
return e;
336-
}
337-
}
338335
return NULL;
339336
}
340337

net/ipv4/netfilter/ipt_ttl.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,13 @@ static bool match(const struct sk_buff *skb,
2828

2929
switch (info->mode) {
3030
case IPT_TTL_EQ:
31-
return (ttl == info->ttl);
32-
break;
31+
return ttl == info->ttl;
3332
case IPT_TTL_NE:
34-
return (!(ttl == info->ttl));
35-
break;
33+
return ttl != info->ttl;
3634
case IPT_TTL_LT:
37-
return (ttl < info->ttl);
38-
break;
35+
return ttl < info->ttl;
3936
case IPT_TTL_GT:
40-
return (ttl > info->ttl);
41-
break;
37+
return ttl > info->ttl;
4238
default:
4339
printk(KERN_WARNING "ipt_ttl: unknown mode %d\n",
4440
info->mode);

net/ipv6/netfilter/ip6t_HL.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static bool ip6t_hl_checkentry(const char *tablename,
7171
info->mode);
7272
return false;
7373
}
74-
if ((info->mode != IP6T_HL_SET) && (info->hop_limit == 0)) {
74+
if (info->mode != IP6T_HL_SET && info->hop_limit == 0) {
7575
printk(KERN_WARNING "ip6t_HL: increment/decrement doesn't "
7676
"make sense with value 0\n");
7777
return false;

net/ipv6/netfilter/ip6t_REJECT.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static void send_reset(struct sk_buff *oldskb)
6969
otcplen = oldskb->len - tcphoff;
7070

7171
/* IP header checks: fragment, too short. */
72-
if ((proto != IPPROTO_TCP) || (otcplen < sizeof(struct tcphdr))) {
72+
if (proto != IPPROTO_TCP || otcplen < sizeof(struct tcphdr)) {
7373
DEBUGP("ip6t_REJECT: proto(%d) != IPPROTO_TCP, or too short. otcplen = %d\n",
7474
proto, otcplen);
7575
return;

net/ipv6/netfilter/ip6t_ah.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ match(const struct sk_buff *skb,
7878
DEBUGP("SPI %u %08X\n", ntohl(ah->spi), ntohl(ah->spi));
7979

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

9393
return (ah != NULL)
9494
&&
95-
(spi_match(ahinfo->spis[0], ahinfo->spis[1],
96-
ntohl(ah->spi),
97-
!!(ahinfo->invflags & IP6T_AH_INV_SPI)))
95+
spi_match(ahinfo->spis[0], ahinfo->spis[1],
96+
ntohl(ah->spi),
97+
!!(ahinfo->invflags & IP6T_AH_INV_SPI))
9898
&&
9999
(!ahinfo->hdrlen ||
100100
(ahinfo->hdrlen == hdrlen) ^

net/ipv6/netfilter/ip6t_eui64.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ match(const struct sk_buff *skb,
3333
int i = 0;
3434

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

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

5757
if (i == 8)

net/ipv6/netfilter/ip6t_frag.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,35 +77,35 @@ match(const struct sk_buff *skb,
7777
ntohl(fh->identification));
7878

7979
DEBUGP("IPv6 FRAG id %02X ",
80-
(id_match(fraginfo->ids[0], fraginfo->ids[1],
80+
id_match(fraginfo->ids[0], fraginfo->ids[1],
8181
ntohl(fh->identification),
82-
!!(fraginfo->invflags & IP6T_FRAG_INV_IDS))));
82+
!!(fraginfo->invflags & IP6T_FRAG_INV_IDS)));
8383
DEBUGP("res %02X %02X%04X %02X ",
84-
(fraginfo->flags & IP6T_FRAG_RES), fh->reserved,
84+
fraginfo->flags & IP6T_FRAG_RES, fh->reserved,
8585
ntohs(fh->frag_off) & 0x6,
8686
!((fraginfo->flags & IP6T_FRAG_RES)
8787
&& (fh->reserved || (ntohs(fh->frag_off) & 0x06))));
8888
DEBUGP("first %02X %02X %02X ",
89-
(fraginfo->flags & IP6T_FRAG_FST),
89+
fraginfo->flags & IP6T_FRAG_FST,
9090
ntohs(fh->frag_off) & ~0x7,
9191
!((fraginfo->flags & IP6T_FRAG_FST)
9292
&& (ntohs(fh->frag_off) & ~0x7)));
9393
DEBUGP("mf %02X %02X %02X ",
94-
(fraginfo->flags & IP6T_FRAG_MF),
94+
fraginfo->flags & IP6T_FRAG_MF,
9595
ntohs(fh->frag_off) & IP6_MF,
9696
!((fraginfo->flags & IP6T_FRAG_MF)
9797
&& !((ntohs(fh->frag_off) & IP6_MF))));
9898
DEBUGP("last %02X %02X %02X\n",
99-
(fraginfo->flags & IP6T_FRAG_NMF),
99+
fraginfo->flags & IP6T_FRAG_NMF,
100100
ntohs(fh->frag_off) & IP6_MF,
101101
!((fraginfo->flags & IP6T_FRAG_NMF)
102102
&& (ntohs(fh->frag_off) & IP6_MF)));
103103

104104
return (fh != NULL)
105105
&&
106-
(id_match(fraginfo->ids[0], fraginfo->ids[1],
107-
ntohl(fh->identification),
108-
!!(fraginfo->invflags & IP6T_FRAG_INV_IDS)))
106+
id_match(fraginfo->ids[0], fraginfo->ids[1],
107+
ntohl(fh->identification),
108+
!!(fraginfo->invflags & IP6T_FRAG_INV_IDS))
109109
&&
110110
!((fraginfo->flags & IP6T_FRAG_RES)
111111
&& (fh->reserved || (ntohs(fh->frag_off) & 0x6)))

net/ipv6/netfilter/ip6t_hbh.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ match(const struct sk_buff *skb,
160160
DEBUGP("len%04X \n", optlen);
161161

162162
if ((ptr > skb->len - optlen || hdrlen < optlen) &&
163-
(temp < optinfo->optsnr - 1)) {
163+
temp < optinfo->optsnr - 1) {
164164
DEBUGP("new pointer is too large! \n");
165165
break;
166166
}

net/ipv6/netfilter/ip6t_hl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ static bool match(const struct sk_buff *skb,
2929

3030
switch (info->mode) {
3131
case IP6T_HL_EQ:
32-
return (ip6h->hop_limit == info->hop_limit);
32+
return ip6h->hop_limit == info->hop_limit;
3333
break;
3434
case IP6T_HL_NE:
35-
return (!(ip6h->hop_limit == info->hop_limit));
35+
return ip6h->hop_limit != info->hop_limit;
3636
break;
3737
case IP6T_HL_LT:
38-
return (ip6h->hop_limit < info->hop_limit);
38+
return ip6h->hop_limit < info->hop_limit;
3939
break;
4040
case IP6T_HL_GT:
41-
return (ip6h->hop_limit > info->hop_limit);
41+
return ip6h->hop_limit > info->hop_limit;
4242
break;
4343
default:
4444
printk(KERN_WARNING "ip6t_hl: unknown mode %d\n",

net/ipv6/netfilter/ip6t_ipv6header.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ ipv6header_match(const struct sk_buff *skb,
7474
BUG_ON(hp == NULL);
7575

7676
/* Calculate the header length */
77-
if (nexthdr == NEXTHDR_FRAGMENT) {
77+
if (nexthdr == NEXTHDR_FRAGMENT)
7878
hdrlen = 8;
79-
} else if (nexthdr == NEXTHDR_AUTH)
79+
else if (nexthdr == NEXTHDR_AUTH)
8080
hdrlen = (hp->hdrlen + 2) << 2;
8181
else
8282
hdrlen = ipv6_optlen(hp);
@@ -110,7 +110,7 @@ ipv6header_match(const struct sk_buff *skb,
110110
break;
111111
}
112112

113-
if ((nexthdr != NEXTHDR_NONE) && (nexthdr != NEXTHDR_ESP))
113+
if (nexthdr != NEXTHDR_NONE && nexthdr != NEXTHDR_ESP)
114114
temp |= MASK_PROTO;
115115

116116
if (info->modeflag)

net/ipv6/netfilter/ip6t_owner.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,15 @@ match(const struct sk_buff *skb,
3838
if (!skb->sk || !skb->sk->sk_socket || !skb->sk->sk_socket->file)
3939
return false;
4040

41-
if (info->match & IP6T_OWNER_UID) {
41+
if (info->match & IP6T_OWNER_UID)
4242
if ((skb->sk->sk_socket->file->f_uid != info->uid) ^
4343
!!(info->invert & IP6T_OWNER_UID))
4444
return false;
45-
}
4645

47-
if (info->match & IP6T_OWNER_GID) {
46+
if (info->match & IP6T_OWNER_GID)
4847
if ((skb->sk->sk_socket->file->f_gid != info->gid) ^
4948
!!(info->invert & IP6T_OWNER_GID))
5049
return false;
51-
}
5250

5351
return true;
5452
}

net/ipv6/netfilter/ip6t_rt.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,21 +87,21 @@ match(const struct sk_buff *skb,
8787
DEBUGP("SGS_LEFT %u %02X\n", rh->segments_left, rh->segments_left);
8888

8989
DEBUGP("IPv6 RT segsleft %02X ",
90-
(segsleft_match(rtinfo->segsleft[0], rtinfo->segsleft[1],
91-
rh->segments_left,
92-
!!(rtinfo->invflags & IP6T_RT_INV_SGS))));
90+
segsleft_match(rtinfo->segsleft[0], rtinfo->segsleft[1],
91+
rh->segments_left,
92+
!!(rtinfo->invflags & IP6T_RT_INV_SGS)));
9393
DEBUGP("type %02X %02X %02X ",
9494
rtinfo->rt_type, rh->type,
9595
(!(rtinfo->flags & IP6T_RT_TYP) ||
9696
((rtinfo->rt_type == rh->type) ^
9797
!!(rtinfo->invflags & IP6T_RT_INV_TYP))));
9898
DEBUGP("len %02X %04X %02X ",
9999
rtinfo->hdrlen, hdrlen,
100-
(!(rtinfo->flags & IP6T_RT_LEN) ||
100+
!(rtinfo->flags & IP6T_RT_LEN) ||
101101
((rtinfo->hdrlen == hdrlen) ^
102-
!!(rtinfo->invflags & IP6T_RT_INV_LEN))));
102+
!!(rtinfo->invflags & IP6T_RT_INV_LEN)));
103103
DEBUGP("res %02X %02X %02X ",
104-
(rtinfo->flags & IP6T_RT_RES),
104+
rtinfo->flags & IP6T_RT_RES,
105105
((const struct rt0_hdr *)rh)->reserved,
106106
!((rtinfo->flags & IP6T_RT_RES) &&
107107
(((const struct rt0_hdr *)rh)->reserved)));
@@ -188,8 +188,8 @@ match(const struct sk_buff *skb,
188188
break;
189189
}
190190
DEBUGP("temp=%d #%d\n", temp, rtinfo->addrnr);
191-
if ((temp == rtinfo->addrnr) &&
192-
(temp == (unsigned int)((hdrlen - 8) / 16)))
191+
if (temp == rtinfo->addrnr &&
192+
temp == (unsigned int)((hdrlen - 8) / 16))
193193
return ret;
194194
else
195195
return false;

net/netfilter/xt_DSCP.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static bool checkentry(const char *tablename,
7474
{
7575
const u_int8_t dscp = ((struct xt_DSCP_info *)targinfo)->dscp;
7676

77-
if ((dscp > XT_DSCP_MAX)) {
77+
if (dscp > XT_DSCP_MAX) {
7878
printk(KERN_WARNING "DSCP: dscp %x out of range\n", dscp);
7979
return false;
8080
}

0 commit comments

Comments
 (0)