From patchwork Wed Dec 6 16:41:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefano Garzarella X-Patchwork-Id: 13482023 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HvwHU/3w" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77510D4F for ; Wed, 6 Dec 2023 08:41:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701880916; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=BRBYbA6A9iVFJVJw2yLnCuRWTbq0bYeGysrV9jksr78=; b=HvwHU/3wBwdD8oPXKZ2+jR1CI5hSr+MJuSguM9HX7nXpd2cZH6S2D6PxOwqo4tYJcuM7NP 0/zD+/vmoqPpqJzujAOcdKB9OxHQKxiPDm+TxqH/+FxVOlgkvUpWJEeV8U3Y/X9YNhpNYI bjFrf39TuMgC85HBIA1fszBxXyXxFC0= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-264-FyV7u_otNz-G6OAE9XY7Qg-1; Wed, 06 Dec 2023 11:41:55 -0500 X-MC-Unique: FyV7u_otNz-G6OAE9XY7Qg-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-4239047911bso10994601cf.3 for ; Wed, 06 Dec 2023 08:41:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701880914; x=1702485714; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BRBYbA6A9iVFJVJw2yLnCuRWTbq0bYeGysrV9jksr78=; b=qVm6no0uQNtLpnF6/xUUZ3iq71r5XeQnqVEVwDYUV5+dwBw6uiZF99ZAHe1+xnfHEO aKjLmXvtZImQLDLflnrwSQs4pe7EuUu3FqP9ZldQWXqTFgF3kvNAm7dEKnumTTH+azRn Dv7yz0Ar4eiytp3CRX6PwTb1Jy65QNFyt2srGuHMpxLYjnMPb2k5uIgef6Z40YcIjCr8 +/j8vvXs2nOdnterDbgkFgBQsSF6bkNsSuxPiRNElUzr3DQJ9rFj2tl4uSB9rTJFqgNe hhiXyZ0TMMjUqT+iWlU8FczEj45iPnoOZ9ro9f44YP/xIxF+x8Xd2Zw1JnQwy/S8tusS p0BQ== X-Gm-Message-State: AOJu0Yy1rH7ODtaZEEbz9SvynDFYHM1YlfQXFr7sqzfhA9yFafHKkSDP c5bXwdd1PqKboQ8QP0mi8L3M+uQmwfM+DtPj7RtLKf3b7QtCwFo80Vdnvb2FlqClcIXPSj2zm+O GizTCtUm0q/vodLbpxLW4joWggXU5ItnvW4s2vbYAsexuYv1B+AiwCdqhZ6bLCZnrCCqScL/4So tH X-Received: by 2002:ac8:5b95:0:b0:425:4043:2a05 with SMTP id a21-20020ac85b95000000b0042540432a05mr1420278qta.128.1701880914675; Wed, 06 Dec 2023 08:41:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IFaJIB6NOvZQTIiVkkPSR38mjWBsiSx+xgzPD2epv6qC/zaKWzLLIvu6i12qCTPMRBfNOkUNA== X-Received: by 2002:ac8:5b95:0:b0:425:4043:2a05 with SMTP id a21-20020ac85b95000000b0042540432a05mr1420258qta.128.1701880914272; Wed, 06 Dec 2023 08:41:54 -0800 (PST) Received: from step1.redhat.com (host-79-46-200-125.retail.telecomitalia.it. [79.46.200.125]) by smtp.gmail.com with ESMTPSA id e25-20020ac86719000000b00423e8021da2sm78802qtp.42.2023.12.06.08.41.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 08:41:53 -0800 (PST) From: Stefano Garzarella To: netdev@vger.kernel.org Cc: Jakub Kicinski , "David S. Miller" , virtualization@lists.linux.dev, "Michael S. Tsirkin" , Arseniy Krasnov , Stefano Garzarella , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Hajnoczi , Eric Dumazet , Paolo Abeni Subject: [PATCH net] vsock/virtio: fix "comparison of distinct pointer types lacks a cast" warning Date: Wed, 6 Dec 2023 17:41:43 +0100 Message-ID: <20231206164143.281107-1-sgarzare@redhat.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain X-Patchwork-Delegate: kuba@kernel.org After backporting commit 581512a6dc93 ("vsock/virtio: MSG_ZEROCOPY flag support") in CentOS Stream 9, CI reported the following error: In file included from ./include/linux/kernel.h:17, from ./include/linux/list.h:9, from ./include/linux/preempt.h:11, from ./include/linux/spinlock.h:56, from net/vmw_vsock/virtio_transport_common.c:9: net/vmw_vsock/virtio_transport_common.c: In function ‘virtio_transport_can_zcopy‘: ./include/linux/minmax.h:20:35: error: comparison of distinct pointer types lacks a cast [-Werror] 20 | (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1))) | ^~ ./include/linux/minmax.h:26:18: note: in expansion of macro ‘__typecheck‘ 26 | (__typecheck(x, y) && __no_side_effects(x, y)) | ^~~~~~~~~~~ ./include/linux/minmax.h:36:31: note: in expansion of macro ‘__safe_cmp‘ 36 | __builtin_choose_expr(__safe_cmp(x, y), \ | ^~~~~~~~~~ ./include/linux/minmax.h:45:25: note: in expansion of macro ‘__careful_cmp‘ 45 | #define min(x, y) __careful_cmp(x, y, <) | ^~~~~~~~~~~~~ net/vmw_vsock/virtio_transport_common.c:63:37: note: in expansion of macro ‘min‘ 63 | int pages_to_send = min(pages_in_iov, MAX_SKB_FRAGS); We could solve it by using min_t(), but this operation seems entirely unnecessary, because we also pass MAX_SKB_FRAGS to iov_iter_npages(), which performs almost the same check, returning at most MAX_SKB_FRAGS elements. So, let's eliminate this unnecessary comparison. Fixes: 581512a6dc93 ("vsock/virtio: MSG_ZEROCOPY flag support") Cc: avkrasnov@salutedevices.com Signed-off-by: Stefano Garzarella Acked-by: Michael S. Tsirkin Reviewed-by: Arseniy Krasnov --- net/vmw_vsock/virtio_transport_common.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c index f6dc896bf44c..c8e162c9d1df 100644 --- a/net/vmw_vsock/virtio_transport_common.c +++ b/net/vmw_vsock/virtio_transport_common.c @@ -59,8 +59,7 @@ static bool virtio_transport_can_zcopy(const struct virtio_transport *t_ops, t_ops = virtio_transport_get_ops(info->vsk); if (t_ops->can_msgzerocopy) { - int pages_in_iov = iov_iter_npages(iov_iter, MAX_SKB_FRAGS); - int pages_to_send = min(pages_in_iov, MAX_SKB_FRAGS); + int pages_to_send = iov_iter_npages(iov_iter, MAX_SKB_FRAGS); /* +1 is for packet header. */ return t_ops->can_msgzerocopy(pages_to_send + 1);