From 28954781dc61c24189492be040bcdce5372ead51 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 7 Apr 2012 08:30:27 +0200 Subject: [PATCH 1/1] Make (most) command handlers static. Now that the array of commands for para_server and para_audiod are read from a header file, the command handlers can be made static if they are in the same file that defines the command array. This patch makes all such handlers static and tweaks command_util.sh to recognize also static functions. --- audiod_command.c | 18 +++++++++--------- command.c | 28 ++++++++++++++-------------- command_util.sh | 2 +- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/audiod_command.c b/audiod_command.c index 1c3b0582..35b76b5f 100644 --- a/audiod_command.c +++ b/audiod_command.c @@ -252,7 +252,7 @@ static int dump_commands(int fd) * to each individual command to close the fd if necessary. */ -int com_help(int fd, int argc, char **argv) +static int com_help(int fd, int argc, char **argv) { int i, ret; char *buf; @@ -287,7 +287,7 @@ out: return ret; } -int com_tasks(int fd, __a_unused int argc, __a_unused char **argv) +static int com_tasks(int fd, __a_unused int argc, __a_unused char **argv) { char *tl = get_task_list(&sched); int ret = 1; @@ -299,7 +299,7 @@ int com_tasks(int fd, __a_unused int argc, __a_unused char **argv) return ret; } -int com_stat(int fd, int argc, char **argv) +static int com_stat(int fd, int argc, char **argv) { int i, ret, parser_friendly = 0; uint64_t mask = 0; @@ -345,39 +345,39 @@ int com_stat(int fd, int argc, char **argv) return ret; } -int com_grab(int fd, int argc, char **argv) +static int com_grab(int fd, int argc, char **argv) { return grab_client_new(fd, argc, argv, &sched); } -__noreturn int com_term(int fd, __a_unused int argc, __a_unused char **argv) +__noreturn static int com_term(int fd, __a_unused int argc, __a_unused char **argv) { close(fd); clean_exit(EXIT_SUCCESS, "terminating on user request"); } -int com_on(int fd, __a_unused int argc, __a_unused char **argv) +static int com_on(int fd, __a_unused int argc, __a_unused char **argv) { audiod_status = AUDIOD_ON; close(fd); return 1; } -int com_off(int fd, __a_unused int argc, __a_unused char **argv) +static int com_off(int fd, __a_unused int argc, __a_unused char **argv) { audiod_status = AUDIOD_OFF; close(fd); return 1; } -int com_sb(int fd, __a_unused int argc, __a_unused char **argv) +static int com_sb(int fd, __a_unused int argc, __a_unused char **argv) { audiod_status = AUDIOD_STANDBY; close(fd); return 1; } -int com_cycle(int fd, int argc, char **argv) +static int com_cycle(int fd, int argc, char **argv) { switch (audiod_status) { case AUDIOD_ON: diff --git a/command.c b/command.c index e051aae4..f9bace34 100644 --- a/command.c +++ b/command.c @@ -317,7 +317,7 @@ fail: return ret; } -int com_sender(struct command_context *cc) +static int com_sender(struct command_context *cc) { int i, ret = 0; char *msg = NULL; @@ -374,7 +374,7 @@ int com_sender(struct command_context *cc) } /* server info */ -int com_si(struct command_context *cc) +static int com_si(struct command_context *cc) { int i, ret; char *msg, *ut, *sender_info = NULL; @@ -417,7 +417,7 @@ int com_si(struct command_context *cc) } /* version */ -int com_version(struct command_context *cc) +static int com_version(struct command_context *cc) { char *msg; size_t len; @@ -498,7 +498,7 @@ out: #undef EMPTY_STATUS_ITEMS /* stat */ -int com_stat(struct command_context *cc) +static int com_stat(struct command_context *cc) { int i, ret; struct misc_meta_data tmp, *nmmd = &tmp; @@ -608,7 +608,7 @@ static struct server_command *get_cmd_ptr(const char *name, char **handler) } /* help */ -int com_help(struct command_context *cc) +static int com_help(struct command_context *cc) { struct server_command *cmd; char *perms, *handler, *buf; @@ -647,7 +647,7 @@ int com_help(struct command_context *cc) } /* hup */ -int com_hup(struct command_context *cc) +static int com_hup(struct command_context *cc) { if (cc->argc != 1) return -E_COMMAND_SYNTAX; @@ -656,7 +656,7 @@ int com_hup(struct command_context *cc) } /* term */ -int com_term(struct command_context *cc) +static int com_term(struct command_context *cc) { if (cc->argc != 1) return -E_COMMAND_SYNTAX; @@ -664,7 +664,7 @@ int com_term(struct command_context *cc) return 1; } -int com_play(struct command_context *cc) +static int com_play(struct command_context *cc) { if (cc->argc != 1) return -E_COMMAND_SYNTAX; @@ -676,7 +676,7 @@ int com_play(struct command_context *cc) } /* stop */ -int com_stop(struct command_context *cc) +static int com_stop(struct command_context *cc) { if (cc->argc != 1) return -E_COMMAND_SYNTAX; @@ -689,7 +689,7 @@ int com_stop(struct command_context *cc) } /* pause */ -int com_pause(struct command_context *cc) +static int com_pause(struct command_context *cc) { if (cc->argc != 1) return -E_COMMAND_SYNTAX; @@ -704,7 +704,7 @@ int com_pause(struct command_context *cc) } /* next */ -int com_next(struct command_context *cc) +static int com_next(struct command_context *cc) { if (cc->argc != 1) return -E_COMMAND_SYNTAX; @@ -716,7 +716,7 @@ int com_next(struct command_context *cc) } /* nomore */ -int com_nomore(struct command_context *cc) +static int com_nomore(struct command_context *cc) { if (cc->argc != 1) return -E_COMMAND_SYNTAX; @@ -728,7 +728,7 @@ int com_nomore(struct command_context *cc) } /* ff */ -int com_ff(struct command_context *cc) +static int com_ff(struct command_context *cc) { long promille; int ret, backwards = 0; @@ -767,7 +767,7 @@ out: } /* jmp */ -int com_jmp(struct command_context *cc) +static int com_jmp(struct command_context *cc) { long unsigned int i; int ret; diff --git a/command_util.sh b/command_util.sh index 1530aee7..2bceda43 100755 --- a/command_util.sh +++ b/command_util.sh @@ -173,7 +173,7 @@ make_proto() fi result= for source_file in $source_files; do - match=$(grep "^\(__noreturn \)*int com_$name_txt(" $source_file | head -n 1 | sed -e 's/$/;/1') + match=$(grep "^\(__noreturn \)*\(static \)*int com_$name_txt(" $source_file | head -n 1 | sed -e 's/$/;/1') if test -n "$match"; then result="$result$match$CR" break -- 2.39.2