diff options
author | Xi Wang <xi.wang@gmail.com> | 2012-11-11 11:20:01 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-11-26 11:34:35 -0800 |
commit | 26aeb8bdda7619453e0958e8c38a84c7add3643b (patch) | |
tree | 21f98a9d79e5e323b37cffd71850b81c9e41ea3c /virt | |
parent | 345d88cfbdd56cab94faf80554fe000f19a51576 (diff) |
ipv4: avoid undefined behavior in do_ip_setsockopt()
[ Upstream commit 0c9f79be295c99ac7e4b569ca493d75fdcc19e4e ]
(1<<optname) is undefined behavior in C with a negative optname or
optname larger than 31. In those cases the result of the shift is
not necessarily zero (e.g., on x86).
This patch simplifies the code with a switch statement on optname.
It also allows the compiler to generate better code (e.g., using a
64-bit mask).
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'virt')
0 files changed, 0 insertions, 0 deletions