Thread (24 messages) 24 messages, 3 authors, 2011-11-02
STALE5343d

[PATCH 19/19] make_parts(): Avoid false positive security warning

From: <hidden>
Date: 2011-11-01 15:09:35
Subsystem: the rest · Maintainer: Linus Torvalds

From: Jes Sorensen <redacted>

S_ISBLK() and S_ISLNK() are mutually exclusive. By swapping the checks
round and testing S_ISBLK() first, we avoid having to silence the
compiler for uninitialized variable usage, and avoid a warning from
security checking tools.

Signed-off-by: Jes Sorensen <redacted>
---
 mdopen.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/mdopen.c b/mdopen.c
index 555ab84..e6db7d7 100644
--- a/mdopen.c
+++ b/mdopen.c
@@ -38,9 +38,9 @@ void make_parts(char *dev, int cnt)
 	 * else that of dev
 	 */
 	struct stat stb;
-	int major_num = major_num; /* quiet gcc -Os unitialized warning */
-	int minor_num = minor_num; /* quiet gcc -Os unitialized warning */
-	int odig = odig; /* quiet gcc -Os unitialized warning */
+	int major_num;
+	int minor_num;
+	int odig;
 	int i;
 	int nlen = strlen(dev) + 20;
 	char *name;
@@ -53,15 +53,15 @@ void make_parts(char *dev, int cnt)
 	if (lstat(dev, &stb)!= 0)
 		return;
 
-	if (S_ISLNK(stb.st_mode)) {
+	if (S_ISBLK(stb.st_mode)) {
+		major_num = major(stb.st_rdev);
+		minor_num = minor(stb.st_rdev);
+	} else if (S_ISLNK(stb.st_mode)) {
 		int len = readlink(dev, orig, sizeof(orig));
 		if (len < 0 || len > 1000)
 			return;
 		orig[len] = 0;
 		odig = isdigit(orig[len-1]);
-	} else if (S_ISBLK(stb.st_mode)) {
-		major_num = major(stb.st_rdev);
-		minor_num = minor(stb.st_rdev);
 	} else
 		   return;
 	name = malloc(nlen);
-- 
1.7.6.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help