rxrpc: avoid clang -Wuninitialized warning
Subsystems (3)
PATCH 1/1 rxrpc: avoid clang -Wuninitialized warning
clang produces a false-positive warning as it fails to notice that "lost = true" implies that "ret" is initialized:
net/rxrpc/output.c:402:6: error: variable 'ret' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
if (lost)
^~~~
net/rxrpc/output.c:437:6: note: uninitialized use occurs here
if (ret >= 0) {
^~~
net/rxrpc/output.c:402:2: note: remove the 'if' if its condition is always false
if (lost)
^~~~~~~~~
net/rxrpc/output.c:339:9: note: initialize the variable 'ret' to silence this warning
int ret, opt;
^
= 0Rearrange the code to make that more obvious and avoid the warning.
--- net/rxrpc/output.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
net/rxrpc/output.c +5 -6
@@ -335,7 +335,6 @@ int rxrpc_send_data_packet(struct rxrpc_call *call, struct sk_buff *skb,struct kvec iov[2 ];rxrpc_serial_t serial;size_t len; -bool lost = false;int ret, opt;_enter (",{%d}" , skb->len);
@@ -393,14 +392,14 @@ int rxrpc_send_data_packet(struct rxrpc_call *call, struct sk_buff *skb,static int lose;if ((lose++ &7 ) ==7 ) { ret =0 ; - lost = true; +trace_rxrpc_tx_data (call, sp->hdr.seq, serial, + whdr.flags, retrans, true); + goto done; } } -trace_rxrpc_tx_data (call, sp->hdr.seq, serial, whdr.flags, - retrans, lost); -if (lost) - goto done; +trace_rxrpc_tx_data (call, sp->hdr.seq, serial, whdr.flags, retrans, + false);/* send the packet with the don't fragment bit set if we currently * think it's small enough */
Signature · 1 line
2.20.0
Quoted 17 lines · Arnd Bergmann
clang produces a false-positive warning as it fails to notice that "lost = true" implies that "ret" is initialized:
net/rxrpc/output.c:402:6: error: variable 'ret' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]if (lost) ^~~~ net/rxrpc/output.c:437:6: note: uninitialized use occurs here if (ret >= 0) { ^~~ net/rxrpc/output.c:402:2: note: remove the 'if' if its condition is always false if (lost) ^~~~~~~~~ net/rxrpc/output.c:339:9: note: initialize the variable 'ret' to silence this warning int ret, opt; ^ = 0
Quoted 3 lines
Rearrange the code to make that more obvious and avoid the warning.
Signed-off-by Arnd Bergmann <[email protected]>
Quoted 39 lines
--- net/rxrpc/output.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)net/rxrpc/output.c +5
-6@@ -335,7 +335,6 @@ int rxrpc_send_data_packet(struct rxrpc_call *call, struct sk_buff *skb,struct kvec iov[2 ];rxrpc_serial_t serial;size_t len; -bool lost = false;int ret, opt;_enter (",{%d}" , skb->len);@@ -393,14 +392,14 @@ int rxrpc_send_data_packet(struct rxrpc_call *call, struct sk_buff *skb,static int lose;if ((lose++ &7 ) ==7 ) { ret =0 ; - lost = true; +trace_rxrpc_tx_data (call, sp->hdr.seq, serial, + whdr.flags, retrans, true); + goto done; } } -trace_rxrpc_tx_data (call, sp->hdr.seq, serial, whdr.flags, - retrans, lost); -if (lost) - goto done; +trace_rxrpc_tx_data (call, sp->hdr.seq, serial, whdr.flags, retrans, + false);/* send the packet with the don't fragment bit set if we currently * think it's small enough */ Signature · 1 line
2.20.0
From: Arnd Bergmann <[email protected]>
Date: Fri, 22 Mar 2019 15:18:43 +0100
Quoted 2 lines
clang produces a false-positive warning as it fails to notice that "lost = true" implies that "ret" is initialized:
...
Quoted 3 lines
Rearrange the code to make that more obvious and avoid the warning.
Signed-off-by Arnd Bergmann <[email protected]>
Applied.