Commit 9127a5e
committed
libretro-common/samples/streams/rzip: silence fgets -Wunused-result
Minor bit-rot cleanup. Every CI build of the libretro-common
samples workflow emitted:
rzip.c:246:7: warning: ignoring return value of 'fgets' declared
with attribute 'warn_unused_result' [-Wunused-result]
The sample prompts the user with "Overwrite? [Y/n]" and reads
the reply with fgets. The existing code already handles fgets
failure correctly -- reply[0] is initialised to '\0' on line
242, so an EOF or read error leaves reply[0] == '\0' and the
subsequent "if (reply[0] != 'Y')" short-circuits to the safe
"don't overwrite" path. The warning is the tool correctly
noticing that the return value is unused; the code is in fact
correct.
Fix: cast the fgets call to (void)! to explicitly signal that
the return is intentionally ignored. Add a comment explaining
the fail-safe interaction with the reply[0] == '\0' init. This
is the same (void)!<call> idiom used elsewhere in the repository
to silence GCC/glibc's warn_unused_result without changing
behaviour.
Verified:
- CFLAGS += -Wall -Wunused-result -pedantic -std=gnu99:
clean compile (warning gone, no new warnings).
- Full libretro-common samples CI dry-run:
Built: 15 Ran: 15 Failed: 0
The only remaining warning in the full dry-run is the
pre-existing "ISO C forbids an empty translation unit" from
compat_snprintf.c, which is in the main library (not a
sample) and has a different root cause -- separate concern.
Regression test: NONE. This is a diagnostic cleanup on a
build-only sample; there is no behaviour change to discriminate.1 parent f3bf03e commit 9127a5e
1 file changed
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
246 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
247 | 253 | | |
248 | 254 | | |
249 | 255 | | |
| |||
0 commit comments