Skip to contentSkip to conversation

NFC:Fix Warning: Comparison to bool

PATCH In review Runzhe Wang 2 participants 2 messages Nov 26, 2020 – Nov 27, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NFC:Fix Warning: Comparison to bool

This patch uses the shdlc->rnr variable as a judgment condition of statement, rather than compares with bool.

---
 net/nfc/hci/llc_shdlc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/nfc/hci/llc_shdlc.c +1 -1
index 0eb4ddc..f178a42 100644
@@ -319,7 +319,7 @@ static void llc_shdlc_rcv_s_frame(struct llc_shdlc *shdlc,
 	switch (s_frame_type) {
 	case S_FRAME_RR:
 		llc_shdlc_rcv_ack(shdlc, nr);
-		if (shdlc->rnr == true) {	/* see SHDLC 10.7.7 */
+		if (shdlc->rnr) {	/* see SHDLC 10.7.7 */
 			shdlc->rnr = false;
 			if (shdlc->send_q.qlen == 0) {
 				skb = llc_shdlc_alloc_skb(shdlc, 0);
Signature · 1 line
1.8.3.1
maintainer
#1 lore raw
Quoted 5 lines · On Thu, 26 Nov 2020 15:15:42 +0800 Runzhe Wang wrote:

This patch uses the shdlc->rnr variable as a judgment condition of statement, rather than compares with bool.

"Fix Warning" sounds like you're addressing a real compiler warning, please use a more suitable subject if the warning in question is from your own tool. Like "nfc: refactor unnecessary comparison to bool".

net/nfc/hci/llc_shdlc.c static void llc_shdlc_rcv_s_frame(struct llc_shdlc *shdlc, · line 322

Quoted 10 lines
net/nfc/hci/llc_shdlc.c +1 -1
index 0eb4ddc..f178a42 100644
@@ -319,7 +319,7 @@ static void llc_shdlc_rcv_s_frame(struct llc_shdlc *shdlc,
 	switch (s_frame_type) {
 	case S_FRAME_RR:
 		llc_shdlc_rcv_ack(shdlc, nr);
-		if (shdlc->rnr == true) {	/* see SHDLC 10.7.7 */
+		if (shdlc->rnr) {	/* see SHDLC 10.7.7 */

rnr is a bool, this is perfectly legal, there are also comparisons to false which you don't fix, and nobody has touched this driver in 8 years so polishing this code is not exactly worth the effort.

I'm not applying this patch, sorry.

Quoted 3 lines
net/nfc/hci/llc_shdlc.c +0 -0
 			shdlc->rnr = false;
 			if (shdlc->send_q.qlen == 0) {
 				skb = llc_shdlc_alloc_skb(shdlc, 0);