Skip to contentSkip to conversation

xen-netback: fix type mismatch warning

PATCH Applied Arnd Bergmann 3 participants 4 messages Oct 12, 2016 – Oct 13, 2016

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

PATCH 1/1 xen-netback: fix type mismatch warning

Wiht the latest rework of the xen-netback driver, we get a warning on ARM about the types passed into min():

drivers/net/xen-netback/rx.c: In function 'xenvif_rx_next_chunk':
include/linux/kernel.h:739:16: error: comparison of distinct pointer types lacks a cast [-Werror]

The reason is that XEN_PAGE_SIZE is not size_t here. There is no actual bug, and we can easily avoid the warning using the min_t() macro instead of min().

Fixes eb1723a29b9a ("xen-netback: refactor guest rx")
---
 drivers/net/xen-netback/rx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/xen-netback/rx.c +3 -3
index 8e9ade6ccf18..aeb150258c6c 100644
@@ -337,9 +337,9 @@ static void xenvif_rx_next_chunk(struct xenvif_queue *queue,
 	frag_data += pkt->frag_offset;
 	frag_len -= pkt->frag_offset;
 
-	chunk_len = min(frag_len, XEN_PAGE_SIZE - offset);
-	chunk_len = min(chunk_len,
-			XEN_PAGE_SIZE -	xen_offset_in_page(frag_data));
+	chunk_len = min_t(size_t, frag_len, XEN_PAGE_SIZE - offset);
+	chunk_len = min_t(size_t, chunk_len, XEN_PAGE_SIZE -
+					     xen_offset_in_page(frag_data));
 
 	pkt->frag_offset += chunk_len;
 
Signature · 1 line
2.9.0
Acked-by on v1 1/1
#1 lore raw
Quoted 17 lines

-----Original Message-----
From: Arnd Bergmann [mailto:[email protected]]
Sent: 12 October 2016 10:54
To: Wei Liu <[email protected]>; Paul Durrant <[email protected]>
Cc: Arnd Bergmann <[email protected]>; David S. Miller <[email protected]>; David Vrabel <[email protected]>; xen- [email protected]; [email protected]; linux- [email protected]
Subject: [PATCH] xen-netback: fix type mismatch warning

Wiht the latest rework of the xen-netback driver, we get a warning on ARM about the types passed into min():

drivers/net/xen-netback/rx.c: In function 'xenvif_rx_next_chunk':
include/linux/kernel.h:739:16: error: comparison of distinct pointer types lacks a cast [-Werror]

Quoted 6 lines

The reason is that XEN_PAGE_SIZE is not size_t here. There is no actual bug, and we can easily avoid the warning using the min_t() macro instead of min().

Fixes eb1723a29b9a ("xen-netback: refactor guest rx")

LGTM

Quoted 25 lines
---
 drivers/net/xen-netback/rx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/xen-netback/rx.c +3 -3
index 8e9ade6ccf18..aeb150258c6c 100644
@@ -337,9 +337,9 @@ static void xenvif_rx_next_chunk(struct
 xenvif_queue *queue,
 	frag_data += pkt->frag_offset;
 	frag_len -= pkt->frag_offset;
 
-	chunk_len = min(frag_len, XEN_PAGE_SIZE - offset);
-	chunk_len = min(chunk_len,
-			XEN_PAGE_SIZE -
 	xen_offset_in_page(frag_data));
+	chunk_len = min_t(size_t, frag_len, XEN_PAGE_SIZE - offset);
+	chunk_len = min_t(size_t, chunk_len, XEN_PAGE_SIZE -
+					     xen_offset_in_page(frag_data));
 

pkt->frag_offset += chunk_len;

--
2.9.0

Acked-by on v1 1/1
#2 lore raw
In reply to Arnd Bergmann
Quoted 17 lines

-----Original Message-----
From: Arnd Bergmann [mailto:[email protected]]
Sent: 12 October 2016 10:54
To: Wei Liu <[email protected]>; Paul Durrant <[email protected]>
Cc: Arnd Bergmann <[email protected]>; David S. Miller <[email protected]>; David Vrabel <[email protected]>; xen- [email protected]; [email protected]; linux- [email protected]
Subject: [PATCH] xen-netback: fix type mismatch warning

Wiht the latest rework of the xen-netback driver, we get a warning on ARM about the types passed into min():

drivers/net/xen-netback/rx.c: In function 'xenvif_rx_next_chunk':
include/linux/kernel.h:739:16: error: comparison of distinct pointer types lacks a cast [-Werror]

Quoted 6 lines

The reason is that XEN_PAGE_SIZE is not size_t here. There is no actual bug, and we can easily avoid the warning using the min_t() macro instead of min().

Fixes eb1723a29b9a ("xen-netback: refactor guest rx")

LGTM

Quoted 23 lines
---
 drivers/net/xen-netback/rx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/xen-netback/rx.c +3 -3
index 8e9ade6ccf18..aeb150258c6c 100644
@@ -337,9 +337,9 @@ static void xenvif_rx_next_chunk(struct
 xenvif_queue *queue,
 	frag_data += pkt->frag_offset;
 	frag_len -= pkt->frag_offset;
 
-	chunk_len = min(frag_len, XEN_PAGE_SIZE - offset);
-	chunk_len = min(chunk_len,
-			XEN_PAGE_SIZE -
 	xen_offset_in_page(frag_data));
+	chunk_len = min_t(size_t, frag_len, XEN_PAGE_SIZE - offset);
+	chunk_len = min_t(size_t, chunk_len, XEN_PAGE_SIZE -
+					     xen_offset_in_page(frag_data));
 

pkt->frag_offset += chunk_len;

Quoted 2 lines

--
2.9.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

maintainer Applied
#3 lore raw
In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>
Date: Wed, 12 Oct 2016 16:54:01 +0200

Quoted 6 lines

Wiht the latest rework of the xen-netback driver, we get a warning on ARM about the types passed into min():

drivers/net/xen-netback/rx.c: In function 'xenvif_rx_next_chunk':
include/linux/kernel.h:739:16: error: comparison of distinct pointer types lacks a cast [-Werror]

Quoted 6 lines

The reason is that XEN_PAGE_SIZE is not size_t here. There is no actual bug, and we can easily avoid the warning using the min_t() macro instead of min().

Fixes eb1723a29b9a ("xen-netback: refactor guest rx")

Applied, thanks.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel