Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp790006pxb; Wed, 29 Sep 2021 09:41:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYb0Na6SO+TbfWfCS0UENwBlZsOvtWerZEG35K9fgvKZDeHwsGdv4qDRXzGoMkuYvGllu6 X-Received: by 2002:a62:1591:0:b0:44b:2a06:207b with SMTP id 139-20020a621591000000b0044b2a06207bmr686797pfv.69.1632933688205; Wed, 29 Sep 2021 09:41:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632933688; cv=none; d=google.com; s=arc-20160816; b=Ekj/ra8aqyLwDKf54jnYqK/uMyNsFcSwsj/D4Hi9MCfE4QaEc1qUp2qXCkfOphXOEY YA9Vy0priwMmOeyCUtOknhNaBCuuQotfPjD8espANGJWbvE2HqJZDKoVA+qUnvJ56FlB 752zc7Hoy8EUTJIUJbUsJtBiMyJeO5n8cpZTIqZ74ZeqmXPVIqA5XuE7dhHWwA2Aq6N0 PJA92rJkNOOpV/NS3e7lMOZ0oPHyAG/iwFjxa9PHTGEBwTm6b17YGB7d0Z1z7ccCl8cx 0JPJwHlGFbf+VR0cGRh7+Nj/z0h8HEvYCfvqjD2Uwr7CTcd8ZijSVG1PNR61uEy+5YOT MatQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=OyZ3H7MJaY+/N42ZRK2SH1vmbMrl3WR8K/+gxMk2AvY=; b=wu1GM4JIrSDeyuNEAq9mSXXZI9KJAB9+F6+aQOaNpt6CCWs8fWVQpVFiVQxu41EtIp bKO0b9e+jRlklAhvSaIEwRBXiYUYaw7FVqg37P8oIQYMADCNiZ8569KalTzmKlusO/j7 HqHtE+zngYE8i+m/ZYnAZihPV6g7qrODBK9eLfUQS2l0Dvy3qZUbZWhlG2EuC6U9pD+7 N13MAqIZ1KoDQyf5lo3c+yPqyWT9BV6IFn0EtvvJXzQ4vsxM85ApMmZBDyyq6dWmNADg fTEPKj9ISW68KLkGwU0o/qVCBCW/KfuvmhU9XlFf0g3wSedot6ec4Apu+iKOAEJTWPDS rr5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MBd4alHz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id b3si404007pgw.94.2021.09.29.09.41.15; Wed, 29 Sep 2021 09:41:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MBd4alHz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1346195AbhI2Qlc (ORCPT + 99 others); Wed, 29 Sep 2021 12:41:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:41872 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345995AbhI2Ql1 (ORCPT ); Wed, 29 Sep 2021 12:41:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1970061411; Wed, 29 Sep 2021 16:39:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632933586; bh=cADn/6IlvG5tQfLFjc2s1heHlc+rWSTbwGM/ZbuPjcw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MBd4alHz+1J3bDeBKLZYYHyFkcyCAZiLlQo3PljylRjmuNjpzN6e0gHlbgiRYVgdU mkr6E8eYOtaRMencqDYLMpA3gAvtGNcGD9nZ3LvKvbQMVRPoYDWuPoTF2RRZa8IWVH 9MsYKV+woAm/RGww9B5BOghIUbwUsrMkOKDE/dyUM0p8nYIDQPGEzotpsMxBdN1NE9 c0ZRePAz8A8qBbQhBVd4z0JJA56nYzmN9GrIDdxou2QoiklMQa+Nptngenh5GaYjLH k3PdMZ2TeHiyzDhcbiNuPZfRfZLcfaKrs90G6+dU0pkddJ5StJfOswsa46nwprIdqv h6NphkBBrNuYA== Date: Wed, 29 Sep 2021 09:39:41 -0700 From: Nathan Chancellor To: Ido Schimmel Cc: kernel test robot , "llvm@lists.linux.dev" , "kbuild-all@lists.01.org" , "linux-kernel@vger.kernel.org" , Jiri Pirko Subject: Re: drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c:2022:1: warning: unused function 'mlxsw_afa_sampler_mirror_agent_get' Message-ID: References: <202109290245.bpgij5Zs-lkp@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Ido, On Wed, Sep 29, 2021 at 12:44:16PM +0300, Ido Schimmel wrote: > On Tue, Sep 28, 2021 at 09:06:54PM +0300, kernel test robot wrote: > > All warnings (new ones prefixed by >>): > > > > static inline u32 mlxsw_##_type##_##_cname##_##_iname##_get(const char ^ > > :119:1: note: expanded from here > > mlxsw_afa_polcnt_c_p_get > > ^ > > I saw your reply to a similar issue here [1] and I got the impression > that you are leading the LLVM-related efforts, so I thought I will > consult with you regarding a possible solution. > > The inline functions that clang is complaining about are generated by > macros that make it easy to set/get fields in the payloads of > configuration messages used to communicate with the device. It is > possible that sometime we only set a field, but never retrieve its value > such as in the warning above. This is very much intentional and not > indicative of a function we forgot to remove. > > The patch below [2] adds the "__maybe_unused" keyword to these macros > and makes clang happy [3]. > > Is this acceptable or you suggest a different solution? Yes, I would say this is a perfectly fine solution. The warning is there to make you consider if you have forgotten to use or remove a function depending on the context and if this is expected behavior, silencing the compiler with the __maybe_unused attribute is the right thing to do. The kernel does this for resume and suspend functions as CONFIG_PM might not be set. Cheers, Nathan > Thanks > > [1] https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org/thread/TIUWC7KZVTHGJKIZ4M3LI3JJYVAAINJX/ > > [2] > diff --git a/drivers/net/ethernet/mellanox/mlxsw/item.h b/drivers/net/ethernet/mellanox/mlxsw/item.h > index e92cadc98128..d2c8f436efb7 100644 > --- a/drivers/net/ethernet/mellanox/mlxsw/item.h > +++ b/drivers/net/ethernet/mellanox/mlxsw/item.h > @@ -290,13 +290,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \ > .size = {.bits = _sizebits,}, \ > .name = #_type "_" #_cname "_" #_iname, \ > }; \ > -static inline u8 \ > +static inline u8 __maybe_unused \ > mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\ > { \ > return __mlxsw_item_get8(buf, &__ITEM_NAME(_type, _cname, _iname), \ > index); \ > } \ > -static inline void \ > +static inline void __maybe_unused \ > mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, unsigned short index, \ > u8 val) \ > { \ > @@ -311,11 +311,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \ > .size = {.bits = _sizebits,}, \ > .name = #_type "_" #_cname "_" #_iname, \ > }; \ > -static inline u16 mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \ > +static inline u16 __maybe_unused \ > +mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \ > { \ > return __mlxsw_item_get16(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \ > } \ > -static inline void mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u16 val)\ > +static inline void __maybe_unused \ > +mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u16 val) \ > { \ > __mlxsw_item_set16(buf, &__ITEM_NAME(_type, _cname, _iname), 0, val); \ > } > @@ -331,13 +333,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \ > .size = {.bits = _sizebits,}, \ > .name = #_type "_" #_cname "_" #_iname, \ > }; \ > -static inline u16 \ > +static inline u16 __maybe_unused \ > mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\ > { \ > return __mlxsw_item_get16(buf, &__ITEM_NAME(_type, _cname, _iname), \ > index); \ > } \ > -static inline void \ > +static inline void __maybe_unused \ > mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, unsigned short index, \ > u16 val) \ > { \ > @@ -352,11 +354,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \ > .size = {.bits = _sizebits,}, \ > .name = #_type "_" #_cname "_" #_iname, \ > }; \ > -static inline u32 mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \ > +static inline u32 __maybe_unused \ > +mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \ > { \ > return __mlxsw_item_get32(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \ > } \ > -static inline void mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u32 val)\ > +static inline void __maybe_unused \ > +mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u32 val) \ > { \ > __mlxsw_item_set32(buf, &__ITEM_NAME(_type, _cname, _iname), 0, val); \ > } > @@ -372,13 +376,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \ > .size = {.bits = _sizebits,}, \ > .name = #_type "_" #_cname "_" #_iname, \ > }; \ > -static inline u32 \ > +static inline u32 __maybe_unused \ > mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\ > { \ > return __mlxsw_item_get32(buf, &__ITEM_NAME(_type, _cname, _iname), \ > index); \ > } \ > -static inline void \ > +static inline void __maybe_unused \ > mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, unsigned short index, \ > u32 val) \ > { \ > @@ -393,11 +397,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \ > .size = {.bits = _sizebits,}, \ > .name = #_type "_" #_cname "_" #_iname, \ > }; \ > -static inline u64 mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \ > +static inline u64 __maybe_unused \ > +mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \ > { \ > return __mlxsw_item_get64(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \ > } \ > -static inline void mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u64 val)\ > +static inline void __maybe_unused \ > +mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u64 val) \ > { \ > __mlxsw_item_set64(buf, &__ITEM_NAME(_type, _cname, _iname), 0, val); \ > } > @@ -413,13 +419,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \ > .size = {.bits = _sizebits,}, \ > .name = #_type "_" #_cname "_" #_iname, \ > }; \ > -static inline u64 \ > +static inline u64 __maybe_unused \ > mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\ > { \ > return __mlxsw_item_get64(buf, &__ITEM_NAME(_type, _cname, _iname), \ > index); \ > } \ > -static inline void \ > +static inline void __maybe_unused \ > mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, unsigned short index, \ > u64 val) \ > { \ > @@ -433,19 +439,19 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \ > .size = {.bytes = _sizebytes,}, \ > .name = #_type "_" #_cname "_" #_iname, \ > }; \ > -static inline void \ > +static inline void __maybe_unused \ > mlxsw_##_type##_##_cname##_##_iname##_memcpy_from(const char *buf, char *dst) \ > { \ > __mlxsw_item_memcpy_from(buf, dst, \ > &__ITEM_NAME(_type, _cname, _iname), 0); \ > } \ > -static inline void \ > +static inline void __maybe_unused \ > mlxsw_##_type##_##_cname##_##_iname##_memcpy_to(char *buf, const char *src) \ > { \ > __mlxsw_item_memcpy_to(buf, src, \ > &__ITEM_NAME(_type, _cname, _iname), 0); \ > } \ > -static inline char * \ > +static inline char * __maybe_unused \ > mlxsw_##_type##_##_cname##_##_iname##_data(char *buf) \ > { \ > return __mlxsw_item_data(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \ > @@ -460,7 +466,7 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \ > .size = {.bytes = _sizebytes,}, \ > .name = #_type "_" #_cname "_" #_iname, \ > }; \ > -static inline void \ > +static inline void __maybe_unused \ > mlxsw_##_type##_##_cname##_##_iname##_memcpy_from(const char *buf, \ > unsigned short index, \ > char *dst) \ > @@ -468,7 +474,7 @@ mlxsw_##_type##_##_cname##_##_iname##_memcpy_from(const char *buf, \ > __mlxsw_item_memcpy_from(buf, dst, \ > &__ITEM_NAME(_type, _cname, _iname), index); \ > } \ > -static inline void \ > +static inline void __maybe_unused \ > mlxsw_##_type##_##_cname##_##_iname##_memcpy_to(char *buf, \ > unsigned short index, \ > const char *src) \ > @@ -476,7 +482,7 @@ mlxsw_##_type##_##_cname##_##_iname##_memcpy_to(char *buf, \ > __mlxsw_item_memcpy_to(buf, src, \ > &__ITEM_NAME(_type, _cname, _iname), index); \ > } \ > -static inline char * \ > +static inline char * __maybe_unused \ > mlxsw_##_type##_##_cname##_##_iname##_data(char *buf, unsigned short index) \ > { \ > return __mlxsw_item_data(buf, \ > @@ -491,14 +497,14 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \ > .size = {.bytes = _sizebytes,}, \ > .name = #_type "_" #_cname "_" #_iname, \ > }; \ > -static inline u8 \ > +static inline u8 __maybe_unused \ > mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, u16 index) \ > { \ > return __mlxsw_item_bit_array_get(buf, \ > &__ITEM_NAME(_type, _cname, _iname), \ > index); \ > } \ > -static inline void \ > +static inline void __maybe_unused \ > mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u16 index, u8 val) \ > { \ > return __mlxsw_item_bit_array_set(buf, \ > > [3] > $ make -j8 CC=clang C=2 W=1 drivers/net/ethernet/mellanox/mlxsw/ > DESCEND bpf/resolve_btfids > DESCEND objtool > CHECK scripts/mod/empty.c > CALL scripts/atomic/check-atomics.sh > CALL scripts/checksyscalls.sh > CHECK drivers/net/ethernet/mellanox/mlxsw/core.c > CHECK drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c > CHECK drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c > CHECK drivers/net/ethernet/mellanox/mlxsw/core_env.c > CHECK drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c > CHECK drivers/net/ethernet/mellanox/mlxsw/core_thermal.c > CHECK drivers/net/ethernet/mellanox/mlxsw/pci.c > CHECK drivers/net/ethernet/mellanox/mlxsw/i2c.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_router_xm.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum1_kvdl.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum2_kvdl.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_bloom_filter.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_flow.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_matchall.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_cnt.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_actions.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum1_mr_tcam.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum2_mr_tcam.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_mr_tcam.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_nve_vxlan.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_policer.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c > CHECK drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c > CHECK drivers/net/ethernet/mellanox/mlxsw/minimal.c