Skip to content

Fix -Wunused-parameter and -Wstringop-truncation warnings - #52

Open
selinger wants to merge 1 commit into
jasper-software:mainfrom
selinger:fix-two-trivial-warnings
Open

selinger wants to merge 1 commit into
jasper-software:mainfrom
selinger:fix-two-trivial-warnings

Conversation

@selinger

Copy link
Copy Markdown

This patch fixes two compiler warnings.

xvorient.c: -Wunused-parameter warning: get_exif_orientation()'s buf/bufsize parameters are used in the #else (HAVE_EXIF) branch but not in the #ifndef HAVE_EXIF fallback that just returns ORIENT_NONE. Mark them explicitly unused in that branch with (void) casts, to avoid compiler warning.

xvpds.c: -Wstringop-truncation warning: the strncat(inote, tmptmp, INOTESIZE - strlen(inote) - 1) call is fine at runtime, but GCC can't prove it so will warn about it. Switched to snprintf-based concatenation, which has well-defined truncation semantics GCC can verify. Also added an explicit guard against inote_len reaching INOTESIZE (which would otherwise underflow the computed size argument).

xvorient.c: get_exif_orientation()'s buf/bufsize parameters are used
in the #else (HAVE_EXIF) branch but not in the #ifndef HAVE_EXIF
fallback that just returns ORIENT_NONE. Mark them explicitly unused
in that branch with (void) casts, to avoid compiler warning.

xvpds.c: the strncat(inote, tmptmp, INOTESIZE - strlen(inote) - 1)
call is fine at runtime, but GCC can't prove it so will warn about it.
Switched to snprintf-based concatenation, which has well-defined
truncation semantics GCC can verify. Also added an explicit guard
against inote_len reaching INOTESIZE (which would otherwise
underflow the computed size argument).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant