git: 3c0ea1b62976 - main - ocs_fc: Use __printflike() instead of format(printf)
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 28 Dec 2025 21:17:08 UTC
The branch main has been updated by dim:
URL: https://cgit.FreeBSD.org/src/commit/?id=3c0ea1b629764c49611e3e3adfa0c44f9afa3558
commit 3c0ea1b629764c49611e3e3adfa0c44f9afa3558
Author: Alex Richardson <arichardson@FreeBSD.org>
AuthorDate: 2025-09-16 04:58:36 +0000
Commit: Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2025-12-28 21:16:24 +0000
ocs_fc: Use __printflike() instead of format(printf)
The __printflike macro sets the format to freebsd_kprintf which recent
clang understands and warns about. Fixes the following error:
`passing 'printf' format string where 'freebsd_kprintf' format string is expected [-Werror,-Wformat]`
MFC after: 1 week
---
sys/dev/ocs_fc/ocs_ddump.h | 3 +--
sys/dev/ocs_fc/ocs_mgmt.h | 3 +--
sys/dev/ocs_fc/ocs_os.h | 2 +-
sys/dev/ocs_fc/ocs_utils.h | 12 ++++--------
4 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/sys/dev/ocs_fc/ocs_ddump.h b/sys/dev/ocs_fc/ocs_ddump.h
index b7d7eefad813..3cffff6d9670 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 7b59a3916ca8..9781aec18462 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 331d5b07aecd..55ee98b3cc58 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 e3a952e0cf26..7c9c9ae85b74 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