All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@kernel.org>
To: Simon Horman <horms@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Jose Abreu <joabreu@synopsys.com>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Serge Semin <fancer.lancer@gmail.com>,
	Furong Xu <0x1207@gmail.com>, Jon Hunter <jonathanh@nvidia.com>,
	Kernel Test Robot <lkp@intel.com>,
	netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH net] net: stmmac: xgmac: use #define for string constants
Date: Thu, 15 Feb 2024 08:01:33 +0100	[thread overview]
Message-ID: <485dbc5a-a04b-40c2-9481-955eaa5ce2e2@kernel.org> (raw)
In-Reply-To: <20240208-xgmac-const-v1-1-e69a1eeabfc8@kernel.org>

On 08. 02. 24, 10:48, Simon Horman wrote:
> The cited commit introduces and uses the string constants dpp_tx_err and
> dpp_rx_err. These are assigned to constant fields of the array
> dwxgmac3_error_desc.
> 
> It has been reported that on GCC 6 and 7.5.0 this results in warnings
> such as:
> 
>    .../dwxgmac2_core.c:836:20: error: initialiser element is not constant
>     { true, "TDPES0", dpp_tx_err },
> 
> I have been able to reproduce this using: GCC 7.5.0, 8.4.0, 9.4.0 and 10.5.0.
> But not GCC 13.2.0.
> 
> So it seems this effects older compilers but not newer ones.
> As Jon points out in his report, the minimum compiler supported by
> the kernel is GCC 5.1, so it does seem that this ought to be fixed.
> 
> It is not clear to me what combination of 'const', if any, would address
> this problem.

You cannot make it more const than it is now ;). (You have a const 
pointer to const data already.)

> So this patch takes of using #defines for the string
> constants

That's indeed ugly. What about NOT creating a pointer to an array at 
all? See below.

> Compile tested only.
> 
> Fixes: 46eba193d04f ("net: stmmac: xgmac: fix handling of DPP safety error for DMA channels")
> Reported-by: Jon Hunter <jonathanh@nvidia.com>
> Closes: https://lore.kernel.org/netdev/c25eb595-8d91-40ea-9f52-efa15ebafdbc@nvidia.com/
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202402081135.lAxxBXHk-lkp@intel.com/
> Signed-off-by: Simon Horman <horms@kernel.org>
> ---
>   .../net/ethernet/stmicro/stmmac/dwxgmac2_core.c    | 69 +++++++++++-----------
>   1 file changed, 35 insertions(+), 34 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
> index 323c57f03c93..1af2f89a0504 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
> @@ -830,41 +830,42 @@ static const struct dwxgmac3_error_desc dwxgmac3_dma_errors[32]= {
>   	{ false, "UNKNOWN", "Unknown Error" }, /* 31 */
>   };
>   
> -static const char * const dpp_rx_err = "Read Rx Descriptor Parity checker Error";
> -static const char * const dpp_tx_err = "Read Tx Descriptor Parity checker Error";

The usual (even documented, I believe) way to do this is:

static const char dpp_tx_err[] = "Read Tx Descriptor Parity checker Error";

Then keep:
{ true, "TDPES0", dpp_tx_err },

Doesn't it do the right job?

> +#define DPP_RX_ERR "Read Rx Descriptor Parity checker Error"
> +#define DPP_TX_ERR "Read Tx Descriptor Parity checker Error"

thanks,
-- 
js
suse labs


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Jiri Slaby <jirislaby@kernel.org>
To: Simon Horman <horms@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Jose Abreu <joabreu@synopsys.com>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Serge Semin <fancer.lancer@gmail.com>,
	Furong Xu <0x1207@gmail.com>, Jon Hunter <jonathanh@nvidia.com>,
	Kernel Test Robot <lkp@intel.com>,
	netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH net] net: stmmac: xgmac: use #define for string constants
Date: Thu, 15 Feb 2024 08:01:33 +0100	[thread overview]
Message-ID: <485dbc5a-a04b-40c2-9481-955eaa5ce2e2@kernel.org> (raw)
In-Reply-To: <20240208-xgmac-const-v1-1-e69a1eeabfc8@kernel.org>

On 08. 02. 24, 10:48, Simon Horman wrote:
> The cited commit introduces and uses the string constants dpp_tx_err and
> dpp_rx_err. These are assigned to constant fields of the array
> dwxgmac3_error_desc.
> 
> It has been reported that on GCC 6 and 7.5.0 this results in warnings
> such as:
> 
>    .../dwxgmac2_core.c:836:20: error: initialiser element is not constant
>     { true, "TDPES0", dpp_tx_err },
> 
> I have been able to reproduce this using: GCC 7.5.0, 8.4.0, 9.4.0 and 10.5.0.
> But not GCC 13.2.0.
> 
> So it seems this effects older compilers but not newer ones.
> As Jon points out in his report, the minimum compiler supported by
> the kernel is GCC 5.1, so it does seem that this ought to be fixed.
> 
> It is not clear to me what combination of 'const', if any, would address
> this problem.

You cannot make it more const than it is now ;). (You have a const 
pointer to const data already.)

> So this patch takes of using #defines for the string
> constants

That's indeed ugly. What about NOT creating a pointer to an array at 
all? See below.

> Compile tested only.
> 
> Fixes: 46eba193d04f ("net: stmmac: xgmac: fix handling of DPP safety error for DMA channels")
> Reported-by: Jon Hunter <jonathanh@nvidia.com>
> Closes: https://lore.kernel.org/netdev/c25eb595-8d91-40ea-9f52-efa15ebafdbc@nvidia.com/
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202402081135.lAxxBXHk-lkp@intel.com/
> Signed-off-by: Simon Horman <horms@kernel.org>
> ---
>   .../net/ethernet/stmicro/stmmac/dwxgmac2_core.c    | 69 +++++++++++-----------
>   1 file changed, 35 insertions(+), 34 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
> index 323c57f03c93..1af2f89a0504 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
> @@ -830,41 +830,42 @@ static const struct dwxgmac3_error_desc dwxgmac3_dma_errors[32]= {
>   	{ false, "UNKNOWN", "Unknown Error" }, /* 31 */
>   };
>   
> -static const char * const dpp_rx_err = "Read Rx Descriptor Parity checker Error";
> -static const char * const dpp_tx_err = "Read Tx Descriptor Parity checker Error";

The usual (even documented, I believe) way to do this is:

static const char dpp_tx_err[] = "Read Tx Descriptor Parity checker Error";

Then keep:
{ true, "TDPES0", dpp_tx_err },

Doesn't it do the right job?

> +#define DPP_RX_ERR "Read Rx Descriptor Parity checker Error"
> +#define DPP_TX_ERR "Read Tx Descriptor Parity checker Error"

thanks,
-- 
js
suse labs


  parent reply	other threads:[~2024-02-15  7:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-08  9:48 [PATCH net] net: stmmac: xgmac: use #define for string constants Simon Horman
2024-02-08  9:48 ` Simon Horman
2024-02-13  1:40 ` patchwork-bot+netdevbpf
2024-02-13  1:40   ` patchwork-bot+netdevbpf
2024-02-15  7:01 ` Jiri Slaby [this message]
2024-02-15  7:01   ` Jiri Slaby

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=485dbc5a-a04b-40c2-9481-955eaa5ce2e2@kernel.org \
    --to=jirislaby@kernel.org \
    --cc=0x1207@gmail.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fancer.lancer@gmail.com \
    --cc=horms@kernel.org \
    --cc=joabreu@synopsys.com \
    --cc=jonathanh@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=lkp@intel.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.