2021-12-16 09:50:22

by Tianjia Zhang

[permalink] [raw]
Subject: [PATCH] MIPS: Octeon: Fix build errors using clang

A large number of the following errors is reported when compiling
with clang:

cvmx-bootinfo.h:326:3: error: adding 'int' to a string does not append to the string [-Werror,-Wstring-plus-int]
ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_NULL)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cvmx-bootinfo.h:321:20: note: expanded from macro 'ENUM_BRD_TYPE_CASE'
case x: return(#x + 16); /* Skip CVMX_BOARD_TYPE_ */
~~~^~~~
cvmx-bootinfo.h:326:3: note: use array indexing to silence this warning
cvmx-bootinfo.h:321:20: note: expanded from macro 'ENUM_BRD_TYPE_CASE'
case x: return(#x + 16); /* Skip CVMX_BOARD_TYPE_ */
^

Follow the prompts to use the address operator '&' to fix this error.

Signed-off-by: Tianjia Zhang <[email protected]>
---
arch/mips/include/asm/octeon/cvmx-bootinfo.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/mips/include/asm/octeon/cvmx-bootinfo.h b/arch/mips/include/asm/octeon/cvmx-bootinfo.h
index 0e6bf220db61..6c61e0a63924 100644
--- a/arch/mips/include/asm/octeon/cvmx-bootinfo.h
+++ b/arch/mips/include/asm/octeon/cvmx-bootinfo.h
@@ -318,7 +318,7 @@ enum cvmx_chip_types_enum {

/* Functions to return string based on type */
#define ENUM_BRD_TYPE_CASE(x) \
- case x: return(#x + 16); /* Skip CVMX_BOARD_TYPE_ */
+ case x: return (&#x[16]); /* Skip CVMX_BOARD_TYPE_ */
static inline const char *cvmx_board_type_to_string(enum
cvmx_board_types_enum type)
{
@@ -410,7 +410,7 @@ static inline const char *cvmx_board_type_to_string(enum
}

#define ENUM_CHIP_TYPE_CASE(x) \
- case x: return(#x + 15); /* Skip CVMX_CHIP_TYPE */
+ case x: return (&#x[15]); /* Skip CVMX_CHIP_TYPE */
static inline const char *cvmx_chip_type_to_string(enum
cvmx_chip_types_enum type)
{
--
2.32.0



2021-12-16 16:11:42

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH] MIPS: Octeon: Fix build errors using clang

On Thu, Dec 16, 2021 at 05:50:14PM +0800, Tianjia Zhang wrote:
> A large number of the following errors is reported when compiling
> with clang:
>
> cvmx-bootinfo.h:326:3: error: adding 'int' to a string does not append to the string [-Werror,-Wstring-plus-int]
> ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_NULL)
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> cvmx-bootinfo.h:321:20: note: expanded from macro 'ENUM_BRD_TYPE_CASE'
> case x: return(#x + 16); /* Skip CVMX_BOARD_TYPE_ */
> ~~~^~~~
> cvmx-bootinfo.h:326:3: note: use array indexing to silence this warning
> cvmx-bootinfo.h:321:20: note: expanded from macro 'ENUM_BRD_TYPE_CASE'
> case x: return(#x + 16); /* Skip CVMX_BOARD_TYPE_ */
> ^
>
> Follow the prompts to use the address operator '&' to fix this error.
>
> Signed-off-by: Tianjia Zhang <[email protected]>

Reviewed-by: Nathan Chancellor <[email protected]>

> ---
> arch/mips/include/asm/octeon/cvmx-bootinfo.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/mips/include/asm/octeon/cvmx-bootinfo.h b/arch/mips/include/asm/octeon/cvmx-bootinfo.h
> index 0e6bf220db61..6c61e0a63924 100644
> --- a/arch/mips/include/asm/octeon/cvmx-bootinfo.h
> +++ b/arch/mips/include/asm/octeon/cvmx-bootinfo.h
> @@ -318,7 +318,7 @@ enum cvmx_chip_types_enum {
>
> /* Functions to return string based on type */
> #define ENUM_BRD_TYPE_CASE(x) \
> - case x: return(#x + 16); /* Skip CVMX_BOARD_TYPE_ */
> + case x: return (&#x[16]); /* Skip CVMX_BOARD_TYPE_ */
> static inline const char *cvmx_board_type_to_string(enum
> cvmx_board_types_enum type)
> {
> @@ -410,7 +410,7 @@ static inline const char *cvmx_board_type_to_string(enum
> }
>
> #define ENUM_CHIP_TYPE_CASE(x) \
> - case x: return(#x + 15); /* Skip CVMX_CHIP_TYPE */
> + case x: return (&#x[15]); /* Skip CVMX_CHIP_TYPE */
> static inline const char *cvmx_chip_type_to_string(enum
> cvmx_chip_types_enum type)
> {
> --
> 2.32.0
>

2021-12-17 23:59:10

by Philippe Mathieu-Daudé

[permalink] [raw]
Subject: Re: [PATCH] MIPS: Octeon: Fix build errors using clang

On Thu, Dec 16, 2021 at 5:11 PM Tianjia Zhang
<[email protected]> wrote:
>
> A large number of the following errors is reported when compiling
> with clang:
>
> cvmx-bootinfo.h:326:3: error: adding 'int' to a string does not append to the string [-Werror,-Wstring-plus-int]
> ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_NULL)
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> cvmx-bootinfo.h:321:20: note: expanded from macro 'ENUM_BRD_TYPE_CASE'
> case x: return(#x + 16); /* Skip CVMX_BOARD_TYPE_ */
> ~~~^~~~
> cvmx-bootinfo.h:326:3: note: use array indexing to silence this warning
> cvmx-bootinfo.h:321:20: note: expanded from macro 'ENUM_BRD_TYPE_CASE'
> case x: return(#x + 16); /* Skip CVMX_BOARD_TYPE_ */
> ^
>
> Follow the prompts to use the address operator '&' to fix this error.
>
> Signed-off-by: Tianjia Zhang <[email protected]>
> ---
> arch/mips/include/asm/octeon/cvmx-bootinfo.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>

2021-12-21 13:58:02

by Thomas Bogendoerfer

[permalink] [raw]
Subject: Re: [PATCH] MIPS: Octeon: Fix build errors using clang

On Thu, Dec 16, 2021 at 05:50:14PM +0800, Tianjia Zhang wrote:
> A large number of the following errors is reported when compiling
> with clang:
>
> cvmx-bootinfo.h:326:3: error: adding 'int' to a string does not append to the string [-Werror,-Wstring-plus-int]
> ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_NULL)
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> cvmx-bootinfo.h:321:20: note: expanded from macro 'ENUM_BRD_TYPE_CASE'
> case x: return(#x + 16); /* Skip CVMX_BOARD_TYPE_ */
> ~~~^~~~
> cvmx-bootinfo.h:326:3: note: use array indexing to silence this warning
> cvmx-bootinfo.h:321:20: note: expanded from macro 'ENUM_BRD_TYPE_CASE'
> case x: return(#x + 16); /* Skip CVMX_BOARD_TYPE_ */
> ^
>
> Follow the prompts to use the address operator '&' to fix this error.
>
> Signed-off-by: Tianjia Zhang <[email protected]>
> ---
> arch/mips/include/asm/octeon/cvmx-bootinfo.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)

applied to mips-next.

Thomas.

--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]