commit | 0c9f79be295c99ac7e4b569ca493d75fdcc19e4e | [log] [tgz] |
---|---|---|
author | Xi Wang <xi.wang@gmail.com> | Sun Nov 11 11:20:01 2012 +0000 |
committer | David S. Miller <davem@davemloft.net> | Sun Nov 11 17:53:13 2012 -0500 |
tree | 86ac3ac72907079585afc43ec2a25edcb8bb051b | |
parent | 77b67063bb6bce6d475e910d3b886a606d0d91f7 [diff] |
ipv4: avoid undefined behavior in do_ip_setsockopt() (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>