Re: [PATCH 1/1 linux-next] affs: add default case in switch
From: Fabian Frederick
Date: Sun May 03 2015 - 14:16:08 EST
> On 03 May 2015 at 16:51 Richard Weinberger <richard.weinberger@xxxxxxxxx>
> wrote:
>
>
> On Sat, May 2, 2015 at 8:56 PM, Fabian Frederick <fabf@xxxxxxxxx> wrote:
> > Fix gcc -Wswitch-default warnings
> >
> > Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> > Signed-off-by: Fabian Frederick <fabf@xxxxxxxxx>
> > ---
> >Â fs/affs/inode.c | 2 ++
> >Â fs/affs/namei.c | 3 +++
> >Â 2 files changed, 5 insertions(+)
> >
> > diff --git a/fs/affs/inode.c b/fs/affs/inode.c
> > index 1734950..623398e 100644
> > --- a/fs/affs/inode.c
> > +++ b/fs/affs/inode.c
> > @@ -143,6 +143,8 @@ struct inode *affs_iget(struct super_block *sb, unsigned
> > long ino)
> >Â Â Â Â Â Â Â Â Âinode->i_op = &affs_symlink_inode_operations;
> >Â Â Â Â Â Â Â Â Âinode->i_data.a_ops = &affs_symlink_aops;
> >Â Â Â Â Â Â Â Â Âbreak;
> > +Â Â Â Âdefault:
> > +Â Â Â Â Â Â Â Âbreak;
> >Â Â Â Â Â}
> >
> >Â Â Â Â Âinode->i_mtime.tv_sec = inode->i_atime.tv_sec =
> >inode->i_ctime.tv_sec
> > diff --git a/fs/affs/namei.c b/fs/affs/namei.c
> > index 181e05b..517926d 100644
> > --- a/fs/affs/namei.c
> > +++ b/fs/affs/namei.c
> > @@ -237,6 +237,9 @@ affs_lookup(struct inode *dir, struct dentry *dentry,
> > unsigned int flags)
> >Â Â Â Â Â Â Â Â Â//case ST_LINKDIR:
> >Â Â Â Â Â Â Â Â Âcase ST_LINKFILE:
> >Â Â Â Â Â Â Â Â Â Â Â Â Âino = be32_to_cpu(AFFS_TAIL(sb, bh)->original);
> > +Â Â Â Â Â Â Â Â Â Â Â Âbreak;
> > +Â Â Â Â Â Â Â Âdefault:
> > +Â Â Â Â Â Â Â Â Â Â Â Âbreak;
>
> How can this code path be reached?
> If I read your patch correctly it just silences gcc.
>
> If the code can be reached you need to take a proper action of not the
> warning is bogus.
As far as I understand, switch in affs_lookup() only updates inode number when
it's a link so we can simply add default:break to silence gcc warning or replace
by if().
affs_iget() switch on the other hand applies to any type of file.
Maybe we could add default: BUG() to avoid working on bad inode ?
Regards,
Fabian
>
> --
> Thanks,
> //richard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/