Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp756391lqh; Thu, 28 Mar 2024 15:54:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXf7lwKSblwKFfFJgFDESGJFKNIIvJGJ/M/37ix3kCrqq//rfv7yGxVB+qJYUXG/jVQ18HRbNfog771PU6i60MCX5iiZTr5ZzktLwjxTA== X-Google-Smtp-Source: AGHT+IH1E3TxD/GOQEHlThbWW2kfiG/p8yCM1Ttsh5c9CcJ1AwAo58VFM1IQFxGgHFgDUs6Eqtke X-Received: by 2002:a05:6808:ec2:b0:3c3:bf11:a628 with SMTP id q2-20020a0568080ec200b003c3bf11a628mr713614oiv.51.1711666439996; Thu, 28 Mar 2024 15:53:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711666439; cv=pass; d=google.com; s=arc-20160816; b=lqE1Qk8GMUgm4vhTtYACYPePRBGDTwTvqiRQN07aR/5aNScAIgjZ6AkvI2+qHfrWHl fBRA+jGwOVrGMLBGtinb6aLs74mWTzvTIlq9Cm4/Ei4ehNWwwLdesExYFp60tptCAYXQ sCg2WWnznJO09l1K0wUHvd2Xx6QT09OyXGn3+IJwARaBZyJM+W5jg58JaRQBDpLhmnip 5zgyHr1OyAXw7cFUwISD97LUkrqbIhfhVFZyxHqrQrFSBZHiUILH4meCVG+iq7FfdcAT vEdk6YUu945gZUpuIdB/r9EcgZ75wYFO2NxkGraOUnGbbEOphlFHbeqnn4KEWOpsni/n SvQA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=TEbIDW7kbPaE87dBPORDU/rsnpNPLPoHlh1VVnWn9NA=; fh=uwncOELh8Py51V4O3MlVZa+ndGWRJlKv709lzhBM8V0=; b=cjjiaA3JUAdRIsIJeEUGIwcGgxde/0hx6bwswPctg/fuiADJbmpgN4bs/cFfOiVVyH U0BTtqXzod6cFhoC0fdd2B8RXR98r8o02RAT0rkAdJeE5gREdFOLKVDyyyUABpo21LE3 qbXGD+dTAhRXhzdXVnXP59gATVcI7yPX7WnmXzr878VU6E/b+l+iHgYMX8LUSWGfAvFD Py+4kiuK+Nq8/UuHiSHFQhDufMvB+YnRHzHp4Jo+S9HFXRKbWBOCSN/Ru8S/306Q5V52 K27Qb0TNiq+oidbKX7UV70Ge8AeBK6NJbK28pQMjdw/ujsHAOizBprZdU11p5XtKsbRT z0bg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=GjvVCqp+; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-123791-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123791-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 9-20020ac85909000000b004315f07d619si2363290qty.393.2024.03.28.15.53.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 15:53:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-123791-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=GjvVCqp+; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-123791-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123791-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B1D201C23064 for ; Thu, 28 Mar 2024 22:53:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ADB835381D; Thu, 28 Mar 2024 22:53:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="GjvVCqp+" Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 473B81D68F for ; Thu, 28 Mar 2024 22:53:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711666430; cv=none; b=OgA0yRkSPgq4KlVN/08iMq3m5n9WIaufQg68k1qpFExbebFUjm3HG2DIwbpHuPydlDPwbOLdbnz2djZvGIe/tdcCeR/9zaKs9s+SbH04hVWU0KBHyfP2dcbRPu8Ilx6kPRgPaDQs6qmyCS80O3Oz5u2LrFJFXs8+k2Z/vJWT1U8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711666430; c=relaxed/simple; bh=m2sHr69UQ23/+yNNagVCVSd+tL9gNcumuplvgXMM3eE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=fcE3oMa4k7mmxwPsEWrms06B/dmZEyIGknZ4ZmhlweLcH0zAo7rqWEoBq1Gp8GM5fsDl3uMc0sjb7Mc6kANHNgbTlSY04bhk+lgleZ9BICwZJXZXj0UDX1Npm05Z7Imi36BJXvKlWXVuve8hw3gaFAR1QVqVgMEaJ0mD3xQUbMA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=GjvVCqp+; arc=none smtp.client-ip=209.85.208.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-56899d9bf52so1954743a12.2 for ; Thu, 28 Mar 2024 15:53:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1711666428; x=1712271228; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=TEbIDW7kbPaE87dBPORDU/rsnpNPLPoHlh1VVnWn9NA=; b=GjvVCqp+UrkJj/Q1BkHxcMX1d1B0WrYzJZU4b12Im5rjUMSk/I1e59Gl2QrWEdObM3 WVc/EDOfGYTRdrVD47dbkVYM7MuIf37jur8eZgPmL+8hG7PgTYwfXzifmBWzk8lveWAu pL0hI0UrIrSW/nh8lmgfAbsXzygVZWxD4TtHdgZcC4pdTnUigPdjglq+uAMNxGA2jvri K6tZOk2oF/XSN3H5BV90vwHs0JQbplddepfes2CCS4QTGh07WMaBJrLApLTdwTjGhLPZ EGKKa3bVP2Cb8BAMFjmMMbQTMCoCKjcFvd0keKtBzIICixLNsRrR6gCAEJa8cbc6+Mid zDzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711666428; x=1712271228; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TEbIDW7kbPaE87dBPORDU/rsnpNPLPoHlh1VVnWn9NA=; b=qwOmx3JPP+zFkjf9zKvx2mgkhGcSxaX5I1XWPzyHV7tJhcZdKiYSjp9AsN4d7DYMUN 43+b19uuA9KyciYvxFZ8N8kIc4IHLdrW+8OT/1abOjL3IjPYw+/au6NAtYplVCh5GSk5 P5MsD2qOl5lmu58LpIXfkcwbAnwvsR4fAKkOeTxzGehsrTdZreN9sU03wjjI/sYHjNqD Wjbzp9qz+6r0YNaCLSlXt5WeynYjLu87uFWBsCUMXgUbrs2RuZCqk9BQNsTEUcHSObzJ REVICIv+TXM4qr29QoZoCgoLi8R8qZwgcVfZP83yOddAppMdoNo+4kx5bF1zmEJQ1XrZ ZdBw== X-Gm-Message-State: AOJu0Yz3rCNcRvdV756lhPXuxs73EKRN6eiof1ulN+Mg5wyEymDh745N dbHqx6G+9X2IefmNXzBjR79d0MilhCtXCeERrSUzDiU9L81DBs48Ois6SmgsUuml3VKqTCs0B4u 53eg/rzqfGdCGyYVEFpCDd4f8xSV0lt0eB4oo X-Received: by 2002:a05:6402:254a:b0:56b:e089:56ed with SMTP id l10-20020a056402254a00b0056be08956edmr540944edb.39.1711666427673; Thu, 28 Mar 2024 15:53:47 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240328143051.1069575-1-arnd@kernel.org> <20240328143051.1069575-3-arnd@kernel.org> In-Reply-To: <20240328143051.1069575-3-arnd@kernel.org> From: Justin Stitt Date: Thu, 28 Mar 2024 15:53:35 -0700 Message-ID: Subject: Re: [PATCH 2/9] libceph: avoid clang out-of-range warning To: Arnd Bergmann Cc: linux-kernel@vger.kernel.org, Xiubo Li , Ilya Dryomov , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Nathan Chancellor , Arnd Bergmann , Jeff Layton , Nick Desaulniers , Bill Wendling , Milind Changire , Patrick Donnelly , Christian Brauner , ceph-devel@vger.kernel.org, netdev@vger.kernel.org, llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Mar 28, 2024 at 7:31=E2=80=AFAM Arnd Bergmann wro= te: > > From: Arnd Bergmann > > clang-14 points out that on 64-bit architectures, a u32 > is never larger than constant based on SIZE_MAX: > > net/ceph/osdmap.c:1425:10: error: result of comparison of constant 461168= 6018427387891 with expression of type 'u32' (aka 'unsigned int') is always = false [-Werror,-Wtautological-constant-out-of-range-compare] > if (len > (SIZE_MAX - sizeof(*pg)) / sizeof(u32)) > ~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > net/ceph/osdmap.c:1608:10: error: result of comparison of constant 230584= 3009213693945 with expression of type 'u32' (aka 'unsigned int') is always = false [-Werror,-Wtautological-constant-out-of-range-compare] > if (len > (SIZE_MAX - sizeof(*pg)) / (2 * sizeof(u32))) > ~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > The code is correct anyway, so just shut up that warning. OK. > > Fixes: 6f428df47dae ("libceph: pg_upmap[_items] infrastructure") > Signed-off-by: Arnd Bergmann Reviewed-by: Justin Stitt > --- > fs/ceph/snap.c | 2 +- > net/ceph/osdmap.c | 4 ++-- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c > index c65f2b202b2b..521507ea8260 100644 > --- a/fs/ceph/snap.c > +++ b/fs/ceph/snap.c > @@ -374,7 +374,7 @@ static int build_snap_context(struct ceph_mds_client = *mdsc, > > /* alloc new snap context */ > err =3D -ENOMEM; > - if (num > (SIZE_MAX - sizeof(*snapc)) / sizeof(u64)) > + if ((size_t)num > (SIZE_MAX - sizeof(*snapc)) / sizeof(u64)) > goto fail; > snapc =3D ceph_create_snap_context(num, GFP_NOFS); > if (!snapc) > diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c > index 295098873861..8e7cb2fde6f1 100644 > --- a/net/ceph/osdmap.c > +++ b/net/ceph/osdmap.c > @@ -1438,7 +1438,7 @@ static struct ceph_pg_mapping *__decode_pg_temp(voi= d **p, void *end, > ceph_decode_32_safe(p, end, len, e_inval); > if (len =3D=3D 0 && incremental) > return NULL; /* new_pg_temp: [] to remove */ > - if (len > (SIZE_MAX - sizeof(*pg)) / sizeof(u32)) > + if ((size_t)len > (SIZE_MAX - sizeof(*pg)) / sizeof(u32)) > return ERR_PTR(-EINVAL); > > ceph_decode_need(p, end, len * sizeof(u32), e_inval); > @@ -1621,7 +1621,7 @@ static struct ceph_pg_mapping *__decode_pg_upmap_it= ems(void **p, void *end, > u32 len, i; > > ceph_decode_32_safe(p, end, len, e_inval); > - if (len > (SIZE_MAX - sizeof(*pg)) / (2 * sizeof(u32))) > + if ((size_t)len > (SIZE_MAX - sizeof(*pg)) / (2 * sizeof(u32))) > return ERR_PTR(-EINVAL); > > ceph_decode_need(p, end, 2 * len * sizeof(u32), e_inval); > -- > 2.39.2 >