When building with gcc 9.3.0 on Ubuntu 20.04, 2 build warnings were seen:
util.c: In function ‘uuid_random’:
util.c:728:2: warning: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Wunused-result]
728 | asprintf(&uuid, "%04lx%04lx-%04lx-%04lx-%04lx-%04lx%04lx%04lx",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
729 | random() & 0xffff, random() & 0xffff,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
730 | random() & 0xffff,
| ~~~~~~~~~~~~~~~~~~
731 | (random() & 0x0fff) | 0x4000,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
732 | (random() & 0x3fff) | 0x8000,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
733 | random() & 0xffff, random() & 0xffff, random() & 0xffff);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
image-flash.c: In function ‘flash_generate’:
image-flash.c:37:8: warning: ignoring return value of ‘truncate’, declared with attribute warn_unused_result [-Wunused-result]
37 | (void)truncate(imageoutfile(image), 0);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If compiling with "-O0", these warnings were gone.
As you can see, the call to truncate() in image-flash.c is casted by (void), which seems to suppress exact this build warning, but it does not work, at least for GCC (haven't tried clang yet).
Actually casting the function call with (void) does not suppress this warning is a deliberate "feature" of GCC "-Wunused-result" attribute. There have been a lot of arguments in the community to persuade the GCC people to change the behavior. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425.
Configure result:
When building with gcc 9.3.0 on Ubuntu 20.04, 2 build warnings were seen:
If compiling with "-O0", these warnings were gone.
As you can see, the call to truncate() in image-flash.c is casted by (void), which seems to suppress exact this build warning, but it does not work, at least for GCC (haven't tried clang yet).
Actually casting the function call with (void) does not suppress this warning is a deliberate "feature" of GCC "-Wunused-result" attribute. There have been a lot of arguments in the community to persuade the GCC people to change the behavior. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425.