[BusyBox] bzip2 applet, work in progress
Glenn McGrath
bug1 at optushome.com.au
Sun Sep 23 06:49:47 UTC 2001
On Sun, 23 Sep 2001 13:18:38 +0200
Neal H Walfield <neal at cs.uml.edu> wrote:
> > 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.
>
I was hoping that i could do a cast, but now i see why that cant work
> > 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.
>
What ive currently done is at http://people.debian.org/~bug1/bzip2.c
Maybe the best idea is to return(vvv); and send the error code of the
function in a pass by value
Glenn
More information about the busybox
mailing list