[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] Gluestik: CNbyte_count() bug?



Pierre Ton-That, 05.01.2013 03:28:18:

gs_stik.c:
static int16 do_CNbyte_count (struct CNbyte_count_param p) { return
gs_canread (p.fd); }

gs_func.c:
long gs_canread (int fd) { ... }

Is this a bug? I'm from GFA, so "long" is 32bits, and "int16", well,
16bits... Correct me, but I understand gs_canread() can return a byte

It's not a bug: The compiler converts the 32-return from gs_canread into 16 bit for the return. But it's not really clean, should give a warning.

number greater than 32767, and the result is a negative value
interpreted as an error.

This could happen if int16 is signed.

--
Helmut Karlowski