Page MenuHomeFreeBSD

ntp: disable format string warnings in libopts
ClosedPublic

Authored by emaste on Feb 27 2022, 7:25 PM.
Tags
None
Referenced Files
Unknown Object (File)
Apr 10 2024, 6:53 AM
Unknown Object (File)
Mar 12 2024, 6:24 PM
Unknown Object (File)
Mar 12 2024, 6:24 PM
Unknown Object (File)
Mar 12 2024, 6:24 PM
Unknown Object (File)
Mar 12 2024, 2:01 AM
Unknown Object (File)
Mar 12 2024, 1:51 AM
Unknown Object (File)
Feb 5 2024, 11:34 PM
Unknown Object (File)
Jan 1 2024, 12:58 PM
Subscribers

Details

Summary

libopts uses generated format string tables that contain embedded NULs.

example error contrib/ntp/sntp/libopts/enum.c:112:38: warning: format string contains '\0' within the string body [-Wformat]
comes from

/*  -*- buffer-read-only: t -*- vi: set ro:
 *
 * DO NOT EDIT THIS FILE   (ao-strs.h)
 *
 * It has been AutoGen-ed
 * From the definitions    ao-strs.def
 * and the template file   strings
...
/*
 * 142 strings in ao_strs_strtable string table
 */
#define ARG_BREAK_STR         (ao_strs_strtable+261)
#define ARG_BREAK_STR_LEN     5
#define ARG_BY_NUM_FMT        (ao_strs_strtable+267)
#define ARG_BY_NUM_FMT_LEN    9
#define BOOL_ATR_FMT          (ao_strs_strtable+876)
#define BOOL_ATR_FMT_LEN      31
#define CHK_MAX_COUNT         (ao_strs_strtable+1427)
#define CHK_MAX_COUNT_LEN     190
...

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

emaste added subscribers: dim, scottl.

There's NO_WFORMAT for this particular purpose, in share/mk/bsd.sys.mk:

.if defined(NO_WFORMAT) || defined(NO_WFORMAT.${COMPILER_TYPE})
CWARNFLAGS+=    -Wno-format
.endif # NO_WFORMAT || NO_WFORMAT.${COMPILER_TYPE}

E.g. just adding a line:

NO_WFORMAT=

should do the trick!

Use NO_WFORMAT as suggested by @dim

This revision was not accepted when it landed; it landed in state Needs Review.Feb 27 2022, 9:31 PM
This revision was automatically updated to reflect the committed changes.