Skip to contentSkip to conversation

Subject: [PATCH] mount.cifs: remove redundant error assignment

PATCH Suresh Jayaraman 2 participants 4 messages Aug 4, 2010 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

... 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
index 9f04261..49fdd08 100644
@@ -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 *fstyp
 	if (!pmntfile) {
 		fprintf(stderr, "could not update mount table\n");
 		unlock_mtab();
-		rc = EX_FILEIO;
 		goto add_mtab_exit;
 	}
#2 lore raw
In reply to a message not in the archive
Quoted 13 lines · On Wed, 04 Aug 2010 12:31:40 +0530 Suresh Jayaraman…

... as it is done anyway at add_mtab_exit.

---
 mount.cifs.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
mount.cifs.c +0 -0
index 9f04261..49fdd08 100644

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 *fstyp
 	if (!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]>
#4 lore raw
In reply to a message not in the archive
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_exit won't set it to EX_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
index 9f04261..3623e76 100644
@@ -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;
 }
#6 lore raw
In reply to a message not in the archive
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 *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_exit won't set it to EX_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 -5
index 9f04261..3623e76 100644
@@ -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]>