diff --git a/.cirrus.yml b/.cirrus.yml index 9d80ea07d..61f094c2b 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -113,7 +113,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 -g -Wall -O3 + CFLAGS: -std=c99 -pedantic -Wformat -Wformat=2 -g -Wall -O3 USE_LIBDEFLATE: yes # NB: we could consider building a docker image with these diff --git a/bgzip.c b/bgzip.c index d795c80a9..740aef117 100644 --- a/bgzip.c +++ b/bgzip.c @@ -48,7 +48,7 @@ static const int WINDOW_SIZE = BGZF_BLOCK_SIZE; -static void error(const char *format, ...) +static void HTS_FORMAT(HTS_PRINTF_FMT, 1, 2) error(const char *format, ...) { va_list ap; va_start(ap, format); @@ -689,7 +689,7 @@ int main(int argc, char **argv) if ( bgzf_index_load(fp, argv[optind], ".gzi") < 0 ) error("Could not load index: %s.gzi\n", argv[optind]); } - if ( bgzf_useek(fp, start, SEEK_SET) < 0 ) error("Could not seek to %d-th (uncompressd) byte\n", start); + if ( bgzf_useek(fp, start, SEEK_SET) < 0 ) error("Could not seek to %ld-th (uncompressd) byte\n", start); } if (threads > 1) diff --git a/htsfile.c b/htsfile.c index 9af4ae31b..25af3f584 100644 --- a/htsfile.c +++ b/htsfile.c @@ -46,7 +46,7 @@ int show_headers = 1; int verbose = 0; int status = EXIT_SUCCESS; /* Exit status from main */ -void error(const char *format, ...) +void HTS_FORMAT(HTS_PRINTF_FMT, 1, 2) error(const char *format, ...) { int err = errno; va_list args; diff --git a/htslib/vcf.h b/htslib/vcf.h index e60911ab5..9a36cab05 100644 --- a/htslib/vcf.h +++ b/htslib/vcf.h @@ -596,7 +596,8 @@ set to one of BCF_ERR* codes and must be checked before calling bcf_write(). int bcf_hdr_append(bcf_hdr_t *h, const char *line); HTSLIB_EXPORT - int bcf_hdr_printf(bcf_hdr_t *h, const char *format, ...); + int bcf_hdr_printf(bcf_hdr_t *h, const char *format, ...) + HTS_FORMAT(HTS_PRINTF_FMT, 2, 3); /** VCF version, e.g. VCFv4.2 */ HTSLIB_EXPORT diff --git a/test/hfile.c b/test/hfile.c index 8f06a971f..741cf7a8d 100644 --- a/test/hfile.c +++ b/test/hfile.c @@ -35,7 +35,8 @@ DEALINGS IN THE SOFTWARE. */ #include "../htslib/hts_defs.h" #include "../htslib/kstring.h" -void HTS_NORETURN fail(const char *format, ...) +void HTS_FORMAT(HTS_PRINTF_FMT, 1, 2) HTS_NORETURN +fail(const char *format, ...) { int err = errno; va_list args; diff --git a/test/test-bcf-sr.c b/test/test-bcf-sr.c index 80daf0423..b4943b5ef 100644 --- a/test/test-bcf-sr.c +++ b/test/test-bcf-sr.c @@ -40,7 +40,7 @@ #include "../htslib/hts.h" #include "../htslib/vcf.h" -void error(const char *format, ...) +void HTS_FORMAT(HTS_PRINTF_FMT, 1, 2) error(const char *format, ...) { va_list ap; va_start(ap, format); diff --git a/test/test-bcf-translate.c b/test/test-bcf-translate.c index c2f069e39..263e71eb8 100644 --- a/test/test-bcf-translate.c +++ b/test/test-bcf-translate.c @@ -29,7 +29,7 @@ #include "../htslib/vcf.h" -void error(const char *format, ...) +void HTS_FORMAT(HTS_PRINTF_FMT, 1, 2) error(const char *format, ...) { va_list ap; va_start(ap, format); diff --git a/test/test-bcf_set_variant_type.c b/test/test-bcf_set_variant_type.c index 3688609f6..eb12ecde3 100644 --- a/test/test-bcf_set_variant_type.c +++ b/test/test-bcf_set_variant_type.c @@ -29,7 +29,7 @@ DEALINGS IN THE SOFTWARE. */ #include "../htslib/hts.h" #include "../vcf.c" -void error(const char *format, ...) +void HTS_FORMAT(HTS_PRINTF_FMT, 1, 2) error(const char *format, ...) { va_list ap; va_start(ap, format); diff --git a/test/test-vcf-api.c b/test/test-vcf-api.c index ff16fa194..b86b71d99 100644 --- a/test/test-vcf-api.c +++ b/test/test-vcf-api.c @@ -33,7 +33,7 @@ DEALINGS IN THE SOFTWARE. */ #include "../htslib/kstring.h" #include "../htslib/kseq.h" -void error(const char *format, ...) +void HTS_FORMAT(HTS_PRINTF_FMT, 1, 2) error(const char *format, ...) { va_list ap; va_start(ap, format);