Skip to content

Commit

Permalink
Add more warnings and reenable -Werror.
Browse files Browse the repository at this point in the history
These find an old bug-let in hts_parse_format():
The buffer size is 8, but it includes \0 so the string would have been
truncated, causing the strcmp to fail for "fastq.gz".

Curiously gcc 10 and 11 spot this, but not gcc 12 or 13, nor clang.

Some builds didn't have -Werror enabled, such as those without
./configure and on Windows.
  • Loading branch information
jkbonfield committed Aug 22, 2024
1 parent 16abf8c commit 6686ac3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ gcc_task:
DO_MAINTAINER_CHECKS: yes
DO_UNTRACKED_FILE_CHECK: yes
USE_CONFIG: no
CFLAGS: -g -O2 -Wall -Werror
- environment:
USE_CONFIG: yes
# ubsan is incompatible with some -Wformat opts so we do that on clang.
Expand Down Expand Up @@ -141,7 +142,7 @@ rocky_task:
LC_ALL: C
CIRRUS_CLONE_DEPTH: 1
USE_CONFIG: yes
CFLAGS: -std=gnu90 -Wformat -Wformat=2
CFLAGS: -g -O3 -std=gnu90 -Wformat -Wformat=2 -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-empty-body

# NB: we could consider building a docker image with these
# preinstalled and specifying that instead, to speed up testing.
Expand Down Expand Up @@ -199,6 +200,7 @@ macosx_task:
matrix:
- environment:
USE_CONFIG: no
CFLAGS: -g -O2 -Wall -Werror
- environment:
USE_CONFIG: yes
USE_LIBDEFLATE: yes
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
export PATH="/mingw64/bin:$PATH:/c/Program Files/Git/bin"
export MSYSTEM=MINGW64
autoreconf -i
./configure
./configure --enable-werror
make cc-version
make -j6
- name: Check Htslib
Expand Down
2 changes: 1 addition & 1 deletion hts.c
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,7 @@ int hts_parse_opt_list(htsFormat *fmt, const char *str) {
* -1 on failure.
*/
int hts_parse_format(htsFormat *format, const char *str) {
char fmt[8];
char fmt[9];
const char *cp = scan_keyword(str, ',', fmt, sizeof fmt);

format->version.minor = 0; // unknown
Expand Down
1 change: 1 addition & 0 deletions test/test-bcf-sr.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ int main(int argc, char *argv[])
break;
case 'h':
usage(EXIT_SUCCESS);
// fall-through
default: usage(EXIT_FAILURE);
}
}
Expand Down

0 comments on commit 6686ac3

Please sign in to comment.