Subject: [PATCH] mount.cifs: remove redundant error assignment
Subsystems (2)
... as it is done anyway at add_mtab_exit.
--- mount.cifs.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
mount.cifs.c +0 -2
@@ -1513,7 +1513,6 @@ add_mtab(char *devname, char *mountpoint, unsigned long flags, const char *fstyp rc =lock_mtab ();if (rc) {fprintf (stderr,"cannot lock mtab" ); - rc =EX_FILEIO ; goto add_mtab_exit; }
@@ -1521,7 +1520,6 @@ add_mtab(char *devname, char *mountpoint, unsigned long flags, const char *fstypif (!pmntfile) {fprintf (stderr,"could not update mount table\n" );unlock_mtab (); - rc =EX_FILEIO ; goto add_mtab_exit; }
Quoted 13 lines · On Wed, 04 Aug 2010 12:31:40 +0530 Suresh Jayaraman…
... as it is done anyway at
add_mtab_exit.Signed-off-by Suresh Jayaraman <[email protected]>--- mount.cifs.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)mount.cifs.c +0
-0
mount.cifs.c add_mtab(char *devname, char *mountpoint, unsigned long flags, const char *fstyp · line 1518
Quoted 7 lines
mount.cifs.c +0
-1@@ -1513,7 +1513,6 @@ add_mtab(char *devname, char *mountpoint, unsigned long flags, const char *fstyp rc =lock_mtab ();if (rc) {fprintf (stderr,"cannot lock mtab" ); - rc =EX_FILEIO ; goto add_mtab_exit; }
^^^^^^^^^^^
This seems to be fine.
mount.cifs.c add_mtab(char *devname, char *mountpoint, unsigned long flags, const char *fstyp · line 1524
Quoted 7 lines
mount.cifs.c +0
-1@@ -1521,7 +1520,6 @@ add_mtab(char *devname, char *mountpoint, unsigned long flags, const char *fstypif (!pmntfile) {fprintf (stderr,"could not update mount table\n" );unlock_mtab (); - rc =EX_FILEIO ; goto add_mtab_exit; }
^^^^^^^^^^^
This looks wrong. If we don't set rc here, then it'll still be 0 and the code at add_mtab_exit won't set it to EX_FILEIO.
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 11 lines · Jeff Layton
Review add_mtab(char *devname, char *mountpoint, unsigned long flags, const char *fstyp · line 1524
Quoted 7 lines · On Wed, 04 Aug 2010 12:31:40 +0530 Suresh Jayaraman…
(quoted diff) +0
-1@@ -1521,7 +1520,6 @@ add_mtab(char *devname, char *mountpoint, unsigned long flags, const char *fstyp if (!pmntfile) { fprintf(stderr, "could not update mount table\n"); unlock_mtab(); - rc = EX_FILEIO; goto add_mtab_exit; }^^^^^^^^^^^
Quoted 3 lines
This looks wrong. If we don't set rc here, then it'll still be 0 and the code at
add_mtab_exitwon't set it toEX_FILEIO.
My bad.. I guess it's due to the effect of working with multiple code versions..
Here's another version which is slightly different..
From: Suresh Jayaraman <[email protected]>
Subject: [PATCH] mount.cifs: remove redundant error assignment
Avoid setting error code twice by moving error handling out of add_mtab_exit block. We already set error code and report error in other places.
--- mount.cifs.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
mount.cifs.c +4 -4
@@ -1554,16 +1554,16 @@ add_mtab(char *devname, char *mountpoint, unsigned long flags, const char *fstyp mountent.mnt_freq =0 ; mountent.mnt_passno =0 ; rc =addmntent (pmntfile, &mountent); +if (rc) { +fprintf (stderr,"unable to add mount entry to mtab\n" ); + rc =EX_FILEIO ; + }endmntent (pmntfile);unlock_mtab ();SAFE_FREE (mountent.mnt_opts); add_mtab_exit:toggle_dac_capability (1 ,0 );sigprocmask (SIG_SETMASK , &oldmask,NULL ); -if (rc) { -fprintf (stderr,"unable to add mount entry to mtab\n" ); - rc =EX_FILEIO ; - }return rc; }
Quoted 58 lines · On Wed, 04 Aug 2010 16:55:50 +0530 Suresh Jayaraman…
Quoted 11 lines · Jeff Layton
mount.cifs.c add_mtab(char *devname, char *mountpoint, unsigned long flags, const char *fstyp · line 1524
Quoted 7 lines · On Wed, 04 Aug 2010 12:31:40 +0530 Suresh Jayaraman…
mount.cifs.c +0
-1@@ -1521,7 +1520,6 @@ add_mtab(char *devname, char *mountpoint, unsigned long flags, const char *fstypif (!pmntfile) {fprintf (stderr,"could not update mount table\n" );unlock_mtab (); - rc =EX_FILEIO ; goto add_mtab_exit; }^^^^^^^^^^^Quoted 3 lines
This looks wrong. If we don't set rc here, then it'll still be 0 and the code at
add_mtab_exitwon't set it toEX_FILEIO.My bad.. I guess it's due to the effect of working with multiple code versions..
Here's another version which is slightly different..
From: Suresh Jayaraman <[email protected]>
Subject: [PATCH] mount.cifs: remove redundant error assignmentAvoid setting error code twice by moving error handling out of
add_mtab_exitblock. We already set error code and report error in other places.Signed-off-by Suresh Jayaraman <[email protected]>--- mount.cifs.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)mount.cifs.c +4
-5@@ -1554,16 +1554,16 @@ add_mtab(char *devname, char *mountpoint, unsigned long flags, const char *fstyp mountent.mnt_freq =0 ; mountent.mnt_passno =0 ; rc =addmntent (pmntfile, &mountent); +if (rc) { +fprintf (stderr,"unable to add mount entry to mtab\n" ); + rc =EX_FILEIO ; + }endmntent (pmntfile);unlock_mtab ();SAFE_FREE (mountent.mnt_opts); add_mtab_exit:toggle_dac_capability (1 ,0 );sigprocmask (SIG_SETMASK , &oldmask,NULL ); -if (rc) { -fprintf (stderr,"unable to add mount entry to mtab\n" ); - rc =EX_FILEIO ; - }return rc; } --
Quoted 4 lines
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
That looks more reasonable...committed.
Signature · 1 line
Jeff Layton <[email protected]>