[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20240118094050.3b890e98@gandalf.local.home>
Date: Thu, 18 Jan 2024 09:40:50 -0500
From: Steven Rostedt <rostedt@...dmis.org>
To: LKML <linux-kernel@...r.kernel.org>
Cc: Masami Hiramatsu <mhiramat@...nel.org>, Mathieu Desnoyers
<mathieu.desnoyers@...icios.com>, Kees Cook <keescook@...omium.org>, Nathan
Lynch <nathanl@...ux.ibm.com>
Subject: [for-linus][PATCH] seq_buf: Make DECLARE_SEQ_BUF() usable
Another update for 6.8:
- Fix seq_buf warning and make static work properly.
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
trace/urgent
Head SHA1: 7a8e9cdf9405819105ae7405cd91e482bf574b01
Nathan Lynch (1):
seq_buf: Make DECLARE_SEQ_BUF() usable
----
include/linux/seq_buf.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
---------------------------
commit 7a8e9cdf9405819105ae7405cd91e482bf574b01
Author: Nathan Lynch <nathanl@...ux.ibm.com>
Date: Tue Jan 16 08:09:25 2024 -0600
seq_buf: Make DECLARE_SEQ_BUF() usable
Using the address operator on the array doesn't work:
./include/linux/seq_buf.h:27:27: error: initialization of ‘char *’
from incompatible pointer type ‘char (*)[128]’
[-Werror=incompatible-pointer-types]
27 | .buffer = &__ ## NAME ## _buffer, \
| ^
Apart from fixing that, we can improve DECLARE_SEQ_BUF() by using a
compound literal to define the buffer array without attaching a name
to it. This makes the macro a single statement, allowing constructs
such as:
static DECLARE_SEQ_BUF(my_seq_buf, MYSB_SIZE);
to work as intended.
Link: https://lkml.kernel.org/r/20240116-declare-seq-buf-fix-v1-1-915db4692f32@linux.ibm.com
Cc: stable@...r.kernel.org
Acked-by: Kees Cook <keescook@...omium.org>
Fixes: dcc4e5728eea ("seq_buf: Introduce DECLARE_SEQ_BUF and seq_buf_str()")
Signed-off-by: Nathan Lynch <nathanl@...ux.ibm.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@...dmis.org>
diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h
index 5fb1f12c33f9..c44f4b47b945 100644
--- a/include/linux/seq_buf.h
+++ b/include/linux/seq_buf.h
@@ -22,9 +22,8 @@ struct seq_buf {
};
#define DECLARE_SEQ_BUF(NAME, SIZE) \
- char __ ## NAME ## _buffer[SIZE] = ""; \
struct seq_buf NAME = { \
- .buffer = &__ ## NAME ## _buffer, \
+ .buffer = (char[SIZE]) { 0 }, \
.size = SIZE, \
}
Powered by blists - more mailing lists