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)
Mon, Nov 4, 4:15 AM
Unknown Object (File)
Mon, Nov 4, 4:15 AM
Unknown Object (File)
Sun, Oct 20, 3:15 PM
Unknown Object (File)
Sep 22 2024, 11:43 PM
Unknown Object (File)
Sep 18 2024, 2:26 AM
Unknown Object (File)
Sep 17 2024, 11:39 AM
Unknown Object (File)
Sep 15 2024, 12:52 PM
Unknown Object (File)
Sep 7 2024, 5:16 AM
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.