ipv6: esp6: use BUG_ON instead of if condition followed by BUG
Subsystems (3)
PATCH 1/1 ipv6: esp6: use BUG_ON instead of if condition followed by BUG
Use BUG_ON instead of if condition followed by BUG in esp_remove_trailer.
This issue was detected with the help of Coccinelle.
--- net/ipv6/esp6.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/ipv6/esp6.c +1 -2
@@ -483,8 +483,7 @@ static inline int esp_remove_trailer(struct sk_buff *skb) goto out; } -if (skb_copy_bits (skb, skb->len - alen -2 , nexthdr,2 )) -BUG (); +BUG_ON (skb_copy_bits (skb, skb->len - alen -2 , nexthdr,2 )); ret = -EINVAL ; padlen = nexthdr[0 ];
Signature · 1 line
2.7.4
Herbert Xu
maintainerQuoted 14 lines · Gustavo A. R. Silva
Use
BUG_ONinstead of if condition followed by BUG inesp_remove_trailer.This issue was detected with the help of Coccinelle.
Signed-off-by Gustavo A. R. Silva <[email protected]>--- net/ipv6/esp6.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)net/ipv6/esp6.c +0
-0
net/ipv6/esp6.c static inline int esp_remove_trailer(struct sk_buff *skb) · line 486
Quoted 6 lines
net/ipv6/esp6.c +1
-2@@ -483,8 +483,7 @@ static inline int esp_remove_trailer(struct sk_buff *skb) goto out; } -if (skb_copy_bits (skb, skb->len - alen -2 , nexthdr,2 )) -BUG (); +BUG_ON (skb_copy_bits (skb, skb->len - alen -2 , nexthdr,2 ));
How about
ret = skb_copy_bits(skb, skb->len - alen - 2, nexthdr, 2); BUG_ON(ret);
Thanks,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
PATCH v2 1/1 ipv6: esp6: use BUG_ON instead of if condition followed by BUG
Use BUG_ON instead of if condition followed by BUG in esp_remove_trailer.
This issue was detected with the help of Coccinelle.
---
Changes in v2:
Update the code as suggested by Herbert Xu:
ret = foo();
BUG_ON(ret);
net/ipv6/esp6.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv6/esp6.c +2 -2
@@ -483,8 +483,8 @@ static inline int esp_remove_trailer(struct sk_buff *skb) goto out; } -if (skb_copy_bits (skb, skb->len - alen -2 , nexthdr,2 )) -BUG (); + ret =skb_copy_bits (skb, skb->len - alen -2 , nexthdr,2 ); +BUG_ON (ret); ret = -EINVAL ; padlen = nexthdr[0 ];
Signature · 1 line
2.7.4
Quoted 5 lines · Gustavo A. R. Silva
Use
BUG_ONinstead of if condition followed by BUG inesp_remove_trailer.This issue was detected with the help of Coccinelle.
Signed-off-by Gustavo A. R. Silva <[email protected]>
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Quoting Herbert Xu <[email protected]>:
Quoted 8 lines · Gustavo A. R. Silva
Quoted 5 lines
Use
BUG_ONinstead of if condition followed by BUG inesp_remove_trailer.This issue was detected with the help of Coccinelle.
Signed-off-by Gustavo A. R. Silva <[email protected]>Acked-by Herbert Xu <[email protected]>
Thanks!
--
Gustavo A. R. Silva
Quoted 8 lines · Herbert Xu
Quoted 5 lines · Gustavo A. R. Silva
Use
BUG_ONinstead of if condition followed by BUG inesp_remove_trailer.This issue was detected with the help of Coccinelle.
Signed-off-by Gustavo A. R. Silva <[email protected]>Acked-by Herbert Xu <[email protected]>
Applied to ipsec-next, thanks everyone!