Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a couple of unused value warnings when built with NDEBUG #1688

Merged
merged 1 commit into from
Nov 13, 2023

Conversation

daviesrob
Copy link
Member

The warnings appeared due to the values only being used for assert() statements. The one in cram_stats_encoding() is just checking some counts, so the variable is just annotated with HTS_UNUSED to silence the warning.

The assert() in cram_index_build() could actually be triggered with a suitably-adjusted cram file. As it therefore detects bad inputs, it is replaced with code to write a better error message and return the documented value for read errors in this function.

The attached bad_len.zip file contains an example that can be used to test cram_index_build() via

./test/test_index bad_len.cram

The warnings appeared due to the values only being used for
assert() statements.  The one in cram_stats_encoding() is
just checking some counts, so the variable is just annotated
with HTS_UNUSED to silence the warning.

The assert() in cram_index_build() could actually be triggered
with a suitably-adjusted cram file.  As it therefore detects
bad inputs, it is replaced with code to write a better error
message and return the documented value for read errors in this
function.
@jkbonfield jkbonfield merged commit 2140d03 into samtools:develop Nov 13, 2023
@daviesrob daviesrob deleted the ndebug branch November 14, 2023 14:08
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.

2 participants