On Thursday 12 June 2008 21:02, Cristian Ionescu-Idbohrn wrote: > Been chasing a bug we added to busybox ourselfs :( > The applet is login. We added some extra functionality to that applet. > I could provide details if there is intrest. > > Bottom line is we used variable 'opt_host' without ensuring > '(opt & LOGIN_OPT_h)' was true. > > Talked to the gcc-cris author, while chasing the bug, about one specific > declaration (which is supposed to keep gcc from warning about > uninitialized variables). In this particular case: > > char *opt_host = opt_host; /* for compiler */ > > Yes, doing it like that saves some bytes but it is highly questionable if > it's TRT to do, as you can count on gcc-undeterministic behaviour (IOW, be > prepared for surprises).
I would expect that opt_host stays undefined, but compiler no longer complains. Hopefully, it also does not generate any actual instructions here. > Proper thing to do would be: > > char *opt_host = NULL; > > Yes, it will cost some bytes in each place that construct is used, but > doing it the right way will save some grief. In what sense is it "the right way"? I agree that it has an advantage of not just shutting up the compiler, but also providing a deterministic value for the variable. But it results in bigger code. The people who started busybox project were very paranoid about size. I am less paranoid, but I want to respect the spirit of the project and not enlarge code needlessly. In case when applet is not too complex, smaller code is much preferred. login.c is about ten screenfuls of text on my non-oversized display, I guess it qualifies as "not too complex". "Complex applet" would be a shell, or httpd, etc. -- vda _______________________________________________ busybox mailing list [email protected] http://busybox.net/cgi-bin/mailman/listinfo/busybox
