diff mbox

[17/17] fs/ubifs: remove unnecessary new_valid_dev check

Message ID 1443452004-5831-1-git-send-email-bywxiaobai@163.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yaowei Bai Sept. 28, 2015, 2:53 p.m. UTC
As new_valid_dev always returns 1, so new_valid_dev check is not
needed, remove it.

Signed-off-by: Yaowei Bai <bywxiaobai@163.com>
---
 fs/ubifs/dir.c  | 3 ---
 fs/ubifs/misc.h | 9 ++-------
 2 files changed, 2 insertions(+), 10 deletions(-)

Comments

Richard Weinberger Sept. 28, 2015, 7:20 p.m. UTC | #1
On Mon, Sep 28, 2015 at 4:53 PM, Yaowei Bai <bywxiaobai@163.com> wrote:
> As new_valid_dev always returns 1, so new_valid_dev check is not
> needed, remove it.
>
> Signed-off-by: Yaowei Bai <bywxiaobai@163.com>
> ---
>  fs/ubifs/dir.c  | 3 ---
>  fs/ubifs/misc.h | 9 ++-------
>  2 files changed, 2 insertions(+), 10 deletions(-)
>
> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> index 5c27c66..1dd9267 100644
> --- a/fs/ubifs/dir.c
> +++ b/fs/ubifs/dir.c
> @@ -787,9 +787,6 @@ static int ubifs_mknod(struct inode *dir, struct dentry *dentry,
>
>         dbg_gen("dent '%pd' in dir ino %lu", dentry, dir->i_ino);
>
> -       if (!new_valid_dev(rdev))
> -               return -EINVAL;
> -
>         if (S_ISBLK(mode) || S_ISCHR(mode)) {
>                 dev = kmalloc(sizeof(union ubifs_dev_desc), GFP_NOFS);
>                 if (!dev)
> diff --git a/fs/ubifs/misc.h b/fs/ubifs/misc.h
> index ee7cb5e..0197ed6 100644
> --- a/fs/ubifs/misc.h
> +++ b/fs/ubifs/misc.h
> @@ -155,13 +155,8 @@ static inline int ubifs_wbuf_sync(struct ubifs_wbuf *wbuf)
>   */
>  static inline int ubifs_encode_dev(union ubifs_dev_desc *dev, dev_t rdev)
>  {
> -       if (new_valid_dev(rdev)) {
> -               dev->new = cpu_to_le32(new_encode_dev(rdev));
> -               return sizeof(dev->new);
> -       } else {
> -               dev->huge = cpu_to_le64(huge_encode_dev(rdev));
> -               return sizeof(dev->huge);
> -       }
> +       dev->huge = cpu_to_le64(huge_encode_dev(rdev));
> +       return sizeof(dev->huge);

Please be careful.

dev->new = cpu_to_le32(new_encode_dev(rdev));
return sizeof(dev->huge);

...is the correct branch. You enabled the dead one.
Yaowei Bai Sept. 29, 2015, 1:43 p.m. UTC | #2
On Mon, Sep 28, 2015 at 09:20:32PM +0200, Richard Weinberger wrote:
> On Mon, Sep 28, 2015 at 4:53 PM, Yaowei Bai <bywxiaobai@163.com> wrote:
> > As new_valid_dev always returns 1, so new_valid_dev check is not
> > needed, remove it.
> >
> > Signed-off-by: Yaowei Bai <bywxiaobai@163.com>
> > ---
> >  fs/ubifs/dir.c  | 3 ---
> >  fs/ubifs/misc.h | 9 ++-------
> >  2 files changed, 2 insertions(+), 10 deletions(-)
> >
> > diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> > index 5c27c66..1dd9267 100644
> > --- a/fs/ubifs/dir.c
> > +++ b/fs/ubifs/dir.c
> > @@ -787,9 +787,6 @@ static int ubifs_mknod(struct inode *dir, struct dentry *dentry,
> >
> >         dbg_gen("dent '%pd' in dir ino %lu", dentry, dir->i_ino);
> >
> > -       if (!new_valid_dev(rdev))
> > -               return -EINVAL;
> > -
> >         if (S_ISBLK(mode) || S_ISCHR(mode)) {
> >                 dev = kmalloc(sizeof(union ubifs_dev_desc), GFP_NOFS);
> >                 if (!dev)
> > diff --git a/fs/ubifs/misc.h b/fs/ubifs/misc.h
> > index ee7cb5e..0197ed6 100644
> > --- a/fs/ubifs/misc.h
> > +++ b/fs/ubifs/misc.h
> > @@ -155,13 +155,8 @@ static inline int ubifs_wbuf_sync(struct ubifs_wbuf *wbuf)
> >   */
> >  static inline int ubifs_encode_dev(union ubifs_dev_desc *dev, dev_t rdev)
> >  {
> > -       if (new_valid_dev(rdev)) {
> > -               dev->new = cpu_to_le32(new_encode_dev(rdev));
> > -               return sizeof(dev->new);
> > -       } else {
> > -               dev->huge = cpu_to_le64(huge_encode_dev(rdev));
> > -               return sizeof(dev->huge);
> > -       }
> > +       dev->huge = cpu_to_le64(huge_encode_dev(rdev));
> > +       return sizeof(dev->huge);
> 
> Please be careful.
> 
> dev->new = cpu_to_le32(new_encode_dev(rdev));
> return sizeof(dev->huge);
> 
> ...is the correct branch. You enabled the dead one.

Sorry about that, will resend fixing it. Thanks.

> 
> -- 
> Thanks,
> //richard

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 5c27c66..1dd9267 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -787,9 +787,6 @@  static int ubifs_mknod(struct inode *dir, struct dentry *dentry,
 
 	dbg_gen("dent '%pd' in dir ino %lu", dentry, dir->i_ino);
 
-	if (!new_valid_dev(rdev))
-		return -EINVAL;
-
 	if (S_ISBLK(mode) || S_ISCHR(mode)) {
 		dev = kmalloc(sizeof(union ubifs_dev_desc), GFP_NOFS);
 		if (!dev)
diff --git a/fs/ubifs/misc.h b/fs/ubifs/misc.h
index ee7cb5e..0197ed6 100644
--- a/fs/ubifs/misc.h
+++ b/fs/ubifs/misc.h
@@ -155,13 +155,8 @@  static inline int ubifs_wbuf_sync(struct ubifs_wbuf *wbuf)
  */
 static inline int ubifs_encode_dev(union ubifs_dev_desc *dev, dev_t rdev)
 {
-	if (new_valid_dev(rdev)) {
-		dev->new = cpu_to_le32(new_encode_dev(rdev));
-		return sizeof(dev->new);
-	} else {
-		dev->huge = cpu_to_le64(huge_encode_dev(rdev));
-		return sizeof(dev->huge);
-	}
+	dev->huge = cpu_to_le64(huge_encode_dev(rdev));
+	return sizeof(dev->huge);
 }
 
 /**