From: Alexey Dobriyan <adobri...@gmail.com> Date: Fri, 2 Dec 2016 03:59:06 +0300
> nla_ok() consists of 3 clauses: > > 1) int rem >= (int)sizeof(struct nlattr) > > 2) u16 nla_len >= sizeof(struct nlattr) > > 3) u16 nla_len <= int rem > > The statement is that clause (1) is redundant. > > What it does is ensuring that "rem" is a positive number, > so that in clause (3) positive number will be compared to positive number > with no problems. > > However, "u16" fully fits into "int" and integers do not change value > when upcasting even to signed type. Negative integers will be rejected > by clause (3) just fine. Small positive integers will be rejected > by transitivity of comparison operator. > > NOTE: all of the above DOES NOT apply to nlmsg_ok() where ->nlmsg_len is > u32(!), so 3 clauses AND A CAST TO INT are necessary. > > Obligatory space savings report: -1.6 KB ... > Signed-off-by: Alexey Dobriyan <adobri...@gmail.com> Looks fine, applied to net-next, thanks.