On 13.03.2016 00:05, Stefan Tauner wrote:
> This came up when I was testing if building on SunOS still works
> on the buildbot's instance of OmniOS r151014 which is based on illumos.
> The fix is
> - to link against libnsl
> - a small C type fix in ich_descriptor_tool
> Signed-off-by: Stefan Tauner <stefan.tauner(a)alumni.tuwien.ac.at>
> Acked-by: Stefan Tauner <stefan.tauner(a)alumni.tuwien.ac.at>
> diff --git a/util/ich_descriptors_tool/ich_descriptors_tool.c b/util/ich_descriptors_tool/ich_descriptors_tool.c
> index c3d9ba1..ad3b6f0 100644
> --- a/util/ich_descriptors_tool/ich_descriptors_tool.c
> +++ b/util/ich_descriptors_tool/ich_descriptors_tool.c
> @@ -170,7 +170,7 @@ int main(int argc, char *argv)
> usage(argv, "Seeking to the end of the file failed");
> #ifdef HAVE_MMAP
> - buf = mmap(NULL, len, PROT_READ, MAP_PRIVATE, fd, 0);
> + buf = (uint32_t *)mmap(NULL, len, PROT_READ, MAP_PRIVATE, fd, 0);
The compiler may require that to stop complaining, but AFAICS there is a
real bug behind this. buf is sometimes casted to uint8_t *, and unless
I'm too sleepy already, this buffer violates the strict aliasing rules.
We can solve this with -fno-strict-aliasing, or fix the code. With a
code fix, in theory the problem should go away.
> if (buf == (void *) -1)
Side note (no need to fix this right now)
if (len != read(fd, buf, len))
usage(argv, "Seeking to the end of the file
Somehow that error message doesn't fit with the code.