is this cast valid?

Russ Allbery rra at stanford.edu
Tue Nov 14 19:37:36 UTC 2000


Heath Kehoe <heath.kehoe at intermec.com> writes:

> In current: innd/art.c, line 1211:

>         if (innconf->logipaddr) {
>             hops = ARTparsepath(HDR(_path), &hopcount);
> -->         (const char *)av[4] = hops && hops[0] ? hops[0] : CHANname(cp);
>         } else {
> -->         (const char *)av[4] = Data->Feedsite;
>         }

> What's the deal with those casts on the lvalue?  Is that legal?  The HP
> compiler says it's an error.  It will compile if I remove the casts.

If I'm reading that correctly, I think a better approach here is to cast
hops[0] and Data->Feedsite to (char *) so that they could be assigned to
av[4], which is a char *.  Either that or change av to const char **,
although I'm not sure that works for everything that's being put in it.

Looks like a partial const cleanliness problem.

-- 
Russ Allbery (rra at stanford.edu)             <http://www.eyrie.org/~eagle/>



More information about the inn-workers mailing list