Thread (7 messages) flat view 7 messages, 5 authors, 2021-09-08

Re: [PATCH net v2] net: netfilter: Fix port selection of FTP for NF_NAT_RANGE_PROTO_SPECIFIED

From: Jan Engelhardt <hidden>
Date: 2021-09-08 06:53:18
Also in: lkml, netfilter-devel

On Wednesday 2021-09-08 04:22, Duncan Roe wrote:
quoted
quoted
Either use if (nat->range_info.min_proto.all || ...

or use ntohs().  I will leave it up to you if you prefer
ntohs(nat->range_info.min_proto.all) == 0 or
nat->range_info.min_proto.all == ntohs(0).
If one has the option, one should always prefer to put htons/htonl on
the side with the constant literal;
Propagation of constants and compile-time evaluation is the target.

That works for some other functions as well (e.g.
strlen("fixedstring")).
When comparing against constant zero, why use htons/htonl at all?
Logical correctness.
Remember, it was the sparse tool that complained in the first place.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help