From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 59AED363C79 for ; Sun, 22 Mar 2026 14:40:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774190438; cv=none; b=EWoz14p00OAhYT3dTAcwMLaQSoupkUWzUsN+QycYY40CwgCt67h82S7+FW6kukA/B/pBHwiDEXgakB31kM+zwczaWVninxGFV/kqFydl/8A8Q399X1UVUzogHa5a4qPzqMdZQWcYzvd2jFUzY6sc8ql4dzU/vTbTHERnT5U8lX4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774190438; c=relaxed/simple; bh=0BSCjzDruNP/AyDLj5vJICRGek2k34dplxcY5S/Zdlw=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DqBNamJym1YzY/80CAQtQBlKj36+Ciw7D9tf4kZS+r5TdM/MSYJQK7WlqEqZLo2k3lKMoLnd9AgiIW6fKRd1BguAyGgqb0iZ+jP/rWVisSbI86PXSoXEsNFNQWXB91OkeR85VsGpcvBxvPDrDBnWegFgKm3OzsHcjzh0dG48FMA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=X0C0wDo8; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="X0C0wDo8" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4852b81c73aso18201195e9.3 for ; Sun, 22 Mar 2026 07:40:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1774190434; x=1774795234; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=5/IWr5vfvomOdGiQWFAG7XW5alVFwR3rmlBztzuDjME=; b=X0C0wDo87jPB95VtQJcgUKB0qiDbhzo4bJFIQSGUy56qGcKSNwvQs3+p5tyxIS2KBi 8oLu2zMzRjecoL+BNbQYhWyQT5oT3ohJ5w1NM9i19Y/om8MJZuB5UwH6WQbr+VbvoTIN nVTVdx1X23kAh8JIrgZWAVGSwldQVdm3+pm3RWA3bAUoDuLyCSujqHArx/9AdnQ/+3n2 bB7Vqznta2g2wHv7XwX34kvf08uPG3TDYpBjYgugg+egg/wKqwY5gDP/MT+urC6ZT9S4 SxAbrfT0d06LjU1VKtJVl77uT7wMKqT0j3VYhUE/nvcyBsqvsJrQ+QpatxuXIALBVzwr gi2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774190434; x=1774795234; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=5/IWr5vfvomOdGiQWFAG7XW5alVFwR3rmlBztzuDjME=; b=oWBlJlRbpCKfRNdf0OXABTuthuIkcmshorTrVHfZ8y2RtsF2RgMbcPrePVqpCsVYEw GKkKJrdcfdDqX8OmxoPXOgEAYJddk/monlVco5DcEi3xFAze3u936R4WG7AgmtVbNOPU tQNwLFed3o+bYdG6AaedD9o8BoaO8eD0hqztblWqkobCcPOZaLMHZkXNrJwbXdg/a6jG 9Al+kBMaOVKnZgn3M4Ru1+7UO3a9CzmaD5oaeu9Ws6eT9yfVAOceLIyffJIOOLuASFjm MGmaXJKBKTtE5AY/WphBawdPlixjY8eh0GVkwtdlyFwVdlLBDZukAGvZAtBz1PkLHlTQ G3BA== X-Forwarded-Encrypted: i=1; AJvYcCXnjJIOw6hKiLCXKWOx742Z4wjc4P+TIxVc7LD6KfSbi/6ir8Vw0Q+YdMTHsOTv5S2w16sjRZh8Y1tN/rs=@vger.kernel.org X-Gm-Message-State: AOJu0Yx769Iaio2kdng2FGaK0HhcFN6w1AXIq+xvXeO9wFHZhzmkbb+4 elCo6CnbJ8uutsiVtecfrPiLGAee7tEjMUonYBgFptNdbtCT1JMMSzWM X-Gm-Gg: ATEYQzwgUvZNHRdq+njz1DPmEX5OYNrgixFJ0wIE1SPjnGWljyoZHNU45K6fl/f9Kax wTBcoqCHHgdhwKm65l231geIHeroaPdNGd+3BjOn/prKh0L7QuHbHgiH7OmnF3+03/FRY9wonmp jOXhCDUAmSLwM8NtL5moVNyY+HZjrrtZVrJXlNefXOKulwQms2pYerf2g5HimL2H0boq+KmSmdB UVPcySg249BcptUYziDwIuU2ic+df0cyv9qd0sd9Qvr2iQJYIlcklQXnORef47pYtp1NcnOec6E rx57xkyWomTFE0PM+ezSJE/dE5yd2Qmo4qQ9y5DhHNWKXP4oGjvQkJF27pqkiF9clOZ2IjKpjan vxHnJwKbW3fR1TqZkz6BIPIRlX9ZUMCEJFAszjBIgK0HFuzHIJvagfTPsmBrjTS4S0SwcY4yHZu 9QRgMOzcHOxC3KLNnL+WPlw258b+E4bCxwSui7QcDQi1gYAjwTBfe4AGxXuOAAaydb X-Received: by 2002:a05:600c:4aaa:b0:477:7af8:c8ad with SMTP id 5b1f17b1804b1-4870306720emr48296925e9.31.1774190433483; Sun, 22 Mar 2026 07:40:33 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-486fe68ec05sm319287775e9.0.2026.03.22.07.40.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Mar 2026 07:40:33 -0700 (PDT) Date: Sun, 22 Mar 2026 14:40:32 +0000 From: David Laight To: Min-Hsun Chang Cc: arnd@arndb.de, msalter@redhat.com, akpm@linux-foundation.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] asm-generic: replace ________addr with __UNIQUE_ID(addr) Message-ID: <20260322144032.7353997c@pumpkin> In-Reply-To: <20260307092119.20733-1-chmh0624@gmail.com> References: <20260307092119.20733-1-chmh0624@gmail.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sat, 7 Mar 2026 17:21:19 +0800 Min-Hsun Chang wrote: > The macro __set_fixmap_offset() uses a hardcoded identifier ________addr, > which can lead to variable name shadowing if a caller happens to use the > same name in its scope. > > Following the pattern in commit 44238e82670e ("rcu: Replace ________p1 and > _________p1 with __UNIQUE_ID(rcu)") and commit 589a9785ee3a ("min/max: > remove sparse warnings when they're nested"), replace the hardcoded > identifier with __UNIQUE_ID(addr). > > Since __UNIQUE_ID() must be expanded once to remain consistent across > declaration, assignment, and return within the statement expression, > introduce a nested helper macro ___set_fixmap_offset. I'm not sure that is really relevant here - nested use is probably impossible. It is almost certainly enough to prefix locals with an leading _ and an abbreviation of the macro name. But see below. > > Signed-off-by: Min-Hsun Chang > --- > include/asm-generic/fixmap.h | 16 ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) > > diff --git a/include/asm-generic/fixmap.h b/include/asm-generic/fixmap.h > index 29cab7947980..2d1e9a2c6a3b 100644 > --- a/include/asm-generic/fixmap.h > +++ b/include/asm-generic/fixmap.h > @@ -16,6 +16,7 @@ > #define __ASM_GENERIC_FIXMAP_H > > #include > +#include > #include > > #define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT)) > @@ -71,14 +72,17 @@ static inline unsigned long virt_to_fix(const unsigned long vaddr) > #endif > > /* Return a pointer with offset calculated */ > -#define __set_fixmap_offset(idx, phys, flags) \ > -({ \ > - unsigned long ________addr; \ > - __set_fixmap(idx, phys, flags); \ > - ________addr = fix_to_virt(idx) + ((phys) & (PAGE_SIZE - 1)); \ > - ________addr; \ > +#define ___set_fixmap_offset(idx, phys, flags, uniq) \ > +({ \ > + unsigned long uniq; \ > + __set_fixmap(idx, phys, flags); \ > + uniq = fix_to_virt(idx) + ((phys) & (PAGE_SIZE - 1)); \ > + uniq; \ You don't need a variable to hold the result at all. The real problem with this define is that both idx and phys are expanded twice. So you either need to copy those to locals or use a static inline function - which should be ok here because the types are fixed. (Assuming neither __set_fixmap() or fix_to_virt() are #defines that modify their arguments.) David > }) > > +#define __set_fixmap_offset(idx, phys, flags) \ > + ___set_fixmap_offset(idx, phys, flags, __UNIQUE_ID(addr)) > + > #define set_fixmap_offset(idx, phys) \ > __set_fixmap_offset(idx, phys, FIXMAP_PAGE_NORMAL) >