[PATCH] cramfs: probe(): fix cdev lookup
Peter Korsgaard
jacmet at sunsite.dk
Thu Dec 17 05:24:55 EST 2009
>>>>> "Sascha" == Sascha Hauer <s.hauer at pengutronix.de> writes:
>> > doh! I'm out of brown paper bags.
>> instead of sizeof("...") - 1, strlen should work.
Sascha> Yes, it works, but adds to the binary space. This doesn't matter in this
Sascha> case since the binary size does not really matter for the sandbox, but
Sascha> we don't want other people to copy such things.
Notice that this is in fs/cramfs/crams.c, so not specific to sandbox. I
would imagine gcc would be smart enough to replace strlen("/dev/") with
the constant 5, but apparently not:
nm -S fs/cramfs/cramfs.o{.orig,}|grep cramfs_probe
0000000000000053 000000000000015d t cramfs_probe
0000000000000053 000000000000016f t cramfs_probe
With the difference between those two being:
diff --git a/fs/cramfs/cramfs.c b/fs/cramfs/cramfs.c
index 73a3759..a06cb21 100644
--- a/fs/cramfs/cramfs.c
+++ b/fs/cramfs/cramfs.c
@@ -428,10 +428,10 @@ static int cramfs_probe(struct device_d *dev)
priv = xmalloc(sizeof(struct cramfs_priv));
dev->priv = priv;
- if (strncmp(fsdev->backingstore, "/dev/", 5))
+ if (strncmp(fsdev->backingstore, "/dev/", strlen("/dev/")))
return -ENODEV;
- priv->cdev = cdev_by_name(fsdev->backingstore + 5);
+ priv->cdev = cdev_by_name(fsdev->backingstore + strlen("/dev/"));
if (!priv->cdev)
return -ENODEV;
--
Bye, Peter Korsgaard
More information about the barebox
mailing list