Stichting-MINIX-Research-Foundation/minix — pull request #5 by eblot (2014-11-07 17:26:10+00:00)
Title: Fix bad cast from `u16_t` to `ssize_t`

While building procfs with -O0 on ARM target, I ran into this error:

fs/procfs/CMakeFiles/procfs.dir/util.c.o: In function `procfs_getloadavg':
util.c:(.text+0x1e4): undefined reference to `__aeabi_i2d'
util.c:(.text+0x214): undefined reference to `__aeabi_ui2d'
util.c:(.text+0x228): undefined reference to `__aeabi_dadd'
util.c:(.text+0x23c): undefined reference to `__aeabi_d2iz'

Those functions are ARM conversion helpers from/to integer/double types

The only double used in procfs_getloadavg is here:

12: struct loadinfo loadinfo;
16: ssize_t l;
53: l += (double) loadinfo.proc_load_history[slot];

The cast is somewhat weird, as loadinfo.proc_load_history is a u16_t,
and the result is a ssize_t, i.e. integer types.
I'm wondering if this cast is not a left over from a previous editing?

I guess that with default -O2, GCC is clever enough not to apply the cast.