-
-
Notifications
You must be signed in to change notification settings - Fork 416
Description
Describe the bug
A build with GCC can produce warnings ignoring return value (-Wunused-result) coming from library functions declared with attribute warn_unused_result (such as fgets and fread).
warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
This happens with the default setting on Ubuntu (so likely other systems too) and with the current development practices, today's warnings are tomorrow's errors.
To Reproduce
Compile with GGC with -Wunused-result, -Werror=unused-result, or default settings on Ubuntu 20.04. See also build in the ubuntu-20.04 tests job in the CI (e.g., run 4947257936) or a binder build (link for main, may not rebuild).
Expected behavior
No warnings. (Return values checked I guess.)
Screenshots
main.c: In function ‘update_reclass_maps’:
main.c:138:2: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
fgets(buf2, 255, fp);
^~~~~~~~~~~~~~~~~~~~
...
main.c:148:2: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result]
fread(str, l, 1, fp);
^~~~~~~~~~~~~~~~~~~~
System description
- Operating System: Ubuntu 20.04
- GRASS GIS version: releasebranch_8_0, main
Additional context
Besides the potential of this being configures as an error in the future, the warning is currently visible in several places, namely in some of the CI builds and during a build on mybinder.org where end users may see it too.