[Buildroot] Buildroot fails on powerpc with busybox login.c

Denis Vlasenko vda.linux at googlemail.com
Sun Sep 17 14:43:51 UTC 2006


On Friday 15 September 2006 18:32, Bernhard Fischer wrote:
> I spoke too soon. Turning off UTMP in the config still fails to
> compile..

Oh no... sorry...
 
> I'm attaching 3 incremental patches:
> 
> login.01_of_03.diff
> makes it build even if CONFIG_FEATURE_UTMP is turned off.

Thanks!
 
> login.02_of_03.diff
> shrink by perusing bb_common_bufsiz1

I think that this should not go in.

Rationale:

Using bb_common_bufsiz1 is in general a size-saving hack.
It is risky because it can create nasty bugs when someone else
will decide to use it in another part of the same program.
So it should be used with care. I'd say "only if size savings
are big enough to warrant it".

One place where you can use it more-or-less safely is in <applet>_main().
You can be sure that caller doesn't use it and you can
directly code it so that there are no calls to functions
which implicitly clobber bb_common_bufsiz1.
It's easy because currently no libbb function uses it IIRC.

But here it is used in a function, not in a <applet>_main().
The function has no way to check whether caller uses bb_common_bufsiz1
in an unsafe manner (i.e. across the call to this function).

So it is a bit scary here. And it gives no size savings AT ALL
because char buf[BUFSIZ] was an automatic variable on stack.

> login.02_of_03.diff
> shrink by perusing bb_getopt_ulflags()

+#define LOGIN_OPT_f (1<<0)
+#define LOGIN_OPT_h (1<<1)
+#define LOGIN_OPT_p (1<<2)

Defining constants using enum {...}; is saner.

-                       /*
-                        * username must be a separate token
-                        * (-f root, *NOT* -froot). --marekm
-                        */

I think this property is lost? OTOH I'm not sure it is a problem.

-               opt_fflag = 0;
+               opt ^= LOGIN_OPT_f;

I think you intend to turn it off here? Why you toggle it instead?

> Stats:
>    text    data     bss     dec     hex filename
>    1821       4      32    1857     741 login.o.01
>    1809       4      32    1845     735 login.o.02
>    1745       4      32    1781     6f5 login.o.03
> 
> I compile-tested them and assume that they didn't break anything, but
> can't test them at the moment.. If anyone can confirm that it still
> works as advertised, then please let me know. I'll try to check them in
> during the weekend except somebody raises objections.

I took liberty of applying 1st and 3rd patch. Thank you
for fixing my bugs.
--
vda



More information about the busybox mailing list