diff mbox series

[kvmtool,3/3] virtio/rng: Fix build warning from min()

Message ID 20230606143733.994679-4-jean-philippe@linaro.org (mailing list archive)
State New, archived
Headers show
Series Build fixes | expand

Commit Message

Jean-Philippe Brucker June 6, 2023, 2:37 p.m. UTC
On a 32-bit build GCC complains about the min() parameters:

include/linux/kernel.h:36:24: error: comparison of distinct pointer types lacks a cast [-Werror]
   36 |         (void) (&_min1 == &_min2);              \
      |                        ^~
virtio/rng.c:78:34: note: in expansion of macro 'min'
   78 |                 iov[0].iov_len = min(iov[0].iov_len, 256UL);
      |                                  ^~~

Use min_t() instead

Fixes: bc23b9d9b152 ("virtio/rng: return at least one byte of entropy")
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
---
 virtio/rng.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/virtio/rng.c b/virtio/rng.c
index 77a3a113..6b366552 100644
--- a/virtio/rng.c
+++ b/virtio/rng.c
@@ -75,7 +75,7 @@  static bool virtio_rng_do_io_request(struct kvm *kvm, struct rng_dev *rdev, stru
 		 * just retry here, with the requested size clamped to that
 		 * maximum, in case we were interrupted by a signal.
 		 */
-		iov[0].iov_len = min(iov[0].iov_len, 256UL);
+		iov[0].iov_len = min_t(size_t, iov[0].iov_len, 256UL);
 		len = readv(rdev->fd, iov, 1);
 		if (len < 1)
 			return false;