Commit 84d0f56e authored by Max Kellermann's avatar Max Kellermann

command: make command pointers constant

The command pointers which are passed around aren't being modified - in fact, no command pointer must be modified once it has been added to the commandList.
parent 4b4f7df9
...@@ -1192,10 +1192,10 @@ static int handleCommands(struct client *client, ...@@ -1192,10 +1192,10 @@ static int handleCommands(struct client *client,
{ {
const unsigned permission = client_get_permission(client); const unsigned permission = client_get_permission(client);
ListNode *node = commandList->firstNode; ListNode *node = commandList->firstNode;
struct command *cmd; const struct command *cmd;
while (node != NULL) { while (node != NULL) {
cmd = (struct command *) node->data; cmd = (const struct command *) node->data;
if (cmd->reqPermission == (permission & cmd->reqPermission)) { if (cmd->reqPermission == (permission & cmd->reqPermission)) {
client_printf(client, "command: %s\n", cmd->cmd); client_printf(client, "command: %s\n", cmd->cmd);
} }
...@@ -1211,10 +1211,10 @@ static int handleNotcommands(struct client *client, ...@@ -1211,10 +1211,10 @@ static int handleNotcommands(struct client *client,
{ {
const unsigned permission = client_get_permission(client); const unsigned permission = client_get_permission(client);
ListNode *node = commandList->firstNode; ListNode *node = commandList->firstNode;
struct command *cmd; const struct command *cmd;
while (node != NULL) { while (node != NULL) {
cmd = (struct command *) node->data; cmd = (const struct command *) node->data;
if (cmd->reqPermission != (permission & cmd->reqPermission)) { if (cmd->reqPermission != (permission & cmd->reqPermission)) {
client_printf(client, "command: %s\n", cmd->cmd); client_printf(client, "command: %s\n", cmd->cmd);
...@@ -1345,7 +1345,8 @@ void finishCommands(void) ...@@ -1345,7 +1345,8 @@ void finishCommands(void)
freeList(commandList); freeList(commandList);
} }
static int checkArgcAndPermission(struct command *cmd, struct client *client, static int
checkArgcAndPermission(const struct command *cmd, struct client *client,
unsigned permission, int argc, char *argv[]) unsigned permission, int argc, char *argv[])
{ {
int min = cmd->min + 1; int min = cmd->min + 1;
...@@ -1382,13 +1383,13 @@ static int checkArgcAndPermission(struct command *cmd, struct client *client, ...@@ -1382,13 +1383,13 @@ static int checkArgcAndPermission(struct command *cmd, struct client *client,
return 0; return 0;
} }
static struct command *getCommandEntryAndCheckArgcAndPermission(struct client *client, static const struct command *
getCommandEntryAndCheckArgcAndPermission(struct client *client,
unsigned permission, unsigned permission,
int argc, int argc, char *argv[])
char *argv[])
{ {
static char unknown[] = ""; static char unknown[] = "";
struct command *cmd; const struct command *cmd;
current_command = unknown; current_command = unknown;
...@@ -1415,7 +1416,7 @@ int processCommand(struct client *client, char *commandString) ...@@ -1415,7 +1416,7 @@ int processCommand(struct client *client, char *commandString)
{ {
int argc; int argc;
char *argv[COMMAND_ARGV_MAX] = { NULL }; char *argv[COMMAND_ARGV_MAX] = { NULL };
struct command *cmd; const struct command *cmd;
int ret = -1; int ret = -1;
if (!(argc = buffer2array(commandString, argv, COMMAND_ARGV_MAX))) if (!(argc = buffer2array(commandString, argv, COMMAND_ARGV_MAX)))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment