From cd88e02f3d5a6eef92f77f8b090d7c26ad22c830 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Fri, 10 Sep 2021 11:11:54 +0200 Subject: [PATCH] Use more const char * --- include/h.h | 26 +++++++++++++------------- src/hash.c | 22 +++++++++++----------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/include/h.h b/include/h.h index 0f4723f57..ee95fe3a6 100644 --- a/include/h.h +++ b/include/h.h @@ -180,12 +180,12 @@ extern char *extban_conv_param_nuh(BanContext *b, Extban *extban); extern Ban *is_banned(Client *, Channel *, int, char **, char **); extern Ban *is_banned_with_nick(Client *, Channel *, int, char *, char **, char **); -extern Client *find_client(char *, Client *); -extern Client *find_name(char *, Client *); -extern Client *find_nickserv(char *, Client *); -extern Client *find_person(char *, Client *); -extern Client *find_server(char *, Client *); -extern Client *find_service(char *, Client *); +extern Client *find_client(const char *, Client *); +extern Client *find_name(const char *, Client *); +extern Client *find_nickserv(const char *, Client *); +extern Client *find_person(const char *, Client *); +extern Client *find_server(const char *, Client *); +extern Client *find_service(const char *, Client *); #define find_server_quick(x) find_server(x, NULL) extern char *find_or_add(char *); extern void inittoken(); @@ -336,17 +336,17 @@ extern uint64_t siphash_nocase(const char *in, const char *k); extern void siphash_generate_key(char *k); extern void init_hash(void); uint64_t hash_whowas_name(const char *name); -extern int add_to_client_hash_table(char *, Client *); -extern int del_from_client_hash_table(char *, Client *); -extern int add_to_id_hash_table(char *, Client *); -extern int del_from_id_hash_table(char *, Client *); -extern int add_to_channel_hash_table(char *, Channel *); -extern void del_from_channel_hash_table(char *, Channel *); +extern int add_to_client_hash_table(const char *, Client *); +extern int del_from_client_hash_table(const char *, Client *); +extern int add_to_id_hash_table(const char *, Client *); +extern int del_from_id_hash_table(const char *, Client *); +extern int add_to_channel_hash_table(const char *, Channel *); +extern void del_from_channel_hash_table(const char *, Channel *); extern Channel *hash_get_chan_bucket(uint64_t); extern Client *hash_find_client(const char *, Client *); extern Client *hash_find_id(const char *, Client *); extern Client *hash_find_nickatserver(const char *, Client *); -extern Channel *find_channel(char *name); +extern Channel *find_channel(const char *name); extern Client *hash_find_server(const char *, Client *); extern struct MODVAR ThrottlingBucket *ThrottlingHash[THROTTLING_HASH_TABLE_SIZE]; diff --git a/src/hash.c b/src/hash.c index 90edc278a..5f842c67b 100644 --- a/src/hash.c +++ b/src/hash.c @@ -314,7 +314,7 @@ uint64_t hash_whowas_name(const char *name) /* * add_to_client_hash_table */ -int add_to_client_hash_table(char *name, Client *client) +int add_to_client_hash_table(const char *name, Client *client) { unsigned int hashv; /* @@ -340,7 +340,7 @@ int add_to_client_hash_table(char *name, Client *client) /* * add_to_client_hash_table */ -int add_to_id_hash_table(char *name, Client *client) +int add_to_id_hash_table(const char *name, Client *client) { unsigned int hashv; hashv = hash_client_name(name); @@ -351,7 +351,7 @@ int add_to_id_hash_table(char *name, Client *client) /* * add_to_channel_hash_table */ -int add_to_channel_hash_table(char *name, Channel *channel) +int add_to_channel_hash_table(const char *name, Channel *channel) { unsigned int hashv; @@ -363,7 +363,7 @@ int add_to_channel_hash_table(char *name, Channel *channel) /* * del_from_client_hash_table */ -int del_from_client_hash_table(char *name, Client *client) +int del_from_client_hash_table(const char *name, Client *client) { if (!list_empty(&client->client_hash)) list_del(&client->client_hash); @@ -373,7 +373,7 @@ int del_from_client_hash_table(char *name, Client *client) return 0; } -int del_from_id_hash_table(char *name, Client *client) +int del_from_id_hash_table(const char *name, Client *client) { if (!list_empty(&client->id_hash)) list_del(&client->id_hash); @@ -386,7 +386,7 @@ int del_from_id_hash_table(char *name, Client *client) /* * del_from_channel_hash_table */ -void del_from_channel_hash_table(char *name, Channel *channel) +void del_from_channel_hash_table(const char *name, Channel *channel) { Channel *tmp, *prev = NULL; unsigned int hashv; @@ -507,7 +507,7 @@ Client *hash_find_server(const char *server, Client *def) * the ID table, otherwise not. * @returns If the client is found then the Client is returned, otherwise NULL. */ -Client *find_client(char *name, Client *requester) +Client *find_client(const char *name, Client *requester) { if (requester == NULL || IsServer(requester)) { @@ -528,7 +528,7 @@ Client *find_client(char *name, Client *requester) * the ID table, otherwise not. * @returns If the server is found then the Client is returned, otherwise NULL. */ -Client *find_server(char *name, Client *requester) +Client *find_server(const char *name, Client *requester) { if (name) { @@ -548,7 +548,7 @@ Client *find_server(char *name, Client *requester) * the ID table, otherwise not. * @returns If the user is found then the Client is returned, otherwise NULL. */ -Client *find_person(char *name, Client *requester) /* TODO: this should have been called find_user() to be consistent */ +Client *find_person(const char *name, Client *requester) /* TODO: this should have been called find_user() to be consistent */ { Client *c2ptr; @@ -565,7 +565,7 @@ Client *find_person(char *name, Client *requester) /* TODO: this should have bee * @param name The channel name to search for * @returns If the channel exists then the Channel is returned, otherwise NULL. */ -Channel *find_channel(char *name) +Channel *find_channel(const char *name) { unsigned int hashv; Channel *channel; @@ -625,7 +625,7 @@ void init_throttling() */ } -uint64_t hash_throttling(char *ip) +uint64_t hash_throttling(const char *ip) { return siphash(ip, siphashkey_throttling) % THROTTLING_HASH_TABLE_SIZE; }