It's implementation-defined whether the C '>>' operator, when
applied to a signed integer, is sign-extending or zero-filling.
If you want unsigned arithmetic, you have to ask for it explicitly.
One assumes the reason for the shift is to avoid overflow if the
returned size/count is later converted to a signed int, in which
case maybe it would be better to use INT_MAX here. This is the
minimal change necessary for correctness.
Change-Id: I6e848110963b5e1832a11d052d84884f10903e2e
Reviewed-on: http://gerrit.openafs.org/7800
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
u_int size;
u_int nodesize;
- /* FIXME: this does not look correct: MSVC 6 computes -2 here */
- if (maxsize > ((~0) >> 1) - 1)
- maxsize = ((~0) >> 1) - 1;
+ if (maxsize > ((~0u) >> 1) - 1)
+ maxsize = ((~0u) >> 1) - 1;
/*
* first deal with the length since xdr strings are counted-strings
bool_t stat = TRUE;
u_int nodesize;
- /* FIXME: this does not look correct: MSVC 6 computes -1 / elsize here */
- i = ((~0) >> 1) / elsize;
+ i = ((~0u) >> 1) / elsize;
if (maxsize > i)
maxsize = i;