From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B90C5C76195 for ; Mon, 27 Mar 2023 17:33:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232069AbjC0Rdb (ORCPT ); Mon, 27 Mar 2023 13:33:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229986AbjC0Rda (ORCPT ); Mon, 27 Mar 2023 13:33:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A337AF for ; Mon, 27 Mar 2023 10:33:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3E44FB81733 for ; Mon, 27 Mar 2023 17:33:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3FCBC433D2; Mon, 27 Mar 2023 17:33:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679938404; bh=oQUUoLcduMMy2X1ptMcWIy3qKqq4Ar4Eq352Kc497W0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=VuFbiop/HkMDZuP65Z2UR6jim2DlLzXUX1HPIW+B3pxyBV8CopmDUHP2eOd3mOz4F xwqUu8WUwVDamAObpzkMFxH4kq0zKmDVw+H70PK5NpJ3XcQp8So9DeFlX5i1nnKHYK BrR8rJ7wSEq2wON4HvYxtfMHNQ9PBHd1RY+nfsRMYQY0fu6NlChDWX6doIUozMnnwh AZmasR5w4UtOfPyojlJX3WNeEgizrd+r5QZ5LDquJpDQLMpegynT8T/gMdKFo2I4yU /Tg1Csk18Wfh+JbvAFWkuoP6R8cY45wfcgnABnzhMg4YZGXsDECkrrV1GZ8vthmqsU DsPkqLWbOdYKw== Date: Mon, 27 Mar 2023 10:33:22 -0700 From: Jakub Kicinski To: Shay Agroskin Cc: Paolo Abeni , David Miller , , "Woodhouse, David" , "Machulsky, Zorik" , "Matushevsky, Alexander" , "Saeed Bshara" , "Wilson, Matt" , "Liguori, Anthony" , "Bshara, Nafea" , "Belgazal, Netanel" , "Saidi, Ali" , "Herrenschmidt, Benjamin" , "Kiyanovski, Arthur" , "Dagan, Noam" , "Arinzon, David" , "Itzko, Shahar" , "Abboud, Osama" , Eric Dumazet , Vladimir Oltean , Andrew Lunn , Guangbin Huang , Jie Wang , Johannes Berg , Edward Cree , "Florian Westphal" Subject: Re: [PATCH v6 net-next 1/7] netlink: Add a macro to set policy message with format string Message-ID: <20230327103322.4f294683@kernel.org> In-Reply-To: References: <20230320132523.3203254-1-shayagr@amazon.com> <20230320132523.3203254-2-shayagr@amazon.com> <20230322114041.71df75d1@kernel.org> <20230323095454.048d7130@kernel.org> <20230323133422.110d6cab@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Sat, 25 Mar 2023 16:49:34 +0300 Shay Agroskin wrote: > > TBH the hierarchy should be the other way around, > > NL_SET_ERR_MSG_FMT() > > should be converted to be: > > > > #define NL_SET_ERR_MSG_FMT(extack, attr, msg, args...) \ > > NL_SET_ERR_MSG_ATTR_POL_FMT(extack, NULL, NULL, msg, > > ##args) > > > > and that'd fix the shadowing, right? > > Well ... It will but it will contradict the current order of calls > as I see it. > > NL_SET_ERR_MSG_FMT_MOD calls NL_SET_ERR_MSG_FMT which can be > described as 'the former extends the latter'. > > On the other hand NL_SET_ERR_MSG_ATTR_POL implements the message > setting by itself and doesn't use NL_SET_ERR_MSG to set the > message. > > So it seems like we already have two approaches for macro ordering > here and following your suggestion would create another type of > call direction of 'the former shrinks the latter by setting to > NULL its attributes'. > Overall given the nature of C macros and the weird issues arise by > shadowing variables (ending up for some reason in not modifying > the pointer at all..) I'd say I mostly prefer V7 version which > re-implements the message setting and avoids creating such very > hard to find issues later. > > Then again I'd follow your implementation suggestion if you still > prefer it (also I can modify the macro NL_SET_ERR_MSG to call > NL_SET_ERR_MSG_ATTR_POL to be consistent with the other change) Alright, it doesn't matter all that much.