Skip to contentSkip to conversation

tlclk.c: pointers are handled by %p

PATCH In review Al Viro 3 participants 3 messages Dec 15, 2005 – Dec 16, 2005

Subsystems (2)
lore
Share & tools
lore

Al Viro

author
#0 lore raw

PATCH 1/1 tlclk.c: pointers are handled by %p

---

 drivers/char/tlclk.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

f1bbf945c86b729c20199133daba358284fa3c32

drivers/char/tlclk.c +2 -2
index 12167c0..e8467dc 100644
@@ -776,8 +776,8 @@ static int __init tlclk_init(void)
 	tlclk_device = platform_device_register_simple("telco_clock",
 				-1, NULL, 0);
 	if (!tlclk_device) {
-		printk(KERN_ERR " platform_device_register retruns 0x%X\n",
-			(unsigned int) tlclk_device);
+		printk(KERN_ERR " platform_device_register retruns 0x%p\n",
+			tlclk_device);
 		ret = -EBUSY;
 		goto out4;
 	}
Signature · 1 line
0.99.9.GIT
#1 lore raw

drivers/char/tlclk.c static int __init tlclk_init(void) · line 780

Quoted 12 lines · Al Viro
drivers/char/tlclk.c +2 -2
index 12167c0..e8467dc 100644
@@ -776,8 +776,8 @@ static int __init tlclk_init(void)
 	tlclk_device = platform_device_register_simple("telco_clock",
 				-1, NULL, 0);
 	if (!tlclk_device) {
-		printk(KERN_ERR " platform_device_register retruns 0x%X\n",
-			(unsigned int) tlclk_device);
+		printk(KERN_ERR " platform_device_register retruns 0x%p\n",
+			tlclk_device);

This looks really strange - we know what tlclk_device will be at that printk - it'll be NULL because if it's anything different we wouldn't be inside this if(){ }.

Moreover, this code is obviously bogus. platform_device_register_simple does not return NULL for the error case. It should be something like:

	if (IS_ERR(tlclk_device)) {
		ret = PTR_ERR(tlclk_device);
		printk(KERN_ERR "platform_device_register returns %d\n",
		        ret);
		goto out4;
	}
Signature · 3 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core
#2 lore raw
Quoted 21 lines · Russell King

drivers/char/tlclk.c static int __init tlclk_init(void) · line 780

Quoted 12 lines · Al Viro
drivers/char/tlclk.c +2 -2
index 12167c0..e8467dc 100644
@@ -776,8 +776,8 @@ static int __init tlclk_init(void)
 	tlclk_device = platform_device_register_simple("telco_clock",
 				-1, NULL, 0);
 	if (!tlclk_device) {
-		printk(KERN_ERR " platform_device_register retruns 0x%X\n",
-			(unsigned int) tlclk_device);
+		printk(KERN_ERR " platform_device_register retruns 0x%p\n",
+			tlclk_device);

This looks really strange - we know what tlclk_device will be at that printk - it'll be NULL because if it's anything different we wouldn't be inside this if(){ }.

Moreover, this code is obviously bogus. platform_device_register_simple does not return NULL for the error case. It should be something like:

Quoted 7 lines
	if (IS_ERR(tlclk_device)) {
		ret = PTR_ERR(tlclk_device);
		printk(KERN_ERR "platform_device_register returns %d\n",
		        ret);
		goto out4;
	}

I have a patch killing usage of platform_register_device_simple in this driver (converting to platform_device_alloc() + _add()). Will post in a minute.

Signature · 1 line
Dmitry