Skip to content

Commit e64ed44

Browse files
Jiri Slabygregkh
authored andcommitted
tty_audit: make tty pointers in exposed functions const
Both tty_audit_add_data() and tty_audit_tiocsti() need only to read from the tty struct, so make the tty parameters of them both const. This aids the compiler a bit. Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230621101611.10580-6-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3e540a7 commit e64ed44

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

drivers/tty/tty.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,15 @@ extern int tty_ldisc_autoload;
9999

100100
/* tty_audit.c */
101101
#ifdef CONFIG_AUDIT
102-
void tty_audit_add_data(struct tty_struct *tty, const void *data, size_t size);
103-
void tty_audit_tiocsti(struct tty_struct *tty, char ch);
102+
void tty_audit_add_data(const struct tty_struct *tty, const void *data,
103+
size_t size);
104+
void tty_audit_tiocsti(const struct tty_struct *tty, char ch);
104105
#else
105-
static inline void tty_audit_add_data(struct tty_struct *tty, const void *data,
106-
size_t size)
106+
static inline void tty_audit_add_data(const struct tty_struct *tty,
107+
const void *data, size_t size)
107108
{
108109
}
109-
static inline void tty_audit_tiocsti(struct tty_struct *tty, char ch)
110+
static inline void tty_audit_tiocsti(const struct tty_struct *tty, char ch)
110111
{
111112
}
112113
#endif

drivers/tty/tty_audit.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void tty_audit_fork(struct signal_struct *sig)
134134
/*
135135
* tty_audit_tiocsti - Log TIOCSTI
136136
*/
137-
void tty_audit_tiocsti(struct tty_struct *tty, char ch)
137+
void tty_audit_tiocsti(const struct tty_struct *tty, char ch)
138138
{
139139
dev_t dev;
140140

@@ -199,7 +199,8 @@ static struct tty_audit_buf *tty_audit_buf_get(void)
199199
*
200200
* Audit @data of @size from @tty, if necessary.
201201
*/
202-
void tty_audit_add_data(struct tty_struct *tty, const void *data, size_t size)
202+
void tty_audit_add_data(const struct tty_struct *tty, const void *data,
203+
size_t size)
203204
{
204205
struct tty_audit_buf *buf;
205206
unsigned int audit_tty;

0 commit comments

Comments
 (0)