Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp512788imp; Wed, 20 Feb 2019 04:19:48 -0800 (PST) X-Google-Smtp-Source: AHgI3IbmpbSlv5k0Es32myfnmnxxWLtdBP1AEk0l0xJaTUm8FppynTUMFK3LQXjMUKVIfLkPyYLn X-Received: by 2002:a63:4a0a:: with SMTP id x10mr12415572pga.325.1550665188069; Wed, 20 Feb 2019 04:19:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550665188; cv=none; d=google.com; s=arc-20160816; b=Fru3ihs80HAyhMgzPZnX3qrGC0dRfeA8zPM7cy5Kalt0O5JQnT2Gl8BZxCpTlcpsex NaCLr/ovlNOKavLl7QepkzG4/johzVhU4Mae8iD5ZTIiHiYJdG0yp/kjhPWoTIIr5bzu K6fH5e+Qp2A6S5biq41aLYBStmRKriXoOWab8ulrjN44Th7SPfwklTsDtpYWjPkyfYfR 5pMLwPYE+xujI4aAT3vKWZoCbIjtHUIHP7DGERny5YCrrbcmW26fQzXswwNHyCb+zQlz 5yCjhc5fw3PvOpvQEz2Izk5RvFlSk4rzgYchA+beBWPdNfh/GqRgWhxn1dA6AtQCVewP f0QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=mmB1rjq1RwwStPzrrKjrhcLg6JOY4v7eN3sWGWHlaxQ=; b=IjAUdR9jMzJYBFKZmCyPbkToOmua1f++/RU/bVQRdA+XQXNhdBDI/5HoqfekzQ3KSO /w17EHJydpBKYARFnl1VNET6GNkWpZOVha/lqWMEt6gWeina64YkZ2GWhBlsbnxopX5q o+WcLYULQemtv/JQlAITx9jp1eykCurAZJOQr1S+UmNcGw1NJzO3mC0Lxk6T9xE7S6MG 3XwX1smYC948ss+gC0CIxgBXlxJI5udi2Ne4mKtd/04umCDsBbDmxRQn1YFrluSPGyNG cUX9wXDW7+AZ2i45ApXp4r9hvcaD5vMtujBMpV8Gu6w0jkoqGzZi0TJM29VhqwI8bXIF MaBw== 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 p17si2757918pgg.259.2019.02.20.04.19.32; Wed, 20 Feb 2019 04:19:48 -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 S1727685AbfBTMSf (ORCPT + 99 others); Wed, 20 Feb 2019 07:18:35 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:39398 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726209AbfBTMSf (ORCPT ); Wed, 20 Feb 2019 07:18:35 -0500 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 4AE3C6E181238EFBA108; Wed, 20 Feb 2019 20:18:32 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.408.0; Wed, 20 Feb 2019 20:18:22 +0800 From: YueHaibing To: Chris Mason , Josef Bacik , David Sterba CC: YueHaibing , , , , "Dan Carpenter" Subject: [PATCH v2 -next] btrfs: Remove unnecessary casts in btrfs_read_root_item Date: Wed, 20 Feb 2019 12:32:02 +0000 Message-ID: <20190220123202.43256-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190220030840.188854-1-yuehaibing@huawei.com> References: <20190220030840.188854-1-yuehaibing@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is a messy cast here: min_t(int, len, (int)sizeof(*item))); 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. This patch shouldn't affect runtime, it's just a clean up. Suggested-by: Dan Carpenter Signed-off-by: YueHaibing --- v2: modify commit message as Dan suggested --- fs/btrfs/root-tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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_buffer *eb, int slot, struct btrfs_root_item *item) { uuid_le uuid; - int len; + u32 len; int need_reset = 0; len = 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 = 1; if (!need_reset && btrfs_root_generation(item)