examples: Do not assume positive errno macros
authorTormod Volden <debian.tormod@gmail.com>
Sat, 22 Jan 2022 13:39:45 +0000 (14:39 +0100)
committerTormod Volden <debian.tormod@gmail.com>
Sat, 22 Jan 2022 13:47:17 +0000 (14:47 +0100)
commitafcd360005dcbd3d9e6ed2d6e0255a7ad9efd3a7
treeb2c941f8dd1cf2cd4c12b57f33e49341b8c8ebf6
parent65b786f77d78df53c41c064ae958dffad1bbe222
examples: Do not assume positive errno macros

Some functions were returning e.g. -ENOMEM and the caller would check
for negative return values. However, on Haiku, contrary to modern
standards, these macros are negative, so this logic would fail. In any
case, change the function to return -1 instead. For good measure also
set errno to the appropriate value, although it is not used in the
current code.

This was discovered on Haiku builds because the value for ENOMEM is
INT_MIN which cannot be negated without overflow.

Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
examples/dpfp.c
examples/ezusb.c
examples/sam3u_benchmark.c
libusb/version_nano.h