From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F7B53955CF for ; Wed, 15 Jul 2026 14:51:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784127094; cv=none; b=AlEYbEk0L6tK2woukUfaNYWG1d1mfYvTzCuu6HIJCgSF2NBz/37gDdWhc7qwmDDGM5pBc70ot81J++IUXSD8ZgOzwkMC5FeD24AFGPDtEqX5r42512qUkYobzDi4e4KxE/J3Wwj0RZldeu68qIM5iSqeYPRpNT39hcuB8krlU+A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784127094; c=relaxed/simple; bh=sGzXjr7/yELCP7eHxVZfTc41JB5nJiz2B88J79MNkjs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=hGJ1SZLcSiP+Ui5LEGZ9txvP4EQBeEK6zRW59FUigt/Jwzz2TJ4+eaWMRm0e7PIahrT3RPZF2uR1GJToLYUCCByKO0lwmkjGAtasqtKtlvCsItJBmBzyJ2/8UkUYlydvEFjeM1Ys+P/FKpnVdgUXDFC86K4/EvqN1I7vemJhwQg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UzVTfACE; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UzVTfACE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D638D1F000E9; Wed, 15 Jul 2026 14:51:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784127092; bh=4VMPGAGICOGa7csEx19zpeBcPGmLUC1P6LwB1e/OpH4=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=UzVTfACElEQpZ7INLy8UUR6s+8Z8mK9C3WG/O9jZnu+3j5zyy76RhWx9UUU3Zc2WO SNZRZf4VkFNgYmJHZfc6owh0JoNLagf3BfG+5sYn7d1Gu0i8nMZPMs58aZqmnB84uQ m6Q2zruii27b/LXOaS479b5a/OxchJuKgu4yiF2xVbmtdLBNUhBcdp6MIJo2ATB+FE j6xvwpRTKr/JmjM/1X6ID6JroeGARaIDzAGkk2S6pENNiLJ9/0SU11vHqyrnAUdT/g Apk4JH48hLVhBy3VZnbr4dDkmv7TItU54JHUNEcREoa94BRWWp72uN7Lue/Hrz3ovB Eyvh24Yeej7Cw== Message-ID: Date: Wed, 15 Jul 2026 16:51:28 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/3] container_of: remove useless pair of parentheses To: Alexey Dobriyan Cc: Greg Kroah-Hartman , Andrew Morton , Rasmus Villemoes , Sakari Ailus , Nick Desaulniers , Alexander Lobakin , Arnd Bergmann , David Sterba , Ivo van Doorn , linux-kernel@vger.kernel.org References: <20260714-containerof_refactor-v1-0-b5c31164d2ad@kernel.org> <20260714-containerof_refactor-v1-2-b5c31164d2ad@kernel.org> From: Vincent Mailhol Content-Language: en-US Autocrypt: addr=mailhol@kernel.org; keydata= xjMEZluomRYJKwYBBAHaRw8BAQdAf+/PnQvy9LCWNSJLbhc+AOUsR2cNVonvxhDk/KcW7FvN JFZpbmNlbnQgTWFpbGhvbCA8bWFpbGhvbEBrZXJuZWwub3JnPsKZBBMWCgBBFiEE7Y9wBXTm fyDldOjiq1/riG27mcIFAmdfB/kCGwMFCQp/CJcFCwkIBwICIgIGFQoJCAsCBBYCAwECHgcC F4AACgkQq1/riG27mcKBHgEAygbvORJOfMHGlq5lQhZkDnaUXbpZhxirxkAHwTypHr4A/joI 2wLjgTCm5I2Z3zB8hqJu+OeFPXZFWGTuk0e2wT4JzjgEZx4y8xIKKwYBBAGXVQEFAQEHQJrb YZzu0JG5w8gxE6EtQe6LmxKMqP6EyR33sA+BR9pLAwEIB8J+BBgWCgAmFiEE7Y9wBXTmfyDl dOjiq1/riG27mcIFAmceMvMCGwwFCQPCZwAACgkQq1/riG27mcJU7QEA+LmpFhfQ1aij/L8V zsZwr/S44HCzcz5+jkxnVVQ5LZ4BANOCpYEY+CYrld5XZvM8h2EntNnzxHHuhjfDOQ3MAkEK In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 15/07/2026 at 16:30, Alexey Dobriyan wrote: > On Tue, Jul 14, 2026 at 08:18:02PM +0200, Vincent Mailhol wrote: >> The last expression in container_of() doesn't need an extra pair of >> parenthesis. Remove it. >> >> Signed-off-by: Vincent Mailhol >> --- >> include/linux/container_of.h | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/include/linux/container_of.h b/include/linux/container_of.h >> index 28500a62ab7e..68153170db32 100644 >> --- a/include/linux/container_of.h >> +++ b/include/linux/container_of.h >> @@ -21,7 +21,7 @@ >> static_assert(__same_type(*(ptr), typeof_member(type, member)) || \ >> __same_type(*(ptr), void), \ >> "pointer type mismatch in container_of()"); \ >> - ((type *)(__mptr - offsetof(type, member))); }) >> + (type *)(__mptr - offsetof(type, member)); }) > > container_of_const() has the same problem. Yes. But scoped I my series to the container_of() macro only. I don't plan to send a follow-up patch to remove the other useless parenthesis. The things which really bothered me was the __mptr variable which I removed in patch #3. And with that, I am done with what I wanted to contribute in this file. But you are welcome to do this clean-up if you feel the need for it. > And it should parenthesize first argument to _Generic. Do you mean like this: #define container_of_const(ptr, type, member) \ _Generic((ptr), \ const typeof(*(ptr)) *: ((const type *)container_of(ptr, type, member)),\ default: ((type *)container_of(ptr, type, member)) \ ) ? Why would parenthesis be needed here? I don't see what kind of expression would make the current implementation unsafe. Yours sincerely, Vincent Mailhol