Skip to content

Commit

Permalink
Fix more warnings and adjust Cirrus CI rules
Browse files Browse the repository at this point in the history
Change hts_close() to hts_close_abruptly() in bgzip, to fix an
empty body warning, allowing removal of -Wno-empty-body in CI
tests.

Fix signed compare in htslib/bgzf.h, which caused a warning in
the maintainer-check usepublic.cpp check.  It appears that -Wall
does not allow signed-compare in c++.

Make CFLAGS settings more consistent in .cirrus.yml, and ensure
$MAKE_OPTS is consistently applied in all make invocations.  The
latter is necessary because "make cc-version" and
"make maintainer-check" can trigger production of some .mk files,
and we want them to be made in the same way as if we ran the full
build.
  • Loading branch information
daviesrob committed Aug 23, 2024
1 parent 69f2de7 commit 47a6e7f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
21 changes: 11 additions & 10 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ compile_template: &COMPILE
if test "$USE_CONFIG" = "yes"; then
MAKE_OPTS=
autoreconf -i
eval ./configure --enable-plugins --enable-werror $CONFIG_OPTS CFLAGS=\"-g -O3 $CFLAGS\" || \
eval ./configure --enable-plugins --enable-werror $CONFIG_OPTS CFLAGS=\"$CFLAGS\" || \
( cat config.log; false )
else
MAKE_OPTS=-e
fi
make cc-version
make cc-version $MAKE_OPTS
if test "x$DO_MAINTAINER_CHECKS" = "xyes"; then
make maintainer-check
make maintainer-check $MAKE_OPTS
fi
make -j 4 $MAKE_OPTS
test_template: &TEST
test_script: |
make test-shlib-exports
make test
if test "x$DO_UNTRACKED_FILE_CHECK" = "xyes"; then make check-untracked ; fi
make test-shlib-exports $MAKE_OPTS
make test $MAKE_OPTS
if test "x$DO_UNTRACKED_FILE_CHECK" = "xyes"; then make check-untracked $MAKE_OPTS ; fi
#--------------------------------------------------
# Task: linux builds.
Expand All @@ -76,7 +76,7 @@ gcc_task:
- environment:
USE_CONFIG: yes
# ubsan is incompatible with some -Wformat opts so we do that on clang.
CFLAGS: -fsanitize=address,undefined -DHTS_ALLOW_UNALIGNED=0 -Wno-format-truncation -Wno-format-overflow
CFLAGS: -g -O3 -fsanitize=address,undefined -DHTS_ALLOW_UNALIGNED=0 -Wno-format-truncation -Wno-format-overflow
LDFLAGS: -fsanitize=address,undefined
USE_LIBDEFLATE: yes
UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1
Expand Down Expand Up @@ -114,7 +114,7 @@ ubuntu_task:
- environment:
# Cirrus-CI's clang isn't installed with ubsan, so we do that in gcc
USE_CONFIG: yes
CFLAGS: -std=c99 -pedantic -Wformat -Wformat=2 -g -Wall -O3
CFLAGS: -g -O3 -std=c99 -pedantic -Wall -Wformat -Wformat=2
USE_LIBDEFLATE: yes

# NB: we could consider building a docker image with these
Expand Down Expand Up @@ -142,7 +142,7 @@ rocky_task:
LC_ALL: C
CIRRUS_CLONE_DEPTH: 1
USE_CONFIG: yes
CFLAGS: -g -O3 -std=gnu90 -Wformat -Wformat=2 -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-empty-body
CFLAGS: -g -O3 -std=gnu90 -Wall -Wformat -Wformat=2 -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers

# NB: we could consider building a docker image with these
# preinstalled and specifying that instead, to speed up testing.
Expand Down Expand Up @@ -191,7 +191,6 @@ macosx_task:

environment:
CC: clang
CFLAGS: "-Wall -arch arm64 -arch x86_64"
LDFLAGS: "-arch arm64 -arch x86_64"
LIBDEFLATE_CFLAGS: "-arch arm64 -arch x86_64"
LC_ALL: C
Expand All @@ -200,9 +199,11 @@ macosx_task:
matrix:
- environment:
USE_CONFIG: no
CFLAGS: "-g -O3 -Wall -Werror -arch arm64 -arch x86_64"
- environment:
USE_CONFIG: yes
USE_LIBDEFLATE: yes
CFLAGS: "-g -O3 -Wall -arch arm64 -arch x86_64"

package_install_script: |
HOMEBREW_NO_AUTO_UPDATE=1 brew install autoconf automake libtool xz git \
Expand Down
3 changes: 1 addition & 2 deletions bgzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,7 @@ int main(int argc, char **argv)
}
else {
ret = 2; //explicit N - no overwrite, continue and return 2
if (hclose(f_src) < 0)
; //ignoring return value
hclose_abruptly(f_src);
free(name);
continue;
}
Expand Down
3 changes: 2 additions & 1 deletion htslib/bgzf.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ static inline ssize_t bgzf_read_small(BGZF *fp, void *data, size_t length) {
*/
static inline
ssize_t bgzf_write_small(BGZF *fp, const void *data, size_t length) {
if (fp->is_compressed && BGZF_BLOCK_SIZE - fp->block_offset > length) {
if (fp->is_compressed
&& (size_t) (BGZF_BLOCK_SIZE - fp->block_offset) > length) {
// Short cut the common and easy mode
memcpy((uint8_t *)fp->uncompressed_block + fp->block_offset,
data, length);
Expand Down

0 comments on commit 47a6e7f

Please sign in to comment.