[BusyBox] two busybox problems
Erik Andersen
andersen at lineo.com
Fri Sep 15 20:29:46 UTC 2000
On Thu Sep 14, 2000 at 07:02:42PM -0500, Chip Rosenthal wrote:
> On Thu, Sep 14, 2000 at 05:43:28PM -0500, Chip Rosenthal wrote:
> > First, when I do cp /proc/net/pnp /etc/resolv.conf it creates an empty
> > file instead of a file with the "pnp" contents. I haven't determined
> > whether it's happening with all of the /proc stuff or if it's just this
> > one entry.
>
> Ewww ... this is not good. The reason for this problem is that busybox
> defines:
>
> #define TRUE 0
> #define FALSE 1
>
> This is backwards logic. The isDirectory() routine is returning these
> values, and it's being mis-interpreted by cp_mv_main.
>
> I *strongly* urge correcting these to TRUE == 1, FALSE == 0.
>
> Then, when you need to do an exit status (where 0 == success) you
> can do:
>
> exit(some_boolean_flag ? EXIT_SUCCESS : EXIT_FAILURE)
>
> Erik - Let me know if you want me to implement this.
Yes, please do. This is a carryover from the code I swiped from sash (dd and a
now replaced version of tar), and is (as you noticed) an ugly wart. At that
time I added these defines to make things work, and then (oh the horror) I
ended up using them. Sigh.
The place where this is most ugly, is where I have foolishly used exit(TRUE)
and exit(FALSE) all over the place -- relying on the backwardness of the
definition. These all need to be replaced with EXIT_SUCCESS and EXIT_FAILURE.
The other potential problem is anywhere that is using 'if (variable) { foo(); }'
type logic. I think most of these have been weeded out by now and replaced
with 'if (variable==TRUE) { foo(); }' type code (or else nothing would work).
-Erik
--
Erik B. Andersen email: andersen at lineo.com
--This message was written using 73% post-consumer electrons--
More information about the busybox
mailing list