public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: xfs@oss.sgi.com
Subject: [PATCH] xfsprogs: tidy up xfs_fsr.c
Date: Tue, 10 Nov 2015 14:45:46 -0600	[thread overview]
Message-ID: <5642577A.8000206@sandeen.net> (raw)
In-Reply-To: <20151110202806.GG14311@dastard>

Make the mountpoint stat structure "ms" local to
find_mountpoint_check(), no caller uses it.  And remove 3rd
"sb2" statbuf in that same function, we can just re-use ms.

rename "struct mntent *mp" to "struct mntent *mnt" -
"mp" has its own common meaning in xfsprogs.

And a couple more minor whitespace removals.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
index 2887ceb..d5962f7 100644
--- a/fsr/xfs_fsr.c
+++ b/fsr/xfs_fsr.c
@@ -177,44 +177,41 @@ aborter(int unused)
  * of that.
  */
 static char *
-find_mountpoint_check(struct stat64 *sb, struct mntent *t, struct stat64 *ms)
+find_mountpoint_check(struct stat64 *sb, struct mntent *t)
 {
+	struct stat64 ms;
+
 	if (S_ISDIR(sb->st_mode)) {		/* mount point */
-		if (stat64(t->mnt_dir, ms) < 0)
+		if (stat64(t->mnt_dir, &ms) < 0)
 			return NULL;
-		if (sb->st_ino != ms->st_ino)
+		if (sb->st_ino != ms.st_ino)
 			return NULL;
-		if (sb->st_dev != ms->st_dev)
+		if (sb->st_dev != ms.st_dev)
 			return NULL;
 		if (strcmp(t->mnt_type, MNTTYPE_XFS) != 0)
 			return NULL;
 	} else {				/* device */
-		struct stat64 sb2;
-
-		if (stat64(t->mnt_fsname, ms) < 0)
+		if (stat64(t->mnt_fsname, &ms) < 0)
 			return NULL;
-		if (sb->st_rdev != ms->st_rdev)
+		if (sb->st_rdev != ms.st_rdev)
 			return NULL;
 		if (strcmp(t->mnt_type, MNTTYPE_XFS) != 0)
 			return NULL;
-
 		/*
 		 * Make sure the mountpoint given by mtab is accessible
 		 * before using it.
 		 */
-		if (stat64(t->mnt_dir, &sb2) < 0)
+		if (stat64(t->mnt_dir, &ms) < 0)
 			return NULL;
 	}
 
 	return t->mnt_dir;
-
 }
 
 static char *
 find_mountpoint(char *mtab, char *argname, struct stat64 *sb)
 {
 	struct mntent_cursor cursor;
-	struct stat64 ms;
 	struct mntent *t = NULL;
 	char *mntp = NULL;
 
@@ -224,7 +221,7 @@ find_mountpoint(char *mtab, char *argname, struct stat64 *sb)
 	}
 
 	while ((t = platform_mntent_next(&cursor)) != NULL) {
-		mntp = find_mountpoint_check(sb, t, &ms);
+		mntp = find_mountpoint_check(sb, t);
 		if (mntp == NULL)
 			continue;
 		break;
@@ -408,7 +405,7 @@ static void
 initallfs(char *mtab)
 {
 	struct mntent_cursor cursor;
-	struct mntent *mp = NULL;
+	struct mntent *mnt= NULL;
 	int mi;
 	char *cp;
 	struct stat64 sb;
@@ -429,15 +426,15 @@ initallfs(char *mtab)
 		exit(1);
 	}
 
-	while ((mp = platform_mntent_next(&cursor)) != NULL) {
+	while ((mnt = platform_mntent_next(&cursor)) != NULL) {
 		int rw = 0;
 
-		if (strcmp(mp->mnt_type, MNTTYPE_XFS ) != 0 ||
-		    stat64(mp->mnt_fsname, &sb) == -1 ||
+		if (strcmp(mnt->mnt_type, MNTTYPE_XFS ) != 0 ||
+		    stat64(mnt->mnt_fsname, &sb) == -1 ||
 		    !S_ISBLK(sb.st_mode))
 			continue;
 
-		cp = strtok(mp->mnt_opts,",");
+		cp = strtok(mnt->mnt_opts,",");
 		do {
 			if (strcmp("rw", cp) == 0)
 				rw++;
@@ -445,7 +442,7 @@ initallfs(char *mtab)
 		if (rw == 0) {
 			if (dflag)
 				fsrprintf(_("Skipping %s: not mounted rw\n"),
-					mp->mnt_fsname);
+					mnt->mnt_fsname);
 			continue;
 		}
 
@@ -465,15 +462,15 @@ initallfs(char *mtab)
 			fs = (fsbase + mi);  /* Needed ? */
 		}
 
-		fs->dev = strdup(mp->mnt_fsname);
-		fs->mnt = strdup(mp->mnt_dir);
+		fs->dev = strdup(mnt->mnt_fsname);
+		fs->mnt = strdup(mnt->mnt_dir);
 
 		if (fs->dev == NULL) {
-			fsrprintf(_("strdup(%s) failed\n"), mp->mnt_fsname);
+			fsrprintf(_("strdup(%s) failed\n"), mnt->mnt_fsname);
 			exit(1);
 		}
 		if (fs->mnt == NULL) {
-			fsrprintf(_("strdup(%s) failed\n"), mp->mnt_dir);
+			fsrprintf(_("strdup(%s) failed\n"), mnt->mnt_dir);
 			exit(1);
 		}
 		mi++;


_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

      parent reply	other threads:[~2015-11-10 20:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-10 18:21 [PATCH] xfsprogs: fix cut & paste error in xfs_fsr.c Eric Sandeen
2015-11-10 18:45 ` Eric Sandeen
2015-11-10 20:28 ` Dave Chinner
2015-11-10 20:35   ` Eric Sandeen
2015-11-11 13:13     ` Jan Tulak
2015-11-11 15:41       ` Eric Sandeen
2015-11-10 20:45   ` Eric Sandeen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5642577A.8000206@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox