* [U-Boot] [PATCH] ARM: socfpga: fix duplicate const specifier warning
@ 2017-09-12 8:23 Masahiro Yamada
2017-09-12 10:23 ` Marek Vasut
2017-09-12 17:50 ` Marek Vasut
0 siblings, 2 replies; 6+ messages in thread
From: Masahiro Yamada @ 2017-09-12 8:23 UTC (permalink / raw)
To: u-boot
GCC 7.1 warns:
duplicate ‘const’ declaration specifier [-Wduplicate-decl-specifier]
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
arch/arm/mach-socfpga/misc_gen5.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/mach-socfpga/misc_gen5.c b/arch/arm/mach-socfpga/misc_gen5.c
index 2f1da74..91ddb79 100644
--- a/arch/arm/mach-socfpga/misc_gen5.c
+++ b/arch/arm/mach-socfpga/misc_gen5.c
@@ -144,7 +144,7 @@ static const struct {
const u16 pn;
const char *name;
const char *var;
-} const socfpga_fpga_model[] = {
+} socfpga_fpga_model[] = {
/* Cyclone V E */
{ 0x2b15, "Cyclone V, E/A2", "cv_e_a2" },
{ 0x2b05, "Cyclone V, E/A4", "cv_e_a4" },
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] ARM: socfpga: fix duplicate const specifier warning
2017-09-12 8:23 [U-Boot] [PATCH] ARM: socfpga: fix duplicate const specifier warning Masahiro Yamada
@ 2017-09-12 10:23 ` Marek Vasut
2017-09-12 13:19 ` Masahiro Yamada
2017-09-12 17:50 ` Marek Vasut
1 sibling, 1 reply; 6+ messages in thread
From: Marek Vasut @ 2017-09-12 10:23 UTC (permalink / raw)
To: u-boot
On 09/12/2017 10:23 AM, Masahiro Yamada wrote:
> GCC 7.1 warns:
> duplicate ‘const’ declaration specifier [-Wduplicate-decl-specifier]
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
> arch/arm/mach-socfpga/misc_gen5.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm/mach-socfpga/misc_gen5.c b/arch/arm/mach-socfpga/misc_gen5.c
> index 2f1da74..91ddb79 100644
> --- a/arch/arm/mach-socfpga/misc_gen5.c
> +++ b/arch/arm/mach-socfpga/misc_gen5.c
> @@ -144,7 +144,7 @@ static const struct {
^ Shouldn't you fix it here instead ?
> const u16 pn;
> const char *name;
> const char *var;
> -} const socfpga_fpga_model[] = {
> +} socfpga_fpga_model[] = {
> /* Cyclone V E */
> { 0x2b15, "Cyclone V, E/A2", "cv_e_a2" },
> { 0x2b05, "Cyclone V, E/A4", "cv_e_a4" },
>
--
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] ARM: socfpga: fix duplicate const specifier warning
2017-09-12 10:23 ` Marek Vasut
@ 2017-09-12 13:19 ` Masahiro Yamada
2017-09-12 14:10 ` Marek Vasut
0 siblings, 1 reply; 6+ messages in thread
From: Masahiro Yamada @ 2017-09-12 13:19 UTC (permalink / raw)
To: u-boot
Hi Marek,
2017-09-12 19:23 GMT+09:00 Marek Vasut <marex@denx.de>:
> On 09/12/2017 10:23 AM, Masahiro Yamada wrote:
>> GCC 7.1 warns:
>> duplicate ‘const’ declaration specifier [-Wduplicate-decl-specifier]
>>
>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>> ---
>>
>> arch/arm/mach-socfpga/misc_gen5.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/mach-socfpga/misc_gen5.c b/arch/arm/mach-socfpga/misc_gen5.c
>> index 2f1da74..91ddb79 100644
>> --- a/arch/arm/mach-socfpga/misc_gen5.c
>> +++ b/arch/arm/mach-socfpga/misc_gen5.c
>> @@ -144,7 +144,7 @@ static const struct {
> ^ Shouldn't you fix it here instead ?
>
>> const u16 pn;
>> const char *name;
>> const char *var;
>> -} const socfpga_fpga_model[] = {
>> +} socfpga_fpga_model[] = {
>> /* Cyclone V E */
>> { 0x2b15, "Cyclone V, E/A2", "cv_e_a2" },
>> { 0x2b05, "Cyclone V, E/A4", "cv_e_a4" },
>>
>
"const" and the variable type is interchangeable,
so this comes down to a personal preference after all,
but think about simpler cases.
[1]
const int x = 1;
const struct pinctrl_ops *ops;
[2]
int const x = 1;
struct pinctrl_ops const *ops;
Both [1] and [2] are correct and equivalent,
but my preference is [1] (and I hope you too).
In my experience in Linux / U-Boot,
source code mostly looks like [1]
(of course, [2] is mixed here and there)
I prefer style [1] ("const" before variable type),
so I removed the second "const" in this patch.
Ideally, the following might be more readable:
struct fpga_model {
const u16 pn;
const char *name;
const char *var;
};
static const struct fpga_model socfpga_fpga_model[] = {
...
};
But, I will not do
static struct fpga_model const socfpga_fpga_model[] = {
...
};
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] ARM: socfpga: fix duplicate const specifier warning
2017-09-12 13:19 ` Masahiro Yamada
@ 2017-09-12 14:10 ` Marek Vasut
2017-09-12 16:52 ` Masahiro Yamada
0 siblings, 1 reply; 6+ messages in thread
From: Marek Vasut @ 2017-09-12 14:10 UTC (permalink / raw)
To: u-boot
On 09/12/2017 03:19 PM, Masahiro Yamada wrote:
> Hi Marek,
>
>
> 2017-09-12 19:23 GMT+09:00 Marek Vasut <marex@denx.de>:
>> On 09/12/2017 10:23 AM, Masahiro Yamada wrote:
>>> GCC 7.1 warns:
>>> duplicate ‘const’ declaration specifier [-Wduplicate-decl-specifier]
>>>
>>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>>> ---
>>>
>>> arch/arm/mach-socfpga/misc_gen5.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/arch/arm/mach-socfpga/misc_gen5.c b/arch/arm/mach-socfpga/misc_gen5.c
>>> index 2f1da74..91ddb79 100644
>>> --- a/arch/arm/mach-socfpga/misc_gen5.c
>>> +++ b/arch/arm/mach-socfpga/misc_gen5.c
>>> @@ -144,7 +144,7 @@ static const struct {
>> ^ Shouldn't you fix it here instead ?
>>
>>> const u16 pn;
>>> const char *name;
>>> const char *var;
>>> -} const socfpga_fpga_model[] = {
>>> +} socfpga_fpga_model[] = {
>>> /* Cyclone V E */
>>> { 0x2b15, "Cyclone V, E/A2", "cv_e_a2" },
>>> { 0x2b05, "Cyclone V, E/A4", "cv_e_a4" },
>>>
>>
>
>
>
> "const" and the variable type is interchangeable,
> so this comes down to a personal preference after all,
> but think about simpler cases.
>
>
> [1]
> const int x = 1;
> const struct pinctrl_ops *ops;
>
>
> [2]
> int const x = 1;
> struct pinctrl_ops const *ops;
>
>
>
> Both [1] and [2] are correct and equivalent,
> but my preference is [1] (and I hope you too).
>
>
> In my experience in Linux / U-Boot,
> source code mostly looks like [1]
> (of course, [2] is mixed here and there)
>
>
> I prefer style [1] ("const" before variable type),
> so I removed the second "const" in this patch.
>
>
>
> Ideally, the following might be more readable:
>
>
> struct fpga_model {
> const u16 pn;
> const char *name;
> const char *var;
> };
>
> static const struct fpga_model socfpga_fpga_model[] = {
> ...
> };
>
>
>
> But, I will not do
>
> static struct fpga_model const socfpga_fpga_model[] = {
> ...
> };
Doesn't the position of const in the example above indicate whether it's
a const applied to the whole array or const applied to it's elements ?
--
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] ARM: socfpga: fix duplicate const specifier warning
2017-09-12 14:10 ` Marek Vasut
@ 2017-09-12 16:52 ` Masahiro Yamada
0 siblings, 0 replies; 6+ messages in thread
From: Masahiro Yamada @ 2017-09-12 16:52 UTC (permalink / raw)
To: u-boot
2017-09-12 23:10 GMT+09:00 Marek Vasut <marex@denx.de>:
> On 09/12/2017 03:19 PM, Masahiro Yamada wrote:
>> Hi Marek,
>>
>>
>> 2017-09-12 19:23 GMT+09:00 Marek Vasut <marex@denx.de>:
>>> On 09/12/2017 10:23 AM, Masahiro Yamada wrote:
>>>> GCC 7.1 warns:
>>>> duplicate ‘const’ declaration specifier [-Wduplicate-decl-specifier]
>>>>
>>>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>>>> ---
>>>>
>>>> arch/arm/mach-socfpga/misc_gen5.c | 2 +-
>>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/arch/arm/mach-socfpga/misc_gen5.c b/arch/arm/mach-socfpga/misc_gen5.c
>>>> index 2f1da74..91ddb79 100644
>>>> --- a/arch/arm/mach-socfpga/misc_gen5.c
>>>> +++ b/arch/arm/mach-socfpga/misc_gen5.c
>>>> @@ -144,7 +144,7 @@ static const struct {
>>> ^ Shouldn't you fix it here instead ?
>>>
>>>> const u16 pn;
>>>> const char *name;
>>>> const char *var;
>>>> -} const socfpga_fpga_model[] = {
>>>> +} socfpga_fpga_model[] = {
>>>> /* Cyclone V E */
>>>> { 0x2b15, "Cyclone V, E/A2", "cv_e_a2" },
>>>> { 0x2b05, "Cyclone V, E/A4", "cv_e_a4" },
>>>>
>>>
>>
>>
>>
>> "const" and the variable type is interchangeable,
>> so this comes down to a personal preference after all,
>> but think about simpler cases.
>>
>>
>> [1]
>> const int x = 1;
>> const struct pinctrl_ops *ops;
>>
>>
>> [2]
>> int const x = 1;
>> struct pinctrl_ops const *ops;
>>
>>
>>
>> Both [1] and [2] are correct and equivalent,
>> but my preference is [1] (and I hope you too).
>>
>>
>> In my experience in Linux / U-Boot,
>> source code mostly looks like [1]
>> (of course, [2] is mixed here and there)
>>
>>
>> I prefer style [1] ("const" before variable type),
>> so I removed the second "const" in this patch.
>>
>>
>>
>> Ideally, the following might be more readable:
>>
>>
>> struct fpga_model {
>> const u16 pn;
>> const char *name;
>> const char *var;
>> };
>>
>> static const struct fpga_model socfpga_fpga_model[] = {
>> ...
>> };
>>
>>
>>
>> But, I will not do
>>
>> static struct fpga_model const socfpga_fpga_model[] = {
>> ...
>> };
>
> Doesn't the position of const in the example above indicate whether it's
> a const applied to the whole array or const applied to it's elements ?
>
Sorry, I could not get what you mean.
Could you explain it in detail, please?
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] ARM: socfpga: fix duplicate const specifier warning
2017-09-12 8:23 [U-Boot] [PATCH] ARM: socfpga: fix duplicate const specifier warning Masahiro Yamada
2017-09-12 10:23 ` Marek Vasut
@ 2017-09-12 17:50 ` Marek Vasut
1 sibling, 0 replies; 6+ messages in thread
From: Marek Vasut @ 2017-09-12 17:50 UTC (permalink / raw)
To: u-boot
On 09/12/2017 10:23 AM, Masahiro Yamada wrote:
> GCC 7.1 warns:
> duplicate ‘const’ declaration specifier [-Wduplicate-decl-specifier]
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
> arch/arm/mach-socfpga/misc_gen5.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm/mach-socfpga/misc_gen5.c b/arch/arm/mach-socfpga/misc_gen5.c
> index 2f1da74..91ddb79 100644
> --- a/arch/arm/mach-socfpga/misc_gen5.c
> +++ b/arch/arm/mach-socfpga/misc_gen5.c
> @@ -144,7 +144,7 @@ static const struct {
> const u16 pn;
> const char *name;
> const char *var;
> -} const socfpga_fpga_model[] = {
> +} socfpga_fpga_model[] = {
> /* Cyclone V E */
> { 0x2b15, "Cyclone V, E/A2", "cv_e_a2" },
> { 0x2b05, "Cyclone V, E/A4", "cv_e_a4" },
>
Applied, thanks!
--
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-09-12 17:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-12 8:23 [U-Boot] [PATCH] ARM: socfpga: fix duplicate const specifier warning Masahiro Yamada
2017-09-12 10:23 ` Marek Vasut
2017-09-12 13:19 ` Masahiro Yamada
2017-09-12 14:10 ` Marek Vasut
2017-09-12 16:52 ` Masahiro Yamada
2017-09-12 17:50 ` Marek Vasut
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.