Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp530260imp; Wed, 20 Feb 2019 04:39:05 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ3pykpQtg0SB7gODYjKn8vlyWw1/yea6eyRLnO2wGQExc2WyPP6+k8jp4HrpxGH2dgu6GQ X-Received: by 2002:a62:1212:: with SMTP id a18mr34580279pfj.177.1550666345842; Wed, 20 Feb 2019 04:39:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550666345; cv=none; d=google.com; s=arc-20160816; b=en3S6TvuQxC4p4jRwBh63D9uwRvPwZYXmvFkQLLwQoB9t4BuD5Cq8Ua/TqTMw/3Rbq 0k3HidVvY87XjD8yCJNKMIKdwBCuarty5MwSFhGtbuer/62CfdG7zefPhsnIP3/H8IdV C93Qnwt2tUTr+13iOe/B5nrm3nd5VP4PU8nj6EpQffvub4SGPUprjMbw27JmDZj5IZv2 S/p7ebgp6rd0khAUqZ8hrTGZIKxaSguXYt7JHnFrpQwfQFzpkqs0dAyaPH/YbJuZuI1z gYl3q2x/wgixVuNWWMwoebBanuqx8METc84wURoRa7fM28/63CRU6AjeHEvhtMfGzBRF qhTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject; bh=bZN2mFU4slxActyD1EOB2j1zoWCK0AEdW+8G1AdzaZ4=; b=XYm9pZtesn+KIGU+Q9sK1hn4b5CkDlBaAOWJ8oa+vWVPuHY/0qy5Qtyb6WHHn28nEd vanQlRVtCMPTmOLqCJqlu6eRkA1G8qXdMXtMaHwWBLYkXpR4Sf/R7IOSg9XNQcItyAUf 556VOXtkxn21hAQtV/jTs35Q+071mlMTfor9tmjYmv8IRJgvAfQO08EcnD0+wzwrWpIp iFYpmtQXkvsIrWQDBf4DC+Ta5Clbz1l/jaPpq8bVTxW5ixjNKAkb3A9bfRCgOj7qSbm5 zoFRIV1cw6lgYsn+T8cgOroyeoOcuzMhYMlSoTfG+r+PPiuwbT+5LXzOpI6uKRFTmK37 u3kA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y16si10916894pll.83.2019.02.20.04.38.49; Wed, 20 Feb 2019 04:39:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727751AbfBTMgz (ORCPT + 99 others); Wed, 20 Feb 2019 07:36:55 -0500 Received: from mout.gmx.net ([212.227.15.18]:53061 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725812AbfBTMgz (ORCPT ); Wed, 20 Feb 2019 07:36:55 -0500 Received: from [0.0.0.0] ([54.250.245.166]) by mail.gmx.com (mrgmx003 [212.227.17.184]) with ESMTPSA (Nemesis) id 0MNZ9u-1gzCGY0eUs-0079ye; Wed, 20 Feb 2019 13:36:33 +0100 Subject: Re: [PATCH v2 -next] btrfs: Remove unnecessary casts in btrfs_read_root_item To: YueHaibing , Chris Mason , Josef Bacik , David Sterba Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Dan Carpenter References: <20190220030840.188854-1-yuehaibing@huawei.com> <20190220123202.43256-1-yuehaibing@huawei.com> From: Qu Wenruo Openpgp: preference=signencrypt Autocrypt: addr=quwenruo.btrfs@gmx.com; prefer-encrypt=mutual; keydata= mQ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1fN GSsRb+pKEKHKtL1803x71zQxCwLh+zLP1iXHVM5j8gX9zqupigQR/Cel2XPS44zWcDW8r7B0 q1eW4Jrv0x19p4P923voqn+joIAostyNTUjCeSrUdKth9jcdlam9X2DziA/DHDFfS5eq4fEv ABEBAAGJATwEGAEIACYWIQQt33LlpaVbqJ2qQuHCPZHzoSX+qAUCWdWBrwIbDAUJA8JnAAAK CRDCPZHzoSX+qA3xB/4zS8zYh3Cbm3FllKz7+RKBw/ETBibFSKedQkbJzRlZhBc+XRwF61mi f0SXSdqKMbM1a98fEg8H5kV6GTo62BzvynVrf/FyT+zWbIVEuuZttMk2gWLIvbmWNyrQnzPl mnjK4AEvZGIt1pk+3+N/CMEfAZH5Aqnp0PaoytRZ/1vtMXNgMxlfNnb96giC3KMR6U0E+siA 4V7biIoyNoaN33t8m5FwEwd2FQDG9dAXWhG13zcm9gnk63BN3wyCQR+X5+jsfBaS4dvNzvQv h8Uq/YGjCoV1ofKYh3WKMY8avjq25nlrhzD/Nto9jHp8niwr21K//pXVA81R2qaXqGbql+zo Message-ID: Date: Wed, 20 Feb 2019 20:36:18 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: <20190220123202.43256-1-yuehaibing@huawei.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="VQAk2EcGfbtQYq2ZG4Nplb3a1xKgKxeFb" X-Provags-ID: V03:K1:reF3fUZUV7wwrrdARKnASNl35BcFfdtvb7R1cEv6vrVvAKKv0bG PCPrNGBzR/liGRcatuWpcXFTPEUfW7bqs0TZKDyBhF4HahLmL26BJhkkO4JFO15wRKYKJYq 2WRDIZ1j/I1P/zjbFrpxEZjyofjCrVOko+9mnVG0C/TtY7HMmrMno8z2hbgZqr0yV+0ZsWp FSelrA9zoIYyvwhnPsDjA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:WoyLNsI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S YHSBtOtmtMP2Z4oAB4ifjeAx9d9TDZNmDEHkrSV4H/kDHz7Y3Tp0w+dFY46gmJr0vY9MYv+WH lcv+w3YlR7MbWc= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --VQAk2EcGfbtQYq2ZG4Nplb3a1xKgKxeFb Content-Type: multipart/mixed; boundary="EKwfjgP3xMdvfGuJ97upe0lFn9qkFvCVQ"; protected-headers="v1" From: Qu Wenruo To: YueHaibing , Chris Mason , Josef Bacik , David Sterba Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Dan Carpenter Message-ID: Subject: Re: [PATCH v2 -next] btrfs: Remove unnecessary casts in btrfs_read_root_item References: <20190220030840.188854-1-yuehaibing@huawei.com> <20190220123202.43256-1-yuehaibing@huawei.com> In-Reply-To: <20190220123202.43256-1-yuehaibing@huawei.com> --EKwfjgP3xMdvfGuJ97upe0lFn9qkFvCVQ Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 2019/2/20 =E4=B8=8B=E5=8D=888:32, YueHaibing wrote: > There is a messy cast here: > min_t(int, len, (int)sizeof(*item))); >=20 > min_t() should normally cast to unsigned. It's not possible for > "len" to be negative, but if it were then we definitely > wouldn't want to pass negatives to read_extent_buffer(). Also there > is an extra cast. >=20 > This patch shouldn't affect runtime, it's just a clean up. >=20 > Suggested-by: Dan Carpenter > Signed-off-by: YueHaibing Reviewed-by: Qu Wenruo The commit message is much better. Thanks, Qu > --- > v2: modify commit message as Dan suggested=20 > --- > fs/btrfs/root-tree.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c > index 02d1a57af78b..893d12fbfda0 100644 > --- a/fs/btrfs/root-tree.c > +++ b/fs/btrfs/root-tree.c > @@ -21,12 +21,12 @@ static void btrfs_read_root_item(struct extent_buff= er *eb, int slot, > struct btrfs_root_item *item) > { > uuid_le uuid; > - int len; > + u32 len; > int need_reset =3D 0; > =20 > len =3D btrfs_item_size_nr(eb, slot); > read_extent_buffer(eb, item, btrfs_item_ptr_offset(eb, slot), > - min_t(int, len, (int)sizeof(*item))); > + min_t(u32, len, sizeof(*item))); > if (len < sizeof(*item)) > need_reset =3D 1; > if (!need_reset && btrfs_root_generation(item) >=20 >=20 >=20 --EKwfjgP3xMdvfGuJ97upe0lFn9qkFvCVQ-- --VQAk2EcGfbtQYq2ZG4Nplb3a1xKgKxeFb Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEELd9y5aWlW6idqkLhwj2R86El/qgFAlxtScIACgkQwj2R86El /qgv9wgAkCODEPZ6E8+ECLbmeSimSxlkehYyYdrPx91jRrIjoNhfDnedWnKGqlKE nMkeBkttD8URGblky+23lRl76XQl+nEBuz3IOlAPwOhLKjCkZaMe+nVaCcBr9wwP KxH9vA7/O0hVvu9PTnauapDqwUPFTnqDEpT6rMPnG0lYJcaxBjkl0NBobQfeggGu cLFovH/C5PN5901mrBwu6Mhm4IyshwG4HLSCyAU8WpwQiSe6qe+dvZ/86l2dCLLs dSJG6WyQ6ElguO+T+08Jps1TVHWnghjFMRdyapLU+68DMizlwaMlrR8741S+3LMq LN+ut/TyqWOzA9Dcv/YK4FbvR/bblg== =g1QZ -----END PGP SIGNATURE----- --VQAk2EcGfbtQYq2ZG4Nplb3a1xKgKxeFb--