[BusyBox] bzip2 applet, work in progress

Neal H Walfield neal at cs.uml.edu
Sun Sep 23 05:17:19 UTC 2001


> In the original macro vvv was just an int and is usually assigned a new
> value and is then cast to either a char, short or int.
>
> In the new function im trying to make vvv an int pointer so its changed
> value is returned, this is when im getting the warning.
>
> static int get_bits_f(DState **s, unsigned int *vvv, char nnn)
> {snip}
>
> unsigned char uc = 0;
> get_bits_f(&s, &uc, 8);

This is wrong.  sizeof (unsigned char) != sizeof (unsigned int).
Since you are passing pointers around, the target will not (and
cannot) be promoted.  If get_bits_f will never store any value greater
then that which a unsigned char can hold, change the get_bits_f
prototype.

> or
>
> int  nSelectors;
> get_bits_f(&s, &nSelectors, 8);

You should not get a warning here, and, as my tests show that that is
indeed the case.  What options are you using?  Perhaps it is because I
was only using -Wall?

Either way, being a bit pedantic, you should be using an unsigned int
for nSelectors to avoid confusion from the sign bit.







More information about the busybox mailing list