Skip to content

Commit db9571a

Browse files
committed
Merge tag 'printk-for-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux
Pull printk updates from Petr Mladek: - Check all mandatory callbacks when registering nbcon consoles - Fix some compiler warnings * tag 'printk-for-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux: vsnprintf: drop __printf() attributes on binary printing functions printf: convert test_hashed into macro printk: nbcon: Check for device_{lock,unlock} callbacks
2 parents 148f95f + 9abbecf commit db9571a

4 files changed

Lines changed: 18 additions & 14 deletions

File tree

include/linux/seq_file.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ int seq_open_private(struct file *, const struct seq_operations *, int);
181181
int seq_release_private(struct inode *, struct file *);
182182

183183
#ifdef CONFIG_BINARY_PRINTF
184-
__printf(2, 0)
185184
void seq_bprintf(struct seq_file *m, const char *f, const u32 *binary);
186185
#endif
187186

include/linux/string.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,8 @@ int __sysfs_match_string(const char * const *array, size_t n, const char *s);
336336
#define sysfs_match_string(_a, _s) __sysfs_match_string(_a, ARRAY_SIZE(_a), _s)
337337

338338
#ifdef CONFIG_BINARY_PRINTF
339-
__printf(3, 0) int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args);
340-
__printf(3, 0) int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf);
339+
int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args);
340+
int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf);
341341
#endif
342342

343343
extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos,

kernel/printk/nbcon.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,9 +1758,12 @@ bool nbcon_alloc(struct console *con)
17581758
/* Synchronize the kthread start. */
17591759
lockdep_assert_console_list_lock_held();
17601760

1761-
/* The write_thread() callback is mandatory. */
1762-
if (WARN_ON(!con->write_thread))
1761+
/* Check for mandatory nbcon callbacks. */
1762+
if (WARN_ON(!con->write_thread ||
1763+
!con->device_lock ||
1764+
!con->device_unlock)) {
17631765
return false;
1766+
}
17641767

17651768
rcuwait_init(&con->rcuwait);
17661769
init_irq_work(&con->irq_work, nbcon_irq_work);

lib/tests/printf_kunit.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -266,15 +266,17 @@ hash_pointer(struct kunit *kunittest)
266266
KUNIT_EXPECT_MEMNEQ(kunittest, buf, PTR_STR, PTR_WIDTH);
267267
}
268268

269-
static void
270-
test_hashed(struct kunit *kunittest, const char *fmt, const void *p)
271-
{
272-
char buf[PLAIN_BUF_SIZE];
273-
274-
plain_hash_to_buffer(kunittest, p, buf, PLAIN_BUF_SIZE);
275-
276-
test(buf, fmt, p);
277-
}
269+
/*
270+
* This is a macro so that the compiler can compare its arguments to the
271+
* __printf() attribute on __test(). This cannot be a function with a __printf()
272+
* attribute because GCC requires __printf() functions to be variadic.
273+
*/
274+
#define test_hashed(kunittest, fmt, p) \
275+
do { \
276+
char buf[PLAIN_BUF_SIZE]; \
277+
plain_hash_to_buffer(kunittest, p, buf, PLAIN_BUF_SIZE); \
278+
test(buf, fmt, p); \
279+
} while (0)
278280

279281
/*
280282
* NULL pointers aren't hashed.

0 commit comments

Comments
 (0)