[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gnugo-devel] Cast to unsigned
From: |
Gunnar Farneback |
Subject: |
Re: [gnugo-devel] Cast to unsigned |
Date: |
Thu, 07 Aug 2003 21:01:51 +0200 |
User-agent: |
EMH/1.14.1 SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.3 Emacs/20.7 (sparc-sun-solaris2.7) (with unibyte mode) |
Arend wrote:
> > Arend, you (I think) introduced casts to unsigned in some comparisons in
> > cache.c. One of them is in tt_get() and looks like this:
> >
> > if ((unsigned) remaining_depth <= hn_get_remaining_depth(*node)) {
> > if (result)
> > *result = hn_get_result1(*node);
> > return 2;
> > }
> >
> > These give warnings about comparison between singed and unsigned,
> > and before I try to fix them, I think that I must understand the
> > reason for the cast. Can you elaborate?
>
> These were to avoid compiler warnings when .data in the hash nodes
> was still unsigned (as it has to be).
Does it really? I think it works with int too, although I would agree
that unsigned makes it clearer, in particular if the highest bit is
used. If we change to unsigned I would suggest adding casts to the
hn_get_* macros instead. It should be cleaner than having lots of
casts spread over the code.
/Gunnar