Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1932228ybv; Fri, 14 Feb 2020 08:26:53 -0800 (PST) X-Google-Smtp-Source: APXvYqxAzP7lGY4p22zvBPoQiNqZkQxp4d+AVAct9t2Z3s1ymf/5KjmjjFg7Dx6CDIiCpxHBVpVt X-Received: by 2002:a05:6830:11c8:: with SMTP id v8mr2741083otq.330.1581697613166; Fri, 14 Feb 2020 08:26:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581697613; cv=none; d=google.com; s=arc-20160816; b=z+4p+NMP6rPHnbAuxdw8KRqmmLLRt4YEa/Dt1htpWsJOjqUyOTgSAAjpPa3M8b0cDD OZ3mY8YfzlshbqONtvORD6VsesbhSwU4fCA/lAHj3SehV0QW3GRg4BUhbYvxA67rztoS hMcDGk9ibJAtDLDCb0+65tWH6UUGCnn+g2WYGDdy+lRt1vQXaJrCDYinC/49zkdrhqwv ukTYq9Z7C1uu/RmjiVVGT1FM3Duw4OLREXkliK4D63XdLptfohSOYY6G4sN6bWnuKAbo In33XZPduj9F7QvfRKnv1EpOCu8aeZ6f1x35aL/pyAc0355jzPkRD2h2WWORsiVgYtEC VH4Q== 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 :dkim-signature; bh=Fy4GTaRPmL6NvJPpnH2owGDEzITP+x3+CDohfAHA7m4=; b=IRjaO2DSRBnMF5FYemcR1TO/V9pLuQaPhEeVymOsvJvtPU6soPwfI/iNo/bO1taxDA SNznogcyvd/x/jvS4CBp0R9ldmjNISKtAkjLwreoHcTlxUun2qZleyC5WsOPTkH/Z3gl yxfILogqbmHA7HVE11BXqmtx9UMnx/NbnAtc/2n4NkPi543uLoLMEwkNgcLPNFMFVX6q GJei0u3MkhxrZKdZC0A6/cR7L8OYHKL3VxZ/g4Cf5yDXtvw1qRLHDGPxkW1rLqqNuORn v7d+27rJIiKET4UVCb67XUzl876MfZQ26ui+0XymBAQZXgCTBnWUcGvu21Xz6rzaQW0r FTnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sIMm4P02; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s128si2777196oig.204.2020.02.14.08.26.41; Fri, 14 Feb 2020 08:26:53 -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; dkim=pass header.i=@kernel.org header.s=default header.b=sIMm4P02; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406357AbgBNQ0O (ORCPT + 99 others); Fri, 14 Feb 2020 11:26:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:60916 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405599AbgBNQYM (ORCPT ); Fri, 14 Feb 2020 11:24:12 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 237E82476A; Fri, 14 Feb 2020 16:24:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581697452; bh=RQoQ8frxlbI1QjilHnH3/LmzPQ60HcJMzxc+C18UY60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sIMm4P02YtTpDd08G3z4cXkkvmTvG10Msji6l/Fm7koiVTTB6qJi35mjMUbdPRGoc oPjFACIpR2cBdZx669ZAnaV454WsrL65gJla7uocv47dMQqepczPaWiD8hE4PjYY9i UA8saW8uKe9rv77Dby89O/73uuE3/ta6dQAtpPak= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Coly Li , kbuild test robot , Jens Axboe , Sasha Levin , linux-bcache@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 135/141] bcache: explicity type cast in bset_bkey_last() Date: Fri, 14 Feb 2020 11:21:15 -0500 Message-Id: <20200214162122.19794-135-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200214162122.19794-1-sashal@kernel.org> References: <20200214162122.19794-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Coly Li [ Upstream commit 7c02b0055f774ed9afb6e1c7724f33bf148ffdc0 ] In bset.h, macro bset_bkey_last() is defined as, bkey_idx((struct bkey *) (i)->d, (i)->keys) Parameter i can be variable type of data structure, the macro always works once the type of struct i has member 'd' and 'keys'. bset_bkey_last() is also used in macro csum_set() to calculate the checksum of a on-disk data structure. When csum_set() is used to calculate checksum of on-disk bcache super block, the parameter 'i' data type is struct cache_sb_disk. Inside struct cache_sb_disk (also in struct cache_sb) the member keys is __u16 type. But bkey_idx() expects unsigned int (a 32bit width), so there is problem when sending parameters via stack to call bkey_idx(). Sparse tool from Intel 0day kbuild system reports this incompatible problem. bkey_idx() is part of user space API, so the simplest fix is to cast the (i)->keys to unsigned int type in macro bset_bkey_last(). Reported-by: kbuild test robot Signed-off-by: Coly Li Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/md/bcache/bset.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/md/bcache/bset.h b/drivers/md/bcache/bset.h index b935839ab79c6..f483041eed986 100644 --- a/drivers/md/bcache/bset.h +++ b/drivers/md/bcache/bset.h @@ -380,7 +380,8 @@ void bch_btree_keys_stats(struct btree_keys *, struct bset_stats *); /* Bkey utility code */ -#define bset_bkey_last(i) bkey_idx((struct bkey *) (i)->d, (i)->keys) +#define bset_bkey_last(i) bkey_idx((struct bkey *) (i)->d, \ + (unsigned int)(i)->keys) static inline struct bkey *bset_bkey_idx(struct bset *i, unsigned idx) { -- 2.20.1