From nobody Fri Apr 3 22:31:37 2026 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (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 1A3D72AD03 for ; Mon, 23 Mar 2026 06:06:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774245970; cv=none; b=JBnCB7ln7Ob26nULT8P9mulJyFqsXtC7Drnhk+7zkT3deIYSxUR+lmtGuif5aJenDXije6rCxHVwPqEiIM7rf0+5JXdIipbu3UcffbmZ0DQExGWNlUvX3gbCG0Q6yIbXZLZQqKXfo/GktTTXZC9cejWceAqWfypFp/p+WSYIyCY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774245970; c=relaxed/simple; bh=kxf6SYK54/E/zqSeHL2SrBf9duCr2LsNVz/FgDz2zjc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JP6lL2thUALcVtIINzXiiiGTiNwf7yQhGjJCyrhQ4UcXOholDTUFfy1rKs6Jj4QdovfWlVXBq8dTp2q09uMtV6gVaNR21gZQa6X7fQTZ7icWVUQ6DxEYGx7XVAKTXXfAfElZqekBiCZ2LQSYQDMwBHac/vaCiTsh3Q5/1d5LeRQ= 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=A5yk7ZBI; arc=none smtp.client-ip=209.85.216.54 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="A5yk7ZBI" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-35a288a2c00so1794900a91.2 for ; Sun, 22 Mar 2026 23:06:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1774245968; x=1774850768; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Iv3TfBIs57bOOCtJaO/f5ujAkQ8L7rO8zE6RhTk04Fc=; b=A5yk7ZBIHF24gPqEuRBUjvOqYX9ocgQcr9SnLXScpXNSG3fnpgmX7Y8jHDYQYqfK0u 2jjvolCcvwmMTAWRUNn5Q/JhFQ53brkg48isLS4Mi61O+q2namKj9YfYnsnhsz8prfbc /yMGLpZrvokXXtPDIWg6+SEdk4HlUSx5pFwXr6/qL7OIF0YZWKpDHdfR9nkiqzU7MxIC tlrs71pI1aOPc+AFRNhr31Q2Nle8F9yljNSFpmXYfIcyUPszV+vBPB5T2HVb4r1pmRBj W6MJsCJ8LI1mOw4SPMz+Mdv1OFJqsQ+Tnv20XlT3RPQGrfjQb5wmCMD9vgxTW4Yu5G1i OPpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774245968; x=1774850768; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Iv3TfBIs57bOOCtJaO/f5ujAkQ8L7rO8zE6RhTk04Fc=; b=dFrhaDnI2rc8tq0/UfpY67L7idmRrEmdSHAyrNgQa5eKBFnPfWYmYNjRs+x4UayflU 6xEZT5ibLZG63cLt8HRuA/2cD9UNK7n5caTchYKFSyuQPxi/6zvMVNChSXV2UBVpbrcQ usvbZQy9a2u+DbypbfH4B/KSuqLf1j/qv8lOsGpBFMk9wIO0VWFS5vVQ0Tl9eha6J8Lo A2hOI8ckWQpDios/REFJBaEbhf53M5bkbPh1J0G5Rl0ZdBIAnYSthwjBl+RdCSMecoLz EKrOS4L+ePYq0ennFhZo7xS80pElkeYrncdKsFfvCqVDt4exTbY7+2wONHNCHE8yG4dA 5LLw== X-Forwarded-Encrypted: i=1; AJvYcCXZpN82Iqv949G1QFCUXEQH8Fche70z/XsITtR19+lKkhJx0KeCNexCKtwLE+xLaH2myHUasYObOSD6xts=@vger.kernel.org X-Gm-Message-State: AOJu0Yzqf9w+f5jpFHmFjf/+rz7xH29gm4bhHrUwRaiSWo9bnWU2FnzL nU7YVAg/lPlY8l3C5eeFb0rfvleOWnwbDaTEZB1TYcbqy1XMPE+06ebQ X-Gm-Gg: ATEYQzyDagrnuiBWasp1dXw1ySOHJRHyndH9HLzzeDdWQAiZUH9wfV5Pmkw3vDE/TtN pYKy7Y7EfYh7UgKmlw+y1wCZTnEDFIGG7bhsMtav7jEcdbVhoRmcJnR/2LBRNnXqCZBhyAJF3oC zggkCURbyajUbKnJSdeVR5gYkP6OJoZ1QURFq+DR8hwJrpbnqDEEqUAfR+lhC2GJt+LFGnCKFL/ wIh4T857XZxDt9g3ESvewWW0dceB8hoTTqaPr3OtxaxqmKV5EoWuQufaRVmQGeylKJCKlwG9DAS v40r27q+GSeXA3YmEMivqzDtYbxDMyDpQRG4WJT9XbrvIz6YVHncbVcIFmj/ESwFy+sTZ3pTWi7 fSlV0a+k1WQcBdehY3yBL2is7/xrH90N3IOr8uy+IKA4dXRZ0oovtH+tH8DkphqiZh1/fuLnzVv 6LpDc9S2Y2yu+5uQGROKJLZha76gPuYobhFOHHYjE228Rn1ryrmNfQz661SpnYsOC4 X-Received: by 2002:a17:90b:5603:b0:359:2d1c:9206 with SMTP id 98e67ed59e1d1-35bd2d35149mr8760605a91.33.1774245968319; Sun, 22 Mar 2026 23:06:08 -0700 (PDT) Received: from rpi4-ubuntu.. (123-194-188-82.dynamic.kbronet.com.tw. [123.194.188.82]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b0836556f6sm125916615ad.49.2026.03.22.23.06.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Mar 2026 23:06:07 -0700 (PDT) From: Min-Hsun Chang To: arnd@arndb.de, david.laight.linux@gmail.com Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Min-Hsun Chang Subject: [PATCH v2] asm-generic: convert __set_fixmap_offset() to static inline Date: Mon, 23 Mar 2026 14:02:15 +0800 Message-ID: <20260323060228.21064-1-chmh0624@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260322144032.7353997c@pumpkin> References: <20260322144032.7353997c@pumpkin> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The current macro implementation of __set_fixmap_offset() uses a hardcoded identifier `________addr` within a statement expression. This can lead to variable shadowing and potential naming conflicts. Furthermore, the macro expands its `idx` and `phys` arguments twice. This double evaluation is dangerous if arguments with side effects (e.g., i++) are passed to the macro. Convert the macro to a static inline function as suggested by David. This improves type safety, avoids shadowing, and ensures each argument is evaluated exactly once. Signed-off-by: Min-Hsun Chang --- Changes in v2: - Convert the macro to a static inline function instead of just=20 renaming the local variable (suggested by David Laight). - This addresses both variable shadowing and double evaluation=20 issues pointed out during v1 review. - Link to v1: https://lore.kernel.org/all/20260307092119.20733-1-chmh0624= @gmail.com/ --- include/asm-generic/fixmap.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/asm-generic/fixmap.h b/include/asm-generic/fixmap.h index 29cab7947980..541b8db35af2 100644 --- a/include/asm-generic/fixmap.h +++ b/include/asm-generic/fixmap.h @@ -71,13 +71,13 @@ static inline unsigned long virt_to_fix(const unsigned = long vaddr) #endif =20 /* Return a pointer with offset calculated */ -#define __set_fixmap_offset(idx, phys, flags) \ -({ \ - unsigned long ________addr; \ - __set_fixmap(idx, phys, flags); \ - ________addr =3D fix_to_virt(idx) + ((phys) & (PAGE_SIZE - 1)); \ - ________addr; \ -}) +static inline unsigned long __set_fixmap_offset(unsigned int idx, + phys_addr_t phys, + pgprot_t flags) +{ + __set_fixmap(idx, phys, flags); + return fix_to_virt(idx) + (phys & (PAGE_SIZE - 1)); +} =20 #define set_fixmap_offset(idx, phys) \ __set_fixmap_offset(idx, phys, FIXMAP_PAGE_NORMAL) --=20 2.43.0