Skip to contentSkip to conversation

Error in ERR_PTR usage

PATCH New Yum Rayan 1 participant 1 message Mar 20, 2005 JFS filesystem

lore
Share & tools
lore

Yum Rayan

author
#0 lore raw

PATCH 1/1 Error in ERR_PTR usage

Was trying to understand ERR_PTR and friends and surprisingly the first 2 references via LXR seem to be erroneous. Did grep and found 1 additional incorrect reference "return ERR_PTR(0)" and another "ERR_PTR(PTR_ERR(p))" usage. Please let me know if this patch is good. If need be, I can chop it up for the individual maintainers, but it would be nice if someone can comment first.

Thanks,
Rayan

diff -Nur linux-2.6.11.5.orig/drivers/video/backlight/backlight.c linux-2.6.11.5/drivers/video/backlight/backlight.c
--- linux-2.6.11.5.orig/drivers/video/backlight/backlight.c 2005-03-18
22:34:50.000000000 -0800
+++ linux-2.6.11.5/drivers/video/backlight/backlight.c 2005-03-19
22:21:45.058128838 -0800
@@ -174,7 +174,7 @@

new_bd = kmalloc(sizeof(struct backlight_device), GFP_KERNEL); if (unlikely(!new_bd))
- return ERR_PTR(ENOMEM);
+ return ERR_PTR(-ENOMEM);

init_MUTEX(&new_bd->sem);
new_bd->props = bp;
diff -Nur linux-2.6.11.5.orig/drivers/video/backlight/lcd.c linux-2.6.11.5/drivers/video/backlight/lcd.c
--- linux-2.6.11.5.orig/drivers/video/backlight/lcd.c 2005-03-18
22:35:04.000000000 -0800
+++ linux-2.6.11.5/drivers/video/backlight/lcd.c 2005-03-19
22:22:02.923823575 -0800
@@ -173,7 +173,7 @@

new_ld = kmalloc(sizeof(struct lcd_device), GFP_KERNEL); if (unlikely(!new_ld))
- return ERR_PTR(ENOMEM);
+ return ERR_PTR(-ENOMEM);

init_MUTEX(&new_ld->sem);
new_ld->props = lp;

fs/jfs/namei.c +1 -1
diff -Nur linux-2.6.11.5.orig/fs/jfs/namei.c linux-2.6.11.5/fs/jfs/namei.c
@@ -1420,7 +1420,7 @@
 		free_UCSname(&key);
 		if (rc == -ENOENT) {
 			d_add(dentry, NULL);
-			return ERR_PTR(0);
+			return ERR_PTR(-ENOENT);
 		} else if (rc) {
 			jfs_err("jfs_lookup: dtSearch returned %d", rc);
 			return ERR_PTR(rc);

diff -Nur linux-2.6.11.5.orig/fs/reiserfs/xattr.c
linux-2.6.11.5/fs/reiserfs/xattr.c

fs/reiserfs/xattr.c +3 -3
@@ -200,7 +200,7 @@
 
     xadir = open_xa_dir (inode, flags);
     if (IS_ERR (xadir)) {
-        return ERR_PTR (PTR_ERR (xadir));
+        return xadir;
     } else if (xadir && !xadir->d_inode) {
         dput (xadir);
         return ERR_PTR (-ENODATA);
@@ -209,7 +209,7 @@
     xafile = lookup_one_len (name, xadir, strlen (name));
     if (IS_ERR (xafile)) {
         dput (xadir);
-        return ERR_PTR (PTR_ERR (xafile));
+        return xafile;
     }
 
     if (xafile->d_inode) { /* file exists */
@@ -251,7 +251,7 @@
 
     xafile = get_xa_file_dentry (inode, name, flags);
     if (IS_ERR (xafile))
-        return ERR_PTR (PTR_ERR (xafile));
+        return xafile;
     else if (!xafile->d_inode) {
         dput (xafile);
         return ERR_PTR (-ENODATA);