Skip to content

Commit

Permalink
Add HTS_FORMAT checks to a variety of places.
Browse files Browse the repository at this point in the history
These are needed in newer clangs with -Wformat=2.
  • Loading branch information
jkbonfield committed Aug 15, 2024
1 parent 43b4a66 commit 6afcb53
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion htsfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion htslib/vcf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/hfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/test-bcf-sr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/test-bcf-translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/test-bcf_set_variant_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/test-vcf-api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6afcb53

Please sign in to comment.