[PATCH] net: qrtr: use protocol endiannes variable

Subsystems: networking [general], qualcomm ipc router (qrtr) driver, the rest

STALE2689d

3 messages, 3 authors, 2019-05-11 · open the first message on its own page

[PATCH] net: qrtr: use protocol endiannes variable

From: Nicholas Mc Guire <hidden>
Date: 2019-05-10 01:15:15

sparse was unable to verify endianness correctness due to reassignment
from le32_to_cpu to the same variable - fix this warning up by providing
a proper __le32 type and initializing it. This is not actually fixing
any bug - rather just addressing the sparse warning.

Signed-off-by: Nicholas Mc Guire <redacted>
---

Problem located by an experimental coccinelle script to locate
patters that make sparse unhappy (false positives):

sparse was unhappy about:
net/qrtr/qrtr.c:811:24: warning: cast to restricted __le32

The patch does change the binary - from inspection of the .lst files
it seems that the additional variable as well instruction reordering
constraints change the code even if the code-logic is the same.

Patch was compile-tested with: qcom_defconfig + QRTR=m

Patch is against 5.1 (localversion-next is next-20190509)

 net/qrtr/qrtr.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c
index dd0e97f..c90edaa 100644
--- a/net/qrtr/qrtr.c
+++ b/net/qrtr/qrtr.c
@@ -733,7 +733,8 @@ static int qrtr_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
 	struct qrtr_node *node;
 	struct sk_buff *skb;
 	size_t plen;
-	u32 type = QRTR_TYPE_DATA;
+	u32 type = 0;
+	__le32 qrtr_type = cpu_to_le32(QRTR_TYPE_DATA);
 	int rc;
 
 	if (msg->msg_flags & ~(MSG_DONTWAIT))
@@ -807,8 +808,8 @@ static int qrtr_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
 		}
 
 		/* control messages already require the type as 'command' */
-		skb_copy_bits(skb, 0, &type, 4);
-		type = le32_to_cpu(type);
+		skb_copy_bits(skb, 0, &qrtr_type, 4);
+		type = le32_to_cpu(qrtr_type);
 	}
 
 	rc = enqueue_fn(node, skb, type, &ipc->us, addr);
-- 
2.1.4

Re: [PATCH] net: qrtr: use protocol endiannes variable

From: David Miller <davem@davemloft.net>
Date: 2019-05-10 20:28:05

From: Nicholas Mc Guire <redacted>
Date: Fri, 10 May 2019 03:08:53 +0200
quoted hunk
diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c
index dd0e97f..c90edaa 100644
--- a/net/qrtr/qrtr.c
+++ b/net/qrtr/qrtr.c
@@ -733,7 +733,8 @@ static int qrtr_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
 	struct qrtr_node *node;
 	struct sk_buff *skb;
 	size_t plen;
-	u32 type = QRTR_TYPE_DATA;
+	u32 type = 0;
+	__le32 qrtr_type = cpu_to_le32(QRTR_TYPE_DATA);
 	int rc;
Please try to preserve as much of the reverse chrimstas tree here rather
than making it worse.

Thank you.

Re: [PATCH] net: qrtr: use protocol endiannes variable

From: Nicholas Mc Guire <hidden>
Date: 2019-05-11 00:18:39

On Fri, May 10, 2019 at 01:28:00PM -0700, David Miller wrote:
From: Nicholas Mc Guire <redacted>
Date: Fri, 10 May 2019 03:08:53 +0200
quoted
diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c
index dd0e97f..c90edaa 100644
--- a/net/qrtr/qrtr.c
+++ b/net/qrtr/qrtr.c
@@ -733,7 +733,8 @@ static int qrtr_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
 	struct qrtr_node *node;
 	struct sk_buff *skb;
 	size_t plen;
-	u32 type = QRTR_TYPE_DATA;
+	u32 type = 0;
+	__le32 qrtr_type = cpu_to_le32(QRTR_TYPE_DATA);
 	int rc;
Please try to preserve as much of the reverse chrimstas tree here rather
than making it worse.
sorry - did not really think about that at all  - will re-order the declarations and resend

thx!
hofrat 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help