lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <47391300.7070604@gmail.com>
Date:	Tue, 13 Nov 2007 05:59:12 +0300
From:	Dmitri Vorobiev <dmitri.vorobiev@...il.com>
To:	viro@...iv.linux.org.uk
CC:	Linux-kernel <linux-kernel@...r.kernel.org>
Subject: [PATCH] loop cleanup in fs/namespace.c

Hi Alexander,

Although the following non-idiomatic and quite cumbersome C language construct

label:
	if (condition) {
		// DO HARD WORK
		goto label;
	}

is equivalent to a simple while loop

while (condition) {
	// DO HARD WORK
}

it was the "label-if-goto label" approach chosen to implement the loop in the mntput_no_expire() routine located in `fs/namespace.c'.

The patch enclosed to this message changes the goto-based loop to a while-based one, not only saving us two lines of code, but also making the implementation idiomatic and thus more readable.

Thanks,

Dmitri

Signed-off-by: Dmitri Vorobiev <dmitri.vorobiev@...il.com>

--
diff --git a/fs/namespace.c b/fs/namespace.c
index 0608388..6a0cee1 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -278,8 +278,7 @@ static inline void __mntput(struct vfsmo
 
 void mntput_no_expire(struct vfsmount *mnt)
 {
-repeat:
-	if (atomic_dec_and_lock(&mnt->mnt_count, &vfsmount_lock)) {
+	while (atomic_dec_and_lock(&mnt->mnt_count, &vfsmount_lock)) {
 		if (likely(!mnt->mnt_pinned)) {
 			spin_unlock(&vfsmount_lock);
 			__mntput(mnt);
@@ -290,7 +289,6 @@ repeat:
 		spin_unlock(&vfsmount_lock);
 		acct_auto_close_mnt(mnt);
 		security_sb_umount_close(mnt);
-		goto repeat;
 	}
 }
 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ