Skip to contentSkip to conversation

Fix warning in device_add_attrs

PATCH New Jean Delvare 1 participant 1 message Feb 6, 2007 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix warning in device_add_attrs

Fix the following warning which I see with gcc 3.2:
drivers/base/core.c: In function `device_add_attrs':
drivers/base/core.c:251: warning: `i' might be used uninitialized in this function It's a false positive, but it can be worked around easily, and the new code makes rather more sense.

---
 drivers/base/core.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/base/core.c +3 -3
@@ -259,10 +259,10 @@ static int device_add_attrs(struct devic
 			if (error)
 				break;
 		}
+		if (error)
+			while (--i >= 0)
+				device_remove_file(dev, &class->dev_attrs[i]);
 	}
-	if (error)
-		while (--i >= 0)
-			device_remove_file(dev, &class->dev_attrs[i]);
 	return error;
 }
 
Signature · 1 line
Jean Delvare