From 1a4ab483a2a41160e548e799609f964a7a6f3400 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 13 Aug 2017 01:02:17 +0200 Subject: [PATCH] server: Constify return value of lookup_user(). Command handlers only need to read this structure. --- command.c | 2 +- command.h | 2 +- user_list.c | 4 ++-- user_list.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/command.c b/command.c index a72a524f..74e13635 100644 --- a/command.c +++ b/command.c @@ -784,7 +784,7 @@ struct connection_features { int dummy; /* none at the moment */ }; -static int parse_auth_request(char *buf, int len, struct user **u, +static int parse_auth_request(char *buf, int len, const struct user **u, struct connection_features *cf) { int ret; diff --git a/command.h b/command.h index 0265f056..a7fa4673 100644 --- a/command.h +++ b/command.h @@ -3,7 +3,7 @@ /** Per connection data available to command handlers. */ struct command_context { /** The paraslash user that executes this command. */ - struct user *u; + const struct user *u; /** File descriptor and crypto keys. */ struct stream_cipher_context scc; }; diff --git a/user_list.c b/user_list.c index e4866029..cf53c0fa 100644 --- a/user_list.c +++ b/user_list.c @@ -127,9 +127,9 @@ void init_user_list(char *user_list_file) * \return A pointer to the corresponding user struct if the user was found, \p * NULL otherwise. */ -struct user *lookup_user(const char *name) +const struct user *lookup_user(const char *name) { - struct user *u; + const struct user *u; list_for_each_entry(u, &user_list, node) { if (strcmp(u->name, name)) continue; diff --git a/user_list.h b/user_list.h index 41fad164..e4fbd466 100644 --- a/user_list.h +++ b/user_list.h @@ -33,4 +33,4 @@ struct user { }; void init_user_list(char *user_list_file); -struct user *lookup_user(const char *name); +const struct user *lookup_user(const char *name); -- 2.39.2