Re: [PATCH] ihash ids should be unsigned
Roland McGrath <[email protected]> Sat, 16 Aug 2003 21:29:22 -0400 (EDT)
| Newsgroups | gmane.os.hurd.devel.readers |
|---|---|
| Message-ID | <[email protected]> |
> the libihash ids are signed integers, but all users actually provide > unsigned integers, and expect it to work. If a large integer is provided > that is cast to a negative number, the hash value will be negative as well, > and there will be underflow errors (negative array indices). I remember > that Neal told me he actually saw that happening, but I don't know in what > code it was (ours, or code he was hacking) and under which situation. > Anyway, it's apparently wrong. Neal seems to like to use unsigned long > instead, which would give 64 bit on 64 bit arches, but I am more > conservative and provide this patch which uses unsigned int. Sounds good. I am sort of inclined to switch to uint32_t or something like that. I don't think there would be a problem using uintptr_t (long) and having 64 bits on 64-bit machines. But it doesn't buy you anything, since it's used mostly for PIDs (pid_t = int = 32 bits) and port names (mach_port_t = unsigned = 32 bits). > I also want to remove ihash/primes.c which is obsolete but wasn't removed at > the time Roland replaced it by sizes.c. The file will still be in the > repository, of course (under Attic). Fine.