llist_t and llist_pop

Robert P. J. Day rpjday at mindspring.com
Fri May 19 14:49:53 UTC 2006


On Fri, 19 May 2006, Robert P. J. Day wrote:

> On Fri, 19 May 2006, Yann E. MORIN wrote:
>
> > On Friday 19 May 2006 153, Robert P. J. Day wrote:
> > > On Fri, 19 May 2006, Yann E. MORIN wrote:
> > [--SNIP: llist_pop returns data (which is char*) as a void* --]
> > > because a "void*" can represent a pointer to anything.
> >
> > I know that.
> > The real question was: why is it stored as a char* in the first place?
>
> ah, sorry, i misread your post.  you're right.  you'd think they
> should all be "void*", wouldn't you?

ah, i just noticed what's happening with that "void*" versus "char*"
in the llist routines.  normally, you'd expect that a list would
accept completely generic "void*" pointers to store.

but if you look at archival/tar.c, line 305:

  if (excluded_files->data[0] == '/') {

what that's clearly doing is treating the data pointer as a "char*" so
that it can immediately do a character comparison.  the *proper* way,
i would think, is to have to cast that "void*" to "char*" first.  in
short, the code is being lazy so it doesn't have to do that cast every
time it needs to do a character comparison.

at least, that's the way i read it.  the proper fix would be for llist
to use *only* "void*" pointers, and have all of the calling routines
be forced to do the proper casting.

rday





More information about the busybox mailing list