Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jiri Slaby and committed by
Greg Kroah-Hartman
e64ed44b 3e540a7b

+9 -7
+6 -5
drivers/tty/tty.h
··· 99 99 100 100 /* tty_audit.c */ 101 101 #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); 104 105 #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) 107 108 { 108 109 } 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) 110 111 { 111 112 } 112 113 #endif
+3 -2
drivers/tty/tty_audit.c
··· 134 134 /* 135 135 * tty_audit_tiocsti - Log TIOCSTI 136 136 */ 137 - void tty_audit_tiocsti(struct tty_struct *tty, char ch) 137 + void tty_audit_tiocsti(const struct tty_struct *tty, char ch) 138 138 { 139 139 dev_t dev; 140 140 ··· 199 199 * 200 200 * Audit @data of @size from @tty, if necessary. 201 201 */ 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) 203 204 { 204 205 struct tty_audit_buf *buf; 205 206 unsigned int audit_tty;