Skip to content

Commit 6e27c9b

Browse files
author
Jozsef Kadlecsik
committed
netfilter: ipset: Fix sparse warnings "incorrect type in assignment"
Signed-off-by: Jozsef Kadlecsik <[email protected]>
1 parent 2cbc78a commit 6e27c9b

File tree

7 files changed

+39
-33
lines changed

7 files changed

+39
-33
lines changed

net/netfilter/ipset/ip_set_hash_ip.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ hash_ip4_data_tlist(struct sk_buff *skb, const struct hash_ip4_elem *data)
114114
static inline void
115115
hash_ip4_data_next(struct ip_set_hash *h, const struct hash_ip4_elem *d)
116116
{
117-
h->next.ip = ntohl(d->ip);
117+
h->next.ip = d->ip;
118118
}
119119

120120
static int
@@ -188,7 +188,7 @@ hash_ip4_uadt(struct ip_set *set, struct nlattr *tb[],
188188
hosts = h->netmask == 32 ? 1 : 2 << (32 - h->netmask - 1);
189189

190190
if (retried)
191-
ip = h->next.ip;
191+
ip = ntohl(h->next.ip);
192192
for (; !before(ip_to, ip); ip += hosts) {
193193
nip = htonl(ip);
194194
if (nip == 0)

net/netfilter/ipset/ip_set_hash_ipport.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ static inline void
130130
hash_ipport4_data_next(struct ip_set_hash *h,
131131
const struct hash_ipport4_elem *d)
132132
{
133-
h->next.ip = ntohl(d->ip);
134-
h->next.port = ntohs(d->port);
133+
h->next.ip = d->ip;
134+
h->next.port = d->port;
135135
}
136136

137137
static int
@@ -231,9 +231,10 @@ hash_ipport4_uadt(struct ip_set *set, struct nlattr *tb[],
231231
}
232232

233233
if (retried)
234-
ip = h->next.ip;
234+
ip = ntohl(h->next.ip);
235235
for (; !before(ip_to, ip); ip++) {
236-
p = retried && ip == h->next.ip ? h->next.port : port;
236+
p = retried && ip == ntohl(h->next.ip) ? ntohs(h->next.port)
237+
: port;
237238
for (; p <= port_to; p++) {
238239
data.ip = htonl(ip);
239240
data.port = htons(p);
@@ -349,7 +350,7 @@ static inline void
349350
hash_ipport6_data_next(struct ip_set_hash *h,
350351
const struct hash_ipport6_elem *d)
351352
{
352-
h->next.port = ntohs(d->port);
353+
h->next.port = d->port;
353354
}
354355

355356
static int
@@ -431,7 +432,7 @@ hash_ipport6_uadt(struct ip_set *set, struct nlattr *tb[],
431432
swap(port, port_to);
432433

433434
if (retried)
434-
port = h->next.port;
435+
port = ntohs(h->next.port);
435436
for (; port <= port_to; port++) {
436437
data.port = htons(port);
437438
ret = adtfn(set, &data, timeout, flags);

net/netfilter/ipset/ip_set_hash_ipportip.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ static inline void
133133
hash_ipportip4_data_next(struct ip_set_hash *h,
134134
const struct hash_ipportip4_elem *d)
135135
{
136-
h->next.ip = ntohl(d->ip);
137-
h->next.port = ntohs(d->port);
136+
h->next.ip = d->ip;
137+
h->next.port = d->port;
138138
}
139139

140140
static int
@@ -239,9 +239,10 @@ hash_ipportip4_uadt(struct ip_set *set, struct nlattr *tb[],
239239
}
240240

241241
if (retried)
242-
ip = h->next.ip;
242+
ip = ntohl(h->next.ip);
243243
for (; !before(ip_to, ip); ip++) {
244-
p = retried && ip == h->next.ip ? h->next.port : port;
244+
p = retried && ip == ntohl(h->next.ip) ? ntohs(h->next.port)
245+
: port;
245246
for (; p <= port_to; p++) {
246247
data.ip = htonl(ip);
247248
data.port = htons(p);
@@ -362,7 +363,7 @@ static inline void
362363
hash_ipportip6_data_next(struct ip_set_hash *h,
363364
const struct hash_ipportip6_elem *d)
364365
{
365-
h->next.port = ntohs(d->port);
366+
h->next.port = d->port;
366367
}
367368

368369
static int
@@ -449,7 +450,7 @@ hash_ipportip6_uadt(struct ip_set *set, struct nlattr *tb[],
449450
swap(port, port_to);
450451

451452
if (retried)
452-
port = h->next.port;
453+
port = ntohs(h->next.port);
453454
for (; port <= port_to; port++) {
454455
data.port = htons(port);
455456
ret = adtfn(set, &data, timeout, flags);

net/netfilter/ipset/ip_set_hash_ipportnet.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ static inline void
173173
hash_ipportnet4_data_next(struct ip_set_hash *h,
174174
const struct hash_ipportnet4_elem *d)
175175
{
176-
h->next.ip = ntohl(d->ip);
177-
h->next.port = ntohs(d->port);
178-
h->next.ip2 = ntohl(d->ip2);
176+
h->next.ip = d->ip;
177+
h->next.port = d->port;
178+
h->next.ip2 = d->ip2;
179179
}
180180

181181
static int
@@ -314,14 +314,17 @@ hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
314314
}
315315

316316
if (retried)
317-
ip = h->next.ip;
317+
ip = ntohl(h->next.ip);
318318
for (; !before(ip_to, ip); ip++) {
319319
data.ip = htonl(ip);
320-
p = retried && ip == h->next.ip ? h->next.port : port;
320+
p = retried && ip == ntohl(h->next.ip) ? ntohs(h->next.port)
321+
: port;
321322
for (; p <= port_to; p++) {
322323
data.port = htons(p);
323-
ip2 = retried && ip == h->next.ip && p == h->next.port
324-
? h->next.ip2 : ip2_from;
324+
ip2 = retried
325+
&& ip == ntohl(h->next.ip)
326+
&& p == ntohs(h->next.port)
327+
? ntohl(h->next.ip2) : ip2_from;
325328
while (!after(ip2, ip2_to)) {
326329
data.ip2 = htonl(ip2);
327330
ip2_last = ip_set_range_to_cidr(ip2, ip2_to,
@@ -486,7 +489,7 @@ static inline void
486489
hash_ipportnet6_data_next(struct ip_set_hash *h,
487490
const struct hash_ipportnet6_elem *d)
488491
{
489-
h->next.port = ntohs(d->port);
492+
h->next.port = d->port;
490493
}
491494

492495
static int
@@ -598,7 +601,7 @@ hash_ipportnet6_uadt(struct ip_set *set, struct nlattr *tb[],
598601
swap(port, port_to);
599602

600603
if (retried)
601-
port = h->next.port;
604+
port = ntohs(h->next.port);
602605
for (; port <= port_to; port++) {
603606
data.port = htons(port);
604607
ret = adtfn(set, &data, timeout, flags);

net/netfilter/ipset/ip_set_hash_net.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static inline void
152152
hash_net4_data_next(struct ip_set_hash *h,
153153
const struct hash_net4_elem *d)
154154
{
155-
h->next.ip = ntohl(d->ip);
155+
h->next.ip = d->ip;
156156
}
157157

158158
static int
@@ -235,7 +235,7 @@ hash_net4_uadt(struct ip_set *set, struct nlattr *tb[],
235235
return -IPSET_ERR_HASH_RANGE;
236236
}
237237
if (retried)
238-
ip = h->next.ip;
238+
ip = ntohl(h->next.ip);
239239
while (!after(ip, ip_to)) {
240240
data.ip = htonl(ip);
241241
last = ip_set_range_to_cidr(ip, ip_to, &data.cidr);

net/netfilter/ipset/ip_set_hash_netiface.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ static inline void
277277
hash_netiface4_data_next(struct ip_set_hash *h,
278278
const struct hash_netiface4_elem *d)
279279
{
280-
h->next.ip = ntohl(d->ip);
280+
h->next.ip = d->ip;
281281
}
282282

283283
static int
@@ -409,7 +409,7 @@ hash_netiface4_uadt(struct ip_set *set, struct nlattr *tb[],
409409
}
410410

411411
if (retried)
412-
ip = h->next.ip;
412+
ip = ntohl(h->next.ip);
413413
while (!after(ip, ip_to)) {
414414
data.ip = htonl(ip);
415415
last = ip_set_range_to_cidr(ip, ip_to, &data.cidr);

net/netfilter/ipset/ip_set_hash_netport.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ static inline void
171171
hash_netport4_data_next(struct ip_set_hash *h,
172172
const struct hash_netport4_elem *d)
173173
{
174-
h->next.ip = ntohl(d->ip);
175-
h->next.port = ntohs(d->port);
174+
h->next.ip = d->ip;
175+
h->next.port = d->port;
176176
}
177177

178178
static int
@@ -289,12 +289,13 @@ hash_netport4_uadt(struct ip_set *set, struct nlattr *tb[],
289289
}
290290

291291
if (retried)
292-
ip = h->next.ip;
292+
ip = ntohl(h->next.ip);
293293
while (!after(ip, ip_to)) {
294294
data.ip = htonl(ip);
295295
last = ip_set_range_to_cidr(ip, ip_to, &cidr);
296296
data.cidr = cidr - 1;
297-
p = retried && ip == h->next.ip ? h->next.port : port;
297+
p = retried && ip == ntohl(h->next.ip) ? ntohs(h->next.port)
298+
: port;
298299
for (; p <= port_to; p++) {
299300
data.port = htons(p);
300301
ret = adtfn(set, &data, timeout, flags);
@@ -450,7 +451,7 @@ static inline void
450451
hash_netport6_data_next(struct ip_set_hash *h,
451452
const struct hash_netport6_elem *d)
452453
{
453-
h->next.port = ntohs(d->port);
454+
h->next.port = d->port;
454455
}
455456

456457
static int
@@ -554,7 +555,7 @@ hash_netport6_uadt(struct ip_set *set, struct nlattr *tb[],
554555
swap(port, port_to);
555556

556557
if (retried)
557-
port = h->next.port;
558+
port = ntohs(h->next.port);
558559
for (; port <= port_to; port++) {
559560
data.port = htons(port);
560561
ret = adtfn(set, &data, timeout, flags);

0 commit comments

Comments
 (0)