sfjro / aufs-standalone

29 stars 13 forks source link

Label in switch statement breaks Clang's fallthrough checker #36

Open sempervictus opened 9 months ago

sempervictus commented 9 months ago

Building 6.6.4 with clang, i'm seeing:

  AR      kernel/module/built-in.a
fs/aufs/opts.c:673:3: error: fallthrough annotation does not directly precede switch label
                fallthrough;
                ^
./include/linux/compiler_attributes.h:227:41: note: expanded from macro 'fallthrough'
# define fallthrough                    __attribute__((__fallthrough__))
                                        ^
  AR      kernel/built-in.a
1 error generated.

which appears to be happening because of the add: label below the fallthrough in:

 671         case Opt_prepend:
 672                 opt->add.bindex = 0;
 673                 fallthrough;
 674         add: /* indented label */
 675         case Opt_add

is there some sort of annotation needed to make this work or formatting of the label to make Clang happy?

sfjro commented 9 months ago

Hello RageLtMan,

RageLtMan:

fs/aufs/opts.c:673:3: error: fallthrough annotation does not directly precede switch label fallthrough; ^ ::: which appears to be happening because of the add: label below the fallthrough in:

 671         case Opt_prepend:
 672                 opt->add.bindex = 0;
 673                 fallthrough;
 674         add: /* indented label */
 675         case Opt_add

is there some sort of annotation needed to make this work or formatting of the label to make Clang happy?

Thanks for the report. Since I don't use clang usually i'm not aware of that.

What will happen if you switch the line 674 and 675?

J. R. Okajima

sempervictus commented 9 months ago

That's what i ended up doing too

commit 13e220c996fe2205c020ad4ca056acac183eb611
Author: RageLtMan <rageltman [at] sempervictus>
Date:   Sun Feb 18 12:17:06 2024 -0500

    AUFS: move label

diff --git a/fs/aufs/opts.c b/fs/aufs/opts.c
index 20421440c004..1628137da28b 100644
--- a/fs/aufs/opts.c
+++ b/fs/aufs/opts.c
@@ -671,8 +671,8 @@ static int au_opt_br(struct super_block *sb, struct au_opt *opt,
        case Opt_prepend:
                opt->add.bindex = 0;
                fallthrough;
-       add: /* indented label */
        case Opt_add:
+       add: /* indented label */
                err = au_br_add(sb, &opt->add,
                                au_ftest_opts(opts->flags, REMOUNT));
                if (!err) {
sfjro commented 9 months ago

RageLtMan:

That's what i ended up doing too

Ok, I will pick it up into aufs6.1 and spread all other branches. Thanks.

J. R. Okajima

sfjro commented 9 months ago

------- Blind-Carbon-Copy

From: "J. R. Okajima" @.> To: @. Subject: aufs6 GIT release (v6.8-rc5) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: @.> Date: Mon, 26 Feb 2024 04:42:07 +0900 Message-ID: @.>

This is a minor release. There is no change in aufs behaviour.

J. R. Okajima


------- End of Blind-Carbon-Copy