* [PATCH 0/2][next] m68k: amiga: config: Use flexible-array member and mark expected switch fall-through
@ 2020-03-26 23:23 Gustavo A. R. Silva
2020-03-26 23:29 ` [PATCH 2/2][next] m68k: amiga: config: Mark " Gustavo A. R. Silva
2020-04-20 18:14 ` [PATCH RESEND 1/2][next] m68k: amiga: config: Replace zero-length array with flexible-array member Gustavo A. R. Silva
0 siblings, 2 replies; 8+ messages in thread
From: Gustavo A. R. Silva @ 2020-03-26 23:23 UTC (permalink / raw)
To: Geert Uytterhoeven, Gustavo A. R. Silva; +Cc: linux-m68k, linux-kernel
mark expected switch fall-through
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org
Hi,
This series aims to replace a zero-length array with a flexible-array
member and mark a switch case where we are expecting to fall through.
This also coverts some /* fall through */ comments to the new
pseudo-keyword fallthrough;
Building: allmodconfig m68k
Thanks
Gustavo A. R. Silva (2):
[next] m68k: amiga: config: Replace zero-length array with
flexible-array member
[next] m68k: amiga: config: Mark expected switch fall-through
arch/m68k/amiga/config.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
--
2.26.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/2][next] m68k: amiga: config: Mark expected switch fall-through
2020-03-26 23:23 [PATCH 0/2][next] m68k: amiga: config: Use flexible-array member and mark expected switch fall-through Gustavo A. R. Silva
@ 2020-03-26 23:29 ` Gustavo A. R. Silva
2020-04-20 7:17 ` Geert Uytterhoeven
2020-04-20 18:14 ` [PATCH RESEND 1/2][next] m68k: amiga: config: Replace zero-length array with flexible-array member Gustavo A. R. Silva
1 sibling, 1 reply; 8+ messages in thread
From: Gustavo A. R. Silva @ 2020-03-26 23:29 UTC (permalink / raw)
To: Geert Uytterhoeven, Gustavo A. R. Silva; +Cc: linux-m68k, linux-kernel
Mark switch cases where we are expecting to fall through.
This patch fixes the following warning (Building: allmodconfig m68k):
arch/m68k/amiga/config.c: In function ‘amiga_identify’:
./arch/m68k/include/asm/amigahw.h:42:50: warning: this statement may fall through [-Wimplicit-fallthrough=]
#define AMIGAHW_SET(name) (amiga_hw_present.name = 1)
~~~~~~~~~~~~~~~~~~~~~~~^~~~
arch/m68k/amiga/config.c:223:3: note: in expansion of macro ‘AMIGAHW_SET’
AMIGAHW_SET(PCMCIA);
^~~~~~~~~~~
arch/m68k/amiga/config.c:224:2: note: here
case AMI_500:
^~~~
Replace the existing /* fall through */ comments and fix the issue above
by using the new pseudo-keyword fallthrough;
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
arch/m68k/amiga/config.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/m68k/amiga/config.c b/arch/m68k/amiga/config.c
index 06c15374200e..4eb911d64e8d 100644
--- a/arch/m68k/amiga/config.c
+++ b/arch/m68k/amiga/config.c
@@ -221,6 +221,7 @@ static void __init amiga_identify(void)
case AMI_1200:
AMIGAHW_SET(A1200_IDE);
AMIGAHW_SET(PCMCIA);
+ fallthrough;
case AMI_500:
case AMI_500PLUS:
case AMI_1000:
@@ -233,7 +234,7 @@ static void __init amiga_identify(void)
case AMI_3000T:
AMIGAHW_SET(AMBER_FF);
AMIGAHW_SET(MAGIC_REKICK);
- /* fall through */
+ fallthrough;
case AMI_3000PLUS:
AMIGAHW_SET(A3000_SCSI);
AMIGAHW_SET(A3000_CLK);
@@ -242,7 +243,7 @@ static void __init amiga_identify(void)
case AMI_4000T:
AMIGAHW_SET(A4000_SCSI);
- /* fall through */
+ fallthrough;
case AMI_4000:
AMIGAHW_SET(A4000_IDE);
AMIGAHW_SET(A3000_CLK);
--
2.26.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2][next] m68k: amiga: config: Mark expected switch fall-through
2020-03-26 23:29 ` [PATCH 2/2][next] m68k: amiga: config: Mark " Gustavo A. R. Silva
@ 2020-04-20 7:17 ` Geert Uytterhoeven
2020-04-20 16:07 ` Gustavo A. R. Silva
0 siblings, 1 reply; 8+ messages in thread
From: Geert Uytterhoeven @ 2020-04-20 7:17 UTC (permalink / raw)
To: Gustavo A. R. Silva; +Cc: linux-m68k, Linux Kernel Mailing List
On Fri, Mar 27, 2020 at 12:25 AM Gustavo A. R. Silva
<gustavo@embeddedor.com> wrote:
> Mark switch cases where we are expecting to fall through.
>
> This patch fixes the following warning (Building: allmodconfig m68k):
>
> arch/m68k/amiga/config.c: In function ‘amiga_identify’:
> ./arch/m68k/include/asm/amigahw.h:42:50: warning: this statement may fall through [-Wimplicit-fallthrough=]
> #define AMIGAHW_SET(name) (amiga_hw_present.name = 1)
> ~~~~~~~~~~~~~~~~~~~~~~~^~~~
> arch/m68k/amiga/config.c:223:3: note: in expansion of macro ‘AMIGAHW_SET’
> AMIGAHW_SET(PCMCIA);
> ^~~~~~~~~~~
> arch/m68k/amiga/config.c:224:2: note: here
> case AMI_500:
> ^~~~
>
> Replace the existing /* fall through */ comments and fix the issue above
> by using the new pseudo-keyword fallthrough;
>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
i.e. will queue in the m68k for-v5.8 branch.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2][next] m68k: amiga: config: Mark expected switch fall-through
2020-04-20 7:17 ` Geert Uytterhoeven
@ 2020-04-20 16:07 ` Gustavo A. R. Silva
2020-04-20 17:48 ` Geert Uytterhoeven
0 siblings, 1 reply; 8+ messages in thread
From: Gustavo A. R. Silva @ 2020-04-20 16:07 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: linux-m68k, Linux Kernel Mailing List
On 4/20/20 02:17, Geert Uytterhoeven wrote:
> On Fri, Mar 27, 2020 at 12:25 AM Gustavo A. R. Silva
> <gustavo@embeddedor.com> wrote:
>> Mark switch cases where we are expecting to fall through.
>>
>> This patch fixes the following warning (Building: allmodconfig m68k):
>>
>> arch/m68k/amiga/config.c: In function ‘amiga_identify’:
>> ./arch/m68k/include/asm/amigahw.h:42:50: warning: this statement may fall through [-Wimplicit-fallthrough=]
>> #define AMIGAHW_SET(name) (amiga_hw_present.name = 1)
>> ~~~~~~~~~~~~~~~~~~~~~~~^~~~
>> arch/m68k/amiga/config.c:223:3: note: in expansion of macro ‘AMIGAHW_SET’
>> AMIGAHW_SET(PCMCIA);
>> ^~~~~~~~~~~
>> arch/m68k/amiga/config.c:224:2: note: here
>> case AMI_500:
>> ^~~~
>>
>> Replace the existing /* fall through */ comments and fix the issue above
>> by using the new pseudo-keyword fallthrough;
>>
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>
> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
> i.e. will queue in the m68k for-v5.8 branch.
>
Geert,
I wonder if you received the first patch of the series.
It seems lkml has been eating some messages, recently.
Thanks
--
Gustavo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2][next] m68k: amiga: config: Mark expected switch fall-through
2020-04-20 16:07 ` Gustavo A. R. Silva
@ 2020-04-20 17:48 ` Geert Uytterhoeven
2020-04-20 18:15 ` Gustavo A. R. Silva
0 siblings, 1 reply; 8+ messages in thread
From: Geert Uytterhoeven @ 2020-04-20 17:48 UTC (permalink / raw)
To: Gustavo A. R. Silva; +Cc: linux-m68k, Linux Kernel Mailing List
Hi Gustavo,
On Mon, Apr 20, 2020 at 6:03 PM Gustavo A. R. Silva
<gustavo@embeddedor.com> wrote:
> On 4/20/20 02:17, Geert Uytterhoeven wrote:
> > On Fri, Mar 27, 2020 at 12:25 AM Gustavo A. R. Silva
> > <gustavo@embeddedor.com> wrote:
> >> Mark switch cases where we are expecting to fall through.
> >>
> >> This patch fixes the following warning (Building: allmodconfig m68k):
> >>
> >> arch/m68k/amiga/config.c: In function ‘amiga_identify’:
> >> ./arch/m68k/include/asm/amigahw.h:42:50: warning: this statement may fall through [-Wimplicit-fallthrough=]
> >> #define AMIGAHW_SET(name) (amiga_hw_present.name = 1)
> >> ~~~~~~~~~~~~~~~~~~~~~~~^~~~
> >> arch/m68k/amiga/config.c:223:3: note: in expansion of macro ‘AMIGAHW_SET’
> >> AMIGAHW_SET(PCMCIA);
> >> ^~~~~~~~~~~
> >> arch/m68k/amiga/config.c:224:2: note: here
> >> case AMI_500:
> >> ^~~~
> >>
> >> Replace the existing /* fall through */ comments and fix the issue above
> >> by using the new pseudo-keyword fallthrough;
> >>
> >> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> >
> > Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
> > i.e. will queue in the m68k for-v5.8 branch.
> >
>
> Geert,
>
> I wonder if you received the first patch of the series.
No I haven't, and lore also only has the cover latter and patch 2/2:
https://lore.kernel.org/linux-m68k/cover.1585264062.git.gustavo@embeddedor.com/
Can you please resend? Thanks!
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH RESEND 1/2][next] m68k: amiga: config: Replace zero-length array with flexible-array member
2020-03-26 23:23 [PATCH 0/2][next] m68k: amiga: config: Use flexible-array member and mark expected switch fall-through Gustavo A. R. Silva
2020-03-26 23:29 ` [PATCH 2/2][next] m68k: amiga: config: Mark " Gustavo A. R. Silva
@ 2020-04-20 18:14 ` Gustavo A. R. Silva
2020-04-21 7:06 ` Geert Uytterhoeven
1 sibling, 1 reply; 8+ messages in thread
From: Gustavo A. R. Silva @ 2020-04-20 18:14 UTC (permalink / raw)
To: Geert Uytterhoeven, Gustavo A. R. Silva; +Cc: linux-m68k, linux-kernel
The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:
struct foo {
int stuff;
struct boo array[];
};
By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.
Also, notice that, dynamic memory allocations won't be affected by
this change:
"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]
This issue was found with the help of Coccinelle.
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
arch/m68k/amiga/config.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/m68k/amiga/config.c b/arch/m68k/amiga/config.c
index c32ab8041cf6..06c15374200e 100644
--- a/arch/m68k/amiga/config.c
+++ b/arch/m68k/amiga/config.c
@@ -628,7 +628,7 @@ struct savekmsg {
unsigned long magic2; /* SAVEKMSG_MAGIC2 */
unsigned long magicptr; /* address of magic1 */
unsigned long size;
- char data[0];
+ char data[];
};
static struct savekmsg *savekmsg;
--
2.26.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2][next] m68k: amiga: config: Mark expected switch fall-through
2020-04-20 17:48 ` Geert Uytterhoeven
@ 2020-04-20 18:15 ` Gustavo A. R. Silva
0 siblings, 0 replies; 8+ messages in thread
From: Gustavo A. R. Silva @ 2020-04-20 18:15 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: linux-m68k, Linux Kernel Mailing List
On 4/20/20 12:48, Geert Uytterhoeven wrote:
>>
>> I wonder if you received the first patch of the series.
>
> No I haven't, and lore also only has the cover latter and patch 2/2:
> https://lore.kernel.org/linux-m68k/cover.1585264062.git.gustavo@embeddedor.com/
>
> Can you please resend? Thanks!
>
Done. :)
https://lore.kernel.org/linux-m68k/20200420181401.GA32172@embeddedor/
Thanks!
--
Gustavo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH RESEND 1/2][next] m68k: amiga: config: Replace zero-length array with flexible-array member
2020-04-20 18:14 ` [PATCH RESEND 1/2][next] m68k: amiga: config: Replace zero-length array with flexible-array member Gustavo A. R. Silva
@ 2020-04-21 7:06 ` Geert Uytterhoeven
0 siblings, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2020-04-21 7:06 UTC (permalink / raw)
To: Gustavo A. R. Silva; +Cc: linux-m68k, Linux Kernel Mailing List
On Mon, Apr 20, 2020 at 8:09 PM Gustavo A. R. Silva
<gustavo@embeddedor.com> wrote:
> The current codebase makes use of the zero-length array language
> extension to the C90 standard, but the preferred mechanism to declare
> variable-length types such as these ones is a flexible array member[1][2],
> introduced in C99:
>
> struct foo {
> int stuff;
> struct boo array[];
> };
>
> By making use of the mechanism above, we will get a compiler warning
> in case the flexible array does not occur last in the structure, which
> will help us prevent some kind of undefined behavior bugs from being
> inadvertently introduced[3] to the codebase from now on.
>
> Also, notice that, dynamic memory allocations won't be affected by
> this change:
>
> "Flexible array members have incomplete type, and so the sizeof operator
> may not be applied. As a quirk of the original implementation of
> zero-length arrays, sizeof evaluates to zero."[1]
>
> This issue was found with the help of Coccinelle.
>
> [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
> [2] https://github.com/KSPP/linux/issues/21
> [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")
>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
i.e. will queue in the m68k for-v5.8 branch.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-04-21 7:06 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-26 23:23 [PATCH 0/2][next] m68k: amiga: config: Use flexible-array member and mark expected switch fall-through Gustavo A. R. Silva
2020-03-26 23:29 ` [PATCH 2/2][next] m68k: amiga: config: Mark " Gustavo A. R. Silva
2020-04-20 7:17 ` Geert Uytterhoeven
2020-04-20 16:07 ` Gustavo A. R. Silva
2020-04-20 17:48 ` Geert Uytterhoeven
2020-04-20 18:15 ` Gustavo A. R. Silva
2020-04-20 18:14 ` [PATCH RESEND 1/2][next] m68k: amiga: config: Replace zero-length array with flexible-array member Gustavo A. R. Silva
2020-04-21 7:06 ` Geert Uytterhoeven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).