Re: [PATCH] cramfs: probe(): fix cdev lookup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>>>>> "Sascha" == Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> 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

_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox

[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux