[PATCH] cramfs: probe(): fix cdev lookup
Sascha Hauer
s.hauer at pengutronix.de
Thu Dec 17 06:00:26 EST 2009
On Thu, Dec 17, 2009 at 11:32:44AM +0100, Uwe Kleine-König wrote:
> Hello Peter,
>
> On Thu, Dec 17, 2009 at 11:24:55AM +0100, Peter Korsgaard wrote:
> > >>>>> "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
> hmmmm, I have here:
>
> ukleinek at cassiopeia:~$ cat test.c
> #include <string.h>
>
> size_t strlen(const char *s)
> {
> return 2;
> }
>
> int main(int argc, char **argv)
> {
> printf("strlen(\"Peter Korsgaard\") = %d\n", strlen("Peter Korsgaard"));
> return 0;
> }
>
> ukleinek at cassiopeia:~$ gcc test.c -o test
> ukleinek at cassiopeia:~$ ./test
> strlen("Peter Korsgaard") = 15
>
> So the compiler *is* smart. (Maybe even smarter than most people
> expect.)
The -fno-builtin makes the difference here. In barebox strlen is called
no matter what.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list