Skip to content

Commit 5d54aa5

Browse files
jkbonfieldwhitwham
authored andcommitted
Add more warnings and reenable -Werror.
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.
1 parent f399d69 commit 5d54aa5

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

.cirrus.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ gcc_task:
7272
DO_MAINTAINER_CHECKS: yes
7373
DO_UNTRACKED_FILE_CHECK: yes
7474
USE_CONFIG: no
75+
CFLAGS: -g -O2 -Wall -Werror -fvisibility=hidden
7576
- environment:
7677
USE_CONFIG: yes
7778
# ubsan is incompatible with some -Wformat opts so we do that on clang.
@@ -141,7 +142,7 @@ rocky_task:
141142
LC_ALL: C
142143
CIRRUS_CLONE_DEPTH: 1
143144
USE_CONFIG: yes
144-
CFLAGS: -std=gnu90 -Wformat -Wformat=2
145+
CFLAGS: -g -O3 -std=gnu90 -Wformat -Wformat=2 -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-empty-body
145146

146147
# NB: we could consider building a docker image with these
147148
# preinstalled and specifying that instead, to speed up testing.

.github/workflows/windows-build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
export PATH="/mingw64/bin:$PATH:/c/Program Files/Git/bin"
3030
export MSYSTEM=MINGW64
3131
autoreconf -i
32-
./configure
32+
./configure --enable-werror
3333
make cc-version
3434
make -j6
3535
- name: Check Htslib

hts.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ int hts_parse_opt_list(htsFormat *fmt, const char *str) {
13221322
* -1 on failure.
13231323
*/
13241324
int hts_parse_format(htsFormat *format, const char *str) {
1325-
char fmt[8];
1325+
char fmt[9];
13261326
const char *cp = scan_keyword(str, ',', fmt, sizeof fmt);
13271327

13281328
format->version.minor = 0; // unknown

test/test-bcf-sr.c

+1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ int main(int argc, char *argv[])
179179
break;
180180
case 'h':
181181
usage(EXIT_SUCCESS);
182+
// fall-through
182183
default: usage(EXIT_FAILURE);
183184
}
184185
}

0 commit comments

Comments
 (0)