diff --git a/.github/workflows/cross-bootstrap-tools.yml b/.github/workflows/cross-bootstrap-tools.yml index 8f0dd933ef09fb..929811db2c4e2d 100644 --- a/.github/workflows/cross-bootstrap-tools.yml +++ b/.github/workflows/cross-bootstrap-tools.yml @@ -26,13 +26,13 @@ jobs: cross-bindir: /usr/lib/llvm-14/bin pkgs: bmake libarchive-dev clang-14 lld-14 - os: ubuntu-24.04 - compiler: clang-18 - cross-bindir: /usr/lib/llvm-18/bin - pkgs: bmake libarchive-dev clang-18 lld-18 + compiler: clang-20 + cross-bindir: /usr/lib/llvm-20/bin + pkgs: bmake libarchive-dev clang-20 lld-20 - os: macos-latest - compiler: clang-18 - cross-toolchain: llvm@18 - pkgs: bmake libarchive llvm@18 + compiler: clang-21 + cross-toolchain: llvm@21 + pkgs: bmake libarchive llvm@21 lld@21 - target_arch: amd64 target: amd64 - target_arch: aarch64 diff --git a/bin/sh/options.h b/bin/sh/options.h index a059e19707b197..2ce2e6ebedf277 100644 --- a/bin/sh/options.h +++ b/bin/sh/options.h @@ -74,7 +74,7 @@ extern char optval[NOPTS]; extern const char optletter[NSHORTOPTS]; #ifdef DEFINE_OPTIONS char optval[NOPTS]; -const char optletter[NSHORTOPTS] = "efIimnsxvVECabupTPh"; +const char optletter[NSHORTOPTS] __nonstring = "efIimnsxvVECabupTPh"; static const unsigned char optname[] = "\007errexit" "\006noglob" diff --git a/bin/test/test.c b/bin/test/test.c index a35c5b424d3f98..5ba5df5d7e443d 100644 --- a/bin/test/test.c +++ b/bin/test/test.c @@ -116,7 +116,7 @@ enum token { #define TOKEN_TYPE(token) ((token) & 0xff00) static const struct t_op { - char op_text[2]; + char op_text[2] __nonstring; short op_num; } ops1[] = { {"=", STREQ}, diff --git a/contrib/bmake/var.c b/contrib/bmake/var.c index 66b18f7693710d..6ef525801ada7c 100644 --- a/contrib/bmake/var.c +++ b/contrib/bmake/var.c @@ -1866,7 +1866,13 @@ QuoteShell(const char *str, bool quoteDollar, LazyBuf *buf) static char * Hash(const char *str) { - static const char hexdigits[16] = "0123456789abcdef"; + /* + * Temporary FreeBSD diff: Disable -Wunterminated-string-initialization + * warning by adding 1 to size. We can't use __nonstring unconditionally + * in bmake since the bmake bootstrap headers don't define it. + * TODO: add the __nonstring attribute and change size back to 16. + */ + static const char hexdigits[16 + 1] = "0123456789abcdef"; const unsigned char *ustr = (const unsigned char *)str; uint32_t h = 0x971e137bU; diff --git a/contrib/ncurses/progs/infocmp.c b/contrib/ncurses/progs/infocmp.c index 7932203ac2b1aa..f61633cfad8047 100644 --- a/contrib/ncurses/progs/infocmp.c +++ b/contrib/ncurses/progs/infocmp.c @@ -687,7 +687,7 @@ compare_predicate(PredType type, PredIdx idx, const char *name) #define DATAX() DATA("", "") typedef struct { - const char from[4]; + const char from[8]; const char to[12]; } assoc; diff --git a/krb5/include/autoconf.h b/krb5/include/autoconf.h index ed0bf8cacc1438..76a0d548244c69 100644 --- a/krb5/include/autoconf.h +++ b/krb5/include/autoconf.h @@ -691,7 +691,18 @@ #define STDC_HEADERS 1 /* Define to 1 if strerror_r returns char *. */ +/* + * glibc defines two versions of strerror_r, the char* returning one is used + * when _GNU_SOURCE is defined. + */ +#if defined(__linux__) && __has_include() +#include /* get __GLIBC__ */ +#endif +#if defined(__GLIBC__) && defined(__USE_GNU) +#define STRERROR_R_CHAR_P 1 +#else /* #undef STRERROR_R_CHAR_P */ +#endif /* Define if sys_errlist is defined in errno.h */ #define SYS_ERRLIST_DECLARED 1 diff --git a/lib/libcuse/cuse_lib.c b/lib/libcuse/cuse_lib.c index 3f040d0eeeda75..ba66c0a28f8929 100644 --- a/lib/libcuse/cuse_lib.c +++ b/lib/libcuse/cuse_lib.c @@ -92,7 +92,7 @@ static struct cuse_vm_allocation a_cuse[CUSE_ALLOC_UNIT_MAX] #define CUSE_UNLOCK() \ pthread_mutex_unlock(&m_cuse) -int +int __no_lock_analysis /* No need for locking during init */ cuse_init(void) { pthread_mutexattr_t attr; diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c index 786d5647d99350..2e1364edff04de 100644 --- a/lib/libfetch/common.c +++ b/lib/libfetch/common.c @@ -135,7 +135,7 @@ static struct fetcherr socks5_errlist[] = { }; /* End-of-Line */ -static const char ENDL[2] = "\r\n"; +static const char ENDL[2] = { '\r', '\n' }; /*** Error-reporting functions ***********************************************/ diff --git a/lib/libsysdecode/utrace.c b/lib/libsysdecode/utrace.c index 67ba86bfbf7b92..8932f4b7e58fd0 100644 --- a/lib/libsysdecode/utrace.c +++ b/lib/libsysdecode/utrace.c @@ -169,7 +169,8 @@ sysdecode_utrace(FILE *fp, void *p, size_t len) struct utrace_malloc um; struct utrace_malloc32 *pm; #endif - static const char rtld_utrace_sig[RTLD_UTRACE_SIG_SZ] = RTLD_UTRACE_SIG; + static const char rtld_utrace_sig[RTLD_UTRACE_SIG_SZ] __nonstring = + RTLD_UTRACE_SIG; if (len == sizeof(struct utrace_rtld) && bcmp(p, rtld_utrace_sig, sizeof(rtld_utrace_sig)) == 0) diff --git a/lib/libthr/thread/thr_printf.c b/lib/libthr/thread/thr_printf.c index e1edffe5acb2d4..b7cb6ce81bda13 100644 --- a/lib/libthr/thread/thr_printf.c +++ b/lib/libthr/thread/thr_printf.c @@ -61,7 +61,7 @@ _thread_printf(int fd, const char *fmt, ...) void _thread_vprintf(int fd, const char *fmt, va_list ap) { - static const char digits[16] = "0123456789abcdef"; + static const char digits[16] __nonstring = "0123456789abcdef"; char buf[20]; char *s; unsigned long r, u; @@ -147,4 +147,3 @@ pstr(int fd, const char *s) __sys_write(fd, s, strlen(s)); } - diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index d27af520c21d1d..226835d4faa685 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -348,7 +348,8 @@ ld_utrace_log(int event, void *handle, void *mapbase, size_t mapsize, int refcnt, const char *name) { struct utrace_rtld ut; - static const char rtld_utrace_sig[RTLD_UTRACE_SIG_SZ] = RTLD_UTRACE_SIG; + static const char rtld_utrace_sig[RTLD_UTRACE_SIG_SZ] __nonstring = + RTLD_UTRACE_SIG; memset(&ut, 0, sizeof(ut)); /* clear holes */ memcpy(ut.sig, rtld_utrace_sig, sizeof(ut.sig)); diff --git a/libexec/rtld-elf/rtld_utrace.h b/libexec/rtld-elf/rtld_utrace.h index c14a62ddcb0ba6..dee807cc00980c 100644 --- a/libexec/rtld-elf/rtld_utrace.h +++ b/libexec/rtld-elf/rtld_utrace.h @@ -49,7 +49,7 @@ #define RTLD_UTRACE_SIG "RTLD" struct utrace_rtld { - char sig[RTLD_UTRACE_SIG_SZ]; + char sig[RTLD_UTRACE_SIG_SZ] __nonstring; int event; void *handle; void *mapbase; /* Used for 'parent' and 'init/fini' */ diff --git a/sbin/fsck_msdosfs/dir.c b/sbin/fsck_msdosfs/dir.c index 19516d882e2a13..2d7e4bcdc38ffa 100644 --- a/sbin/fsck_msdosfs/dir.c +++ b/sbin/fsck_msdosfs/dir.c @@ -463,8 +463,8 @@ checksize(struct fat_descriptor *fat, u_char *p, struct dosDirEntry *dir) return FSOK; } -static const u_char dot_name[11] = ". "; -static const u_char dotdot_name[11] = ".. "; +static const u_char dot_name[11] __nonstring = ". "; +static const u_char dotdot_name[11] __nonstring = ".. "; /* * Basic sanity check if the subdirectory have good '.' and '..' entries, diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index 2134886abcf501..09dbbe645489fe 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -93,6 +93,10 @@ CWARNFLAGS.clang+= -Wno-error=unused-but-set-parameter # Similar to gcc >= 8.1 -Wno-error=cast-function-type below CWARNFLAGS.clang+= -Wno-error=cast-function-type-mismatch .endif +.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 210000 +# Until gtest is updated: https://github.com/google/googletest/issues/4762 +CXXWARNFLAGS.clang+= -Wno-error=character-conversion +.endif .endif # WARNS <= 6 .if ${WARNS} <= 3 CWARNFLAGS.clang+= -Wno-tautological-compare -Wno-unused-value\ diff --git a/sys/compat/linux/linux_timer.c b/sys/compat/linux/linux_timer.c index ed9133359302ce..e9eb9cc99f9ab5 100644 --- a/sys/compat/linux/linux_timer.c +++ b/sys/compat/linux/linux_timer.c @@ -131,7 +131,7 @@ linux_timer_settime(struct thread *td, struct linux_timer_settime_args *uap) return (error); error = kern_ktimer_settime(td, uap->timerid, flags, &val, ovalp); if (error == 0 && uap->old != NULL) { - error = native_to_linux_itimerspec(&l_val, &val); + error = native_to_linux_itimerspec(&l_oval, &val); if (error == 0) error = copyout(&l_oval, uap->old, sizeof(l_oval)); } @@ -158,7 +158,7 @@ linux_timer_settime64(struct thread *td, struct linux_timer_settime64_args *uap) return (error); error = kern_ktimer_settime(td, uap->timerid, flags, &val, ovalp); if (error == 0 && uap->old != NULL) { - error = native_to_linux_itimerspec64(&l_val, &val); + error = native_to_linux_itimerspec64(&l_oval, &val); if (error == 0) error = copyout(&l_oval, uap->old, sizeof(l_oval)); } diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/cmn_err.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/cmn_err.h index 93dd1196d977ca..fa55b391766915 100644 --- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/cmn_err.h +++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/cmn_err.h @@ -52,28 +52,28 @@ extern "C" { #ifndef _ASM extern void cmn_err(int, const char *, ...) - __attribute__((format(printf, 2, 3))); + __attribute__((format(__printf__, 2, 3))); extern void vzcmn_err(zoneid_t, int, const char *, __va_list) - __attribute__((format(printf, 3, 0))); + __attribute__((format(__printf__, 3, 0))); extern void vcmn_err(int, const char *, __va_list) - __attribute__((format(printf, 2, 0))); + __attribute__((format(__printf__, 2, 0))); extern void zcmn_err(zoneid_t, int, const char *, ...) - __attribute__((format(printf, 3, 4))); + __attribute__((format(__printf__, 3, 4))); extern void vzprintf(zoneid_t, const char *, __va_list) - __attribute__((format(printf, 2, 0))); + __attribute__((format(__printf__, 2, 0))); extern void zprintf(zoneid_t, const char *, ...) - __attribute__((format(printf, 2, 3))); + __attribute__((format(__printf__, 2, 3))); extern void vuprintf(const char *, __va_list) - __attribute__((format(printf, 1, 0))); + __attribute__((format(__printf__, 1, 0))); extern void panic(const char *, ...) - __attribute__((format(printf, 1, 2), __noreturn__)); + __attribute__((format(__printf__, 1, 2), __noreturn__)); #define cmn_err_once(ce, ...) \ do { \ diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/kmem.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/kmem.h index a9619d7d021900..4ae96c91a5f3e6 100644 --- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/kmem.h +++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/kmem.h @@ -55,9 +55,9 @@ MALLOC_DECLARE(M_SOLARIS); typedef struct vmem vmem_t; extern char *kmem_asprintf(const char *, ...) - __attribute__((format(printf, 1, 2))); + __attribute__((format(__printf__, 1, 2))); extern char *kmem_vasprintf(const char *fmt, va_list ap) - __attribute__((format(printf, 1, 0))); + __attribute__((format(__printf__, 1, 0))); extern int kmem_scnprintf(char *restrict str, size_t size, const char *restrict fmt, ...); diff --git a/sys/contrib/openzfs/include/sys/spa.h b/sys/contrib/openzfs/include/sys/spa.h index 66db16b33c51de..22f6ddc1a9d53b 100644 --- a/sys/contrib/openzfs/include/sys/spa.h +++ b/sys/contrib/openzfs/include/sys/spa.h @@ -1122,9 +1122,9 @@ extern void spa_set_allocator(spa_t *spa, const char *allocator); /* Miscellaneous support routines */ extern void spa_load_failed(spa_t *spa, const char *fmt, ...) - __attribute__((format(printf, 2, 3))); + __attribute__((format(__printf__, 2, 3))); extern void spa_load_note(spa_t *spa, const char *fmt, ...) - __attribute__((format(printf, 2, 3))); + __attribute__((format(__printf__, 2, 3))); extern void spa_activate_mos_feature(spa_t *spa, const char *feature, dmu_tx_t *tx); extern void spa_deactivate_mos_feature(spa_t *spa, const char *feature); diff --git a/sys/contrib/openzfs/include/sys/vdev.h b/sys/contrib/openzfs/include/sys/vdev.h index 510474d6c085e0..86f2235f03aca8 100644 --- a/sys/contrib/openzfs/include/sys/vdev.h +++ b/sys/contrib/openzfs/include/sys/vdev.h @@ -54,7 +54,7 @@ extern int zfs_nocacheflush; typedef boolean_t vdev_open_children_func_t(vdev_t *vd); extern void vdev_dbgmsg(vdev_t *vd, const char *fmt, ...) - __attribute__((format(printf, 2, 3))); + __attribute__((format(__printf__, 2, 3))); extern void vdev_dbgmsg_print_tree(vdev_t *, int); extern int vdev_open(vdev_t *); extern void vdev_open_children(vdev_t *); diff --git a/sys/contrib/openzfs/include/sys/zfs_debug.h b/sys/contrib/openzfs/include/sys/zfs_debug.h index 4d4cd4c39e9776..87fafec0c9e71f 100644 --- a/sys/contrib/openzfs/include/sys/zfs_debug.h +++ b/sys/contrib/openzfs/include/sys/zfs_debug.h @@ -67,7 +67,7 @@ extern int zfs_dbgmsg_enable; extern void __set_error(const char *file, const char *func, int line, int err); extern void __zfs_dbgmsg(char *buf); extern void __dprintf(boolean_t dprint, const char *file, const char *func, - int line, const char *fmt, ...) __attribute__((format(printf, 5, 6))); + int line, const char *fmt, ...) __attribute__((format(__printf__, 5, 6))); /* * Some general principles for using zfs_dbgmsg(): diff --git a/sys/crypto/chacha20/chacha.c b/sys/crypto/chacha20/chacha.c index 52f7e18c651cee..b5f51bd10cc98e 100644 --- a/sys/crypto/chacha20/chacha.c +++ b/sys/crypto/chacha20/chacha.c @@ -50,8 +50,8 @@ typedef struct chacha_ctx chacha_ctx; a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \ c = PLUS(c,d); b = ROTATE(XOR(b,c), 7); -static const char sigma[16] = "expand 32-byte k"; -static const char tau[16] = "expand 16-byte k"; +static const char sigma[16] __nonstring = "expand 32-byte k"; +static const char tau[16] __nonstring = "expand 16-byte k"; LOCAL void chacha_keysetup(chacha_ctx *x,const u8 *k,u32 kbits) diff --git a/sys/dev/netmap/netmap_kloop.c b/sys/dev/netmap/netmap_kloop.c index ba9e67076e72d1..ac3ca2d8d21f50 100644 --- a/sys/dev/netmap/netmap_kloop.c +++ b/sys/dev/netmap/netmap_kloop.c @@ -161,7 +161,8 @@ netmap_sync_kloop_tx_ring(const struct sync_kloop_ring_args *a) struct netmap_kring *kring = a->kring; struct nm_csb_atok *csb_atok = a->csb_atok; struct nm_csb_ktoa *csb_ktoa = a->csb_ktoa; - struct netmap_ring shadow_ring; /* shadow copy of the netmap_ring */ + /* shadow copy of the netmap_ring */ + struct netmap_ring shadow_ring = {0}; #ifdef SYNC_KLOOP_POLL bool more_txspace = false; #endif /* SYNC_KLOOP_POLL */ @@ -317,7 +318,8 @@ netmap_sync_kloop_rx_ring(const struct sync_kloop_ring_args *a) struct netmap_kring *kring = a->kring; struct nm_csb_atok *csb_atok = a->csb_atok; struct nm_csb_ktoa *csb_ktoa = a->csb_ktoa; - struct netmap_ring shadow_ring; /* shadow copy of the netmap_ring */ + /* shadow copy of the netmap_ring */ + struct netmap_ring shadow_ring = {0}; int dry_cycles = 0; #ifdef SYNC_KLOOP_POLL bool some_recvd = false; diff --git a/sys/dev/ocs_fc/ocs_ddump.h b/sys/dev/ocs_fc/ocs_ddump.h index b7d7eefad8136c..3cffff6d9670c9 100644 --- a/sys/dev/ocs_fc/ocs_ddump.h +++ b/sys/dev/ocs_fc/ocs_ddump.h @@ -46,8 +46,7 @@ extern void ocs_ddump_startfile(ocs_textbuf_t *textbuf); extern void ocs_ddump_endfile(ocs_textbuf_t *textbuf); extern void ocs_ddump_section(ocs_textbuf_t *textbuf, const char *name, uint32_t instance); extern void ocs_ddump_endsection(ocs_textbuf_t *textbuf, const char *name, uint32_t instance); -__attribute__((format(printf,3,4))) -extern void ocs_ddump_value(ocs_textbuf_t *textbuf, const char *name, const char *fmt, ...); +extern void ocs_ddump_value(ocs_textbuf_t *textbuf, const char *name, const char *fmt, ...) __printflike(3, 4); extern void ocs_ddump_buffer(ocs_textbuf_t *textbuf, const char *name, uint32_t instance, void *buffer, uint32_t size); extern int32_t ocs_save_ddump(ocs_t *ocs, uint32_t flags, uint32_t qentries); extern int32_t ocs_get_saved_ddump(ocs_t *ocs, ocs_textbuf_t *textbuf); diff --git a/sys/dev/ocs_fc/ocs_mgmt.h b/sys/dev/ocs_fc/ocs_mgmt.h index 7b59a3916ca85e..9781aec18462e7 100644 --- a/sys/dev/ocs_fc/ocs_mgmt.h +++ b/sys/dev/ocs_fc/ocs_mgmt.h @@ -95,8 +95,7 @@ extern void ocs_mgmt_end_section(ocs_textbuf_t *textbuf, const char *name, int i extern void ocs_mgmt_end_unnumbered_section(ocs_textbuf_t *textbuf, const char *name); extern void ocs_mgmt_emit_property_name(ocs_textbuf_t *textbuf, int access, const char *name); extern void ocs_mgmt_emit_string(ocs_textbuf_t *textbuf, int access, const char *name, const char *value); -__attribute__((format(printf,4,5))) -extern void ocs_mgmt_emit_int(ocs_textbuf_t *textbuf, int access, const char *name, const char *fmt, ...); +extern void ocs_mgmt_emit_int(ocs_textbuf_t *textbuf, int access, const char *name, const char *fmt, ...) __printflike(4, 5); extern void ocs_mgmt_emit_boolean(ocs_textbuf_t *textbuf, int access, const char *name, const int value); extern int parse_wwn(char *wwn_in, uint64_t *wwn_out); diff --git a/sys/dev/ocs_fc/ocs_os.h b/sys/dev/ocs_fc/ocs_os.h index 331d5b07aecde5..55ee98b3cc58ee 100644 --- a/sys/dev/ocs_fc/ocs_os.h +++ b/sys/dev/ocs_fc/ocs_os.h @@ -711,7 +711,7 @@ typedef struct { * @return returns 0 for success, a negative error code value for failure. */ -extern int ocs_sem_init(ocs_sem_t *sem, int val, const char *name, ...) __attribute__((format(printf, 3, 4))); +extern int ocs_sem_init(ocs_sem_t *sem, int val, const char *name, ...) __printflike(3, 4); /** * @brief execute a P (decrement) operation diff --git a/sys/dev/ocs_fc/ocs_utils.h b/sys/dev/ocs_fc/ocs_utils.h index e3a952e0cf265d..7c9c9ae85b742e 100644 --- a/sys/dev/ocs_fc/ocs_utils.h +++ b/sys/dev/ocs_fc/ocs_utils.h @@ -103,10 +103,8 @@ extern int32_t ocs_textbuf_init(ocs_t *ocs, ocs_textbuf_t *textbuf, void *buffer extern void ocs_textbuf_free(ocs_t *ocs, ocs_textbuf_t *textbuf); extern void ocs_textbuf_putc(ocs_textbuf_t *textbuf, uint8_t c); extern void ocs_textbuf_puts(ocs_textbuf_t *textbuf, char *s); -__attribute__((format(printf,2,3))) -extern void ocs_textbuf_printf(ocs_textbuf_t *textbuf, const char *fmt, ...); -__attribute__((format(printf,2,0))) -extern void ocs_textbuf_vprintf(ocs_textbuf_t *textbuf, const char *fmt, va_list ap); +extern void ocs_textbuf_printf(ocs_textbuf_t *textbuf, const char *fmt, ...) __printflike(2, 3); +extern void ocs_textbuf_vprintf(ocs_textbuf_t *textbuf, const char *fmt, va_list ap) __printflike(2, 0); extern void ocs_textbuf_buffer(ocs_textbuf_t *textbuf, uint8_t *buffer, uint32_t buffer_length); extern void ocs_textbuf_copy(ocs_textbuf_t *textbuf, uint8_t *buffer, uint32_t buffer_length); extern int32_t ocs_textbuf_remaining(ocs_textbuf_t *textbuf); @@ -325,10 +323,8 @@ typedef struct ocs_ramlog_s ocs_ramlog_t; extern ocs_ramlog_t *ocs_ramlog_init(ocs_t *ocs, uint32_t buffer_len, uint32_t buffer_count); extern void ocs_ramlog_free(ocs_t *ocs, ocs_ramlog_t *ramlog); extern void ocs_ramlog_clear(ocs_t *ocs, ocs_ramlog_t *ramlog, int clear_start_of_day, int clear_recent); -__attribute__((format(printf,2,3))) -extern int32_t ocs_ramlog_printf(void *os, const char *fmt, ...); -__attribute__((format(printf,2,0))) -extern int32_t ocs_ramlog_vprintf(ocs_ramlog_t *ramlog, const char *fmt, va_list ap); +extern int32_t ocs_ramlog_printf(void *os, const char *fmt, ...) __printflike(2, 3); +extern int32_t ocs_ramlog_vprintf(ocs_ramlog_t *ramlog, const char *fmt, va_list ap) __printflike(2, 0); extern int32_t ocs_ddump_ramlog(ocs_textbuf_t *textbuf, ocs_ramlog_t *ramlog); #endif diff --git a/sys/dev/xen/blkback/blkback.c b/sys/dev/xen/blkback/blkback.c index c6cba729b991f9..dcfdcafa9351bd 100644 --- a/sys/dev/xen/blkback/blkback.c +++ b/sys/dev/xen/blkback/blkback.c @@ -152,7 +152,7 @@ struct xbb_softc; struct xbb_xen_req; static void xbb_attach_failed(struct xbb_softc *xbb, int err, const char *fmt, - ...) __attribute__((format(printf, 3, 4))); + ...) __printflike(3, 4); static int xbb_shutdown(struct xbb_softc *xbb); /*------------------------------ Data Structures -----------------------------*/ diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 1bc2491a1a120b..de4599fb07acb8 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -2712,12 +2712,15 @@ __elfN(note_procstat_auxv)(void *arg, struct sbuf *sb, size_t *sizep) struct proc *p; size_t size; int structsize; - +#if defined(COMPAT_FREEBSD32) && __ELF_WORD_SIZE == 32 + structsize = sizeof(Elf32_Auxinfo); +#else + structsize = sizeof(Elf_Auxinfo); +#endif p = arg; if (sb == NULL) { size = 0; - sb = sbuf_new(NULL, NULL, AT_COUNT * sizeof(Elf_Auxinfo), - SBUF_FIXEDLEN); + sb = sbuf_new(NULL, NULL, AT_COUNT * structsize, SBUF_FIXEDLEN); sbuf_set_drain(sb, sbuf_count_drain, &size); sbuf_bcat(sb, &structsize, sizeof(structsize)); PHOLD(p); @@ -2727,7 +2730,6 @@ __elfN(note_procstat_auxv)(void *arg, struct sbuf *sb, size_t *sizep) sbuf_delete(sb); *sizep = size; } else { - structsize = sizeof(Elf_Auxinfo); sbuf_bcat(sb, &structsize, sizeof(structsize)); PHOLD(p); proc_getauxv(curthread, p, sb); diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h index 3bc4389346d295..ea6a92ad005679 100644 --- a/sys/sys/cdefs.h +++ b/sys/sys/cdefs.h @@ -394,6 +394,13 @@ #define __printf0like(fmtarg, firstvararg) #endif +/* To silence warnings about null terminator not fitting into an array. */ +#if __has_attribute(__nonstring__) +#define __nonstring __attribute__((__nonstring__)) +#else +#define __nonstring +#endif + #define __strong_reference(sym,aliassym) \ extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym))) #ifdef __STDC__ diff --git a/sys/sys/font.h b/sys/sys/font.h index fb5fbbc9e55768..d486dbc3a011fc 100644 --- a/sys/sys/font.h +++ b/sys/sys/font.h @@ -108,7 +108,7 @@ typedef STAILQ_HEAD(font_list, fontlist) font_list_t; #define FONT_HEADER_MAGIC "VFNT0002" struct font_header { - uint8_t fh_magic[8]; + uint8_t fh_magic[8] __nonstring; uint8_t fh_width; uint8_t fh_height; uint16_t fh_pad; diff --git a/sys/sys/priority.h b/sys/sys/priority.h index 93dd5aa90d9511..3a3537bee1b25d 100644 --- a/sys/sys/priority.h +++ b/sys/sys/priority.h @@ -136,10 +136,10 @@ #endif struct priority { - u_char pri_class; /* Scheduling class. */ - u_char pri_level; /* Normal priority level. */ - u_char pri_native; /* Priority before propagation. */ - u_char pri_user; /* User priority based on p_cpu and p_nice. */ + unsigned char pri_class; /* Scheduling class. */ + unsigned char pri_level; /* Normal priority level. */ + unsigned char pri_native; /* Priority before propagation. */ + unsigned char pri_user; /* User priority based on p_cpu and p_nice. */ }; #endif /* !_SYS_PRIORITY_H_ */ diff --git a/sys/sys/rtprio.h b/sys/sys/rtprio.h index 6e0d8c7b0fe742..d6968a9e58a4e0 100644 --- a/sys/sys/rtprio.h +++ b/sys/sys/rtprio.h @@ -34,6 +34,7 @@ #ifndef _SYS_RTPRIO_H_ #define _SYS_RTPRIO_H_ +#include #include /* @@ -71,8 +72,8 @@ * Scheduling class information. */ struct rtprio { - u_short type; /* scheduling class */ - u_short prio; + unsigned short type; /* scheduling class */ + unsigned short prio; }; #ifdef _KERNEL @@ -86,8 +87,8 @@ void pri_to_rtp(struct thread *, struct rtprio *); #include __BEGIN_DECLS -int rtprio(int, pid_t, struct rtprio *); -int rtprio_thread(int, lwpid_t, struct rtprio *); +int rtprio(int, __pid_t, struct rtprio *); +int rtprio_thread(int, __lwpid_t, struct rtprio *); __END_DECLS #endif /* !_KERNEL */ #endif /* !_SYS_RTPRIO_H_ */ diff --git a/sys/xen/xen_intr.h b/sys/xen/xen_intr.h index 75c3dc7c60600a..4965928cc8b427 100644 --- a/sys/xen/xen_intr.h +++ b/sys/xen/xen_intr.h @@ -182,7 +182,7 @@ void xen_intr_unbind(xen_intr_handle_t *handle); */ int xen_intr_describe(xen_intr_handle_t port_handle, const char *fmt, ...) - __attribute__((format(printf, 2, 3))); + __printflike(2, 3); /** * Signal the remote peer of an interrupt source associated with an diff --git a/sys/xen/xenbus/xenbusvar.h b/sys/xen/xenbus/xenbusvar.h index ee444c132c0c26..0f4168f17e6a92 100644 --- a/sys/xen/xenbus/xenbusvar.h +++ b/sys/xen/xenbus/xenbusvar.h @@ -151,7 +151,7 @@ int xenbus_grant_ring(device_t dev, unsigned long ring_mfn, grant_ref_t *refp); * printf arguments. */ void xenbus_dev_error(device_t dev, int err, const char *fmt, ...) - __attribute__((format(printf, 3, 4))); + __printflike(3, 4); /** * va_list version of xenbus_dev_error(). @@ -162,7 +162,7 @@ void xenbus_dev_error(device_t dev, int err, const char *fmt, ...) * \param ap Va_list of printf arguments. */ void xenbus_dev_verror(device_t dev, int err, const char *fmt, va_list ap) - __attribute__((format(printf, 3, 0))); + __printflike(3, 0); /** * Equivalent to xenbus_dev_error(), followed by @@ -174,7 +174,7 @@ void xenbus_dev_verror(device_t dev, int err, const char *fmt, va_list ap) * printf arguments. */ void xenbus_dev_fatal(device_t dev, int err, const char *fmt, ...) - __attribute__((format(printf, 3, 4))); + __printflike(3, 4); /** * va_list version of xenbus_dev_fatal(). @@ -185,7 +185,7 @@ void xenbus_dev_fatal(device_t dev, int err, const char *fmt, ...) * \param ap Va_list of printf arguments. */ void xenbus_dev_vfatal(device_t dev, int err, const char *fmt, va_list) - __attribute__((format(printf, 3, 0))); + __printflike(3, 0); /** * Convert a member of the xenbus_state enum into an ASCII string. diff --git a/sys/xen/xenstore/xenstorevar.h b/sys/xen/xenstore/xenstorevar.h index 8b02262396e8ec..f34ad375bc3af4 100644 --- a/sys/xen/xenstore/xenstorevar.h +++ b/sys/xen/xenstore/xenstorevar.h @@ -270,7 +270,7 @@ int xs_scanf(struct xs_transaction t, */ int xs_printf(struct xs_transaction t, const char *dir, const char *node, const char *fmt, ...) - __attribute__((format(printf, 4, 5))); + __printflike(4, 5); /** * va_list version of xenbus_printf(). diff --git a/tools/build/cross-build/include/common/sys/cdefs.h b/tools/build/cross-build/include/common/sys/cdefs.h index 3f9b7866141ffc..8419b53135f6cb 100644 --- a/tools/build/cross-build/include/common/sys/cdefs.h +++ b/tools/build/cross-build/include/common/sys/cdefs.h @@ -100,6 +100,14 @@ __attribute__((__format__(__printf0__, fmtarg, firstvararg))) #endif +#ifndef __nonstring +#if __has_attribute(__nonstring__) +#define __nonstring __attribute__((__nonstring__)) +#else +#define __nonstring +#endif +#endif + #ifndef __predict_true #define __predict_true(exp) __builtin_expect((exp), 1) #endif diff --git a/tools/build/mk/Makefile.boot b/tools/build/mk/Makefile.boot index 43246f3ceebf95..6d44bca20c1ec5 100644 --- a/tools/build/mk/Makefile.boot +++ b/tools/build/mk/Makefile.boot @@ -38,6 +38,8 @@ CWARNFLAGS.clang+=-Wno-typedef-redefinition # bsd.sys.mk explicitly turns on -Wsystem-headers, but that's extremely # noisy when building on Linux. CWARNFLAGS+= -Wno-system-headers +# Catch mismatched int/pointer types (e.g. glibc's char* strerror_r prototype) +CWARNFLAGS+= -Werror=int-conversion CWARNFLAGS.clang+=-Werror=incompatible-pointer-types-discards-qualifiers # b64_pton and b64_ntop is in libresolv on MacOS and Linux: diff --git a/tools/build/test-includes/badfiles.inc b/tools/build/test-includes/badfiles.inc index 9feb73edc5d03f..39eb7ef882db08 100644 --- a/tools/build/test-includes/badfiles.inc +++ b/tools/build/test-includes/badfiles.inc @@ -90,14 +90,12 @@ BADHDRS= \ sys/pmckern.h \ sys/posix4.h \ sys/power.h \ - sys/priority.h \ sys/prng.h \ sys/qmath.h \ sys/racct.h \ sys/resourcevar.h \ sys/rman.h \ sys/rmlock.h \ - sys/rtprio.h \ sys/runq.h \ sys/rwlock.h \ sys/sbuf.h \ diff --git a/usr.bin/m4/misc.c b/usr.bin/m4/misc.c index 1870323ccb301e..3091f2ad1f9e7a 100644 --- a/usr.bin/m4/misc.c +++ b/usr.bin/m4/misc.c @@ -120,7 +120,8 @@ pbnum(int n) void pbnumbase(int n, int base, int d) { - static char digits[36] = "0123456789abcdefghijklmnopqrstuvwxyz"; + static char digits[36] __nonstring = + "0123456789abcdefghijklmnopqrstuvwxyz"; unsigned int num; int printed = 0; diff --git a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c index 354ea2ece83aeb..db836d2e731725 100644 --- a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c +++ b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c @@ -336,7 +336,7 @@ static char * snmp_date2asn_oid(char *str, struct asn_oid *oid) { char *endptr, *ptr; - static const char UTC[3] = "UTC"; + static const char UTC[] = "UTC"; int32_t saved_errno; uint32_t v; @@ -445,8 +445,8 @@ snmp_date2asn_oid(char *str, struct asn_oid *oid) /* 'UTC' - optional */ ptr = endptr + 1; - if (strncmp(ptr, UTC, sizeof(UTC)) == 0) - ptr += sizeof(UTC); + if (strncmp(ptr, UTC, strlen(UTC)) == 0) + ptr += strlen(UTC); /* '+/-' */ if (*ptr == '-' || *ptr == '+') { diff --git a/usr.sbin/makefs/msdos/direntry.h b/usr.sbin/makefs/msdos/direntry.h index 9d6c65dfcc7d00..d7ef79114e80ac 100644 --- a/usr.sbin/makefs/msdos/direntry.h +++ b/usr.sbin/makefs/msdos/direntry.h @@ -55,7 +55,7 @@ * Structure of a dos directory entry. */ struct direntry { - uint8_t deName[11]; /* filename, blank filled */ + uint8_t deName[11] __nonstring; /* filename, blank filled */ #define SLOT_EMPTY 0x00 /* slot has never been used */ #define SLOT_E5 0x05 /* the real value is 0xe5 */ #define SLOT_DELETED 0xe5 /* file in this slot deleted */ diff --git a/usr.sbin/pmcannotate/pmcannotate.c b/usr.sbin/pmcannotate/pmcannotate.c index 5958ff615e4ba3..fcfebbe8186d78 100644 --- a/usr.sbin/pmcannotate/pmcannotate.c +++ b/usr.sbin/pmcannotate/pmcannotate.c @@ -54,8 +54,10 @@ if ((ptr) != NULL) \ perror(ptr); \ fprintf(stderr, ##x); \ - remove(tbfl); \ - remove(tofl); \ + if (tbfl != NULL) \ + remove(tbfl); \ + if (tofl != NULL) \ + remove(tofl); \ exit(EXIT_FAILURE); \ } while (0) @@ -692,7 +694,7 @@ int main(int argc, char *argv[]) { char buffer[LNBUFF], fname[FNBUFF]; - char *tbfl, *tofl, *tmpdir; + char *tbfl = NULL, *tofl = NULL, *tmpdir; char tmpf[MAXPATHLEN * 2 + 50]; float limit; char *bin, *exec, *kfile, *ofile;