From: Andre Noll Date: Sun, 9 Sep 2007 17:29:26 +0000 (+0200) Subject: Change the type of the argv argument of all commands. X-Git-Tag: v0.3.0~436 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=2cfb78331c33cb74c6abf357e8221604c3c9ec47;p=paraslash.git Change the type of the argv argument of all commands. The new type, char * const * const argv is what the exec functions also take. This avoids some warnings. --- diff --git a/afs.c b/afs.c index 3fc5df43..806d0fbd 100644 --- a/afs.c +++ b/afs.c @@ -235,7 +235,7 @@ out: * \sa send_standard_callback_request(), send_callback_request(). */ int send_option_arg_callback_request(struct osl_object *options, - int argc, const char **argv, callback_function *f, + int argc, char * const * const argv, callback_function *f, struct osl_object *result) { char *p; @@ -273,7 +273,7 @@ int send_option_arg_callback_request(struct osl_object *options, * \return The return value of the underlying call to * send_option_arg_callback_request(). */ -int send_standard_callback_request(int argc, const char **argv, +int send_standard_callback_request(int argc, char * const * const argv, callback_function *f, struct osl_object *result) { return send_option_arg_callback_request(NULL, argc, argv, f, result); @@ -794,7 +794,7 @@ static int create_all_tables(void) } /* TODO load tables after init */ -int com_init(__a_unused int fd, int argc, const char **argv) +int com_init(__a_unused int fd, int argc, char * const * const argv) { int i, j, ret; if (argc == 1) diff --git a/afs.cmd b/afs.cmd index 187e2af7..f8454d60 100644 --- a/afs.cmd +++ b/afs.cmd @@ -70,7 +70,7 @@ H: FIXME --- T: cat N: cat@member@ -O: int com_cat@member@(int fd, int argc, char **argv); +O: int com_cat@member@(int fd, int argc, char * const * const argv); P: AFS_READ D: FIXME U: cat@member@ @member@_name @@ -78,7 +78,7 @@ H: FIXME --- T: ls N: ls@member@ -O: int com_ls@member@(int fd, int argc, char **argv); +O: int com_ls@member@(int fd, int argc, char * const * const argv); P: AFS_READ D: FIXME U: cat@member@ @@ -86,7 +86,7 @@ H: FIXME --- T: rm N: rm@member@ -O: int com_rm@member@(int fd, int argc, char **argv); +O: int com_rm@member@(int fd, int argc, char * const * const argv); P: AFS_READ | AFS_WRITE D: FIXME U: rm@member@ @member@_name @@ -94,7 +94,7 @@ H: FIXME --- T: mv N: mv@member@ -O: int com_mv@member@(int fd, int argc, char **argv); +O: int com_mv@member@(int fd, int argc, char * const * const argv); P: AFS_READ | AFS_WRITE D: FIXME U: mv@member@ old_@member@_name new_@member@_name diff --git a/afs.h b/afs.h index aa94ac72..22d70ad9 100644 --- a/afs.h +++ b/afs.h @@ -96,10 +96,10 @@ typedef int callback_function(const struct osl_object *, struct osl_object *); __noreturn int afs_init(uint32_t cookie, int socket_fd); int send_callback_request(callback_function *f, struct osl_object *query, struct osl_object *result); -int send_standard_callback_request(int argc, const char **argv, +int send_standard_callback_request(int argc, char * const * const argv, callback_function *f, struct osl_object *result); int send_option_arg_callback_request(struct osl_object *options, - int argc, const char **argv, callback_function *f, + int argc, char * const * const argv, callback_function *f, struct osl_object *result); int stdin_command(struct osl_object *arg_obj, callback_function *f, unsigned max_len, struct osl_object *result); diff --git a/aft.c b/aft.c index 866f269f..f1616adf 100644 --- a/aft.c +++ b/aft.c @@ -1030,7 +1030,7 @@ out: * full list: list everything, including afsi, afhi, atts as clear text * * */ -int com_afs_ls(int fd, int argc, const char **argv) +int com_afs_ls(int fd, int argc, char * const * const argv) { int i, ret; unsigned flags = 0; @@ -1437,7 +1437,7 @@ out_free: return ret; } -int com_add(int fd, int argc, char **argv) +int com_add(int fd, int argc, char * const * const argv) { int i, ret; struct private_add_data pad = {.fd = fd, .flags = 0}; @@ -1540,7 +1540,7 @@ static int com_touch_callback(const struct osl_object *query, return 1; } -int com_touch(__a_unused int fd, int argc, const char **argv) +int com_touch(__a_unused int fd, int argc, char * const * const argv) { struct com_touch_options cto = { .num_played = -1, @@ -1629,7 +1629,7 @@ static int com_rm_callback(const struct osl_object *query, * * */ -int com_afs_rm(__a_unused int fd, int argc, const char **argv) +int com_afs_rm(__a_unused int fd, int argc, char * const * const argv) { struct com_rm_options cro = {.flags = 0}; struct osl_object options = {.data = &cro, .size = sizeof(cro)}; diff --git a/attribute.c b/attribute.c index cecd1aa5..925795be 100644 --- a/attribute.c +++ b/attribute.c @@ -107,7 +107,7 @@ static int log_attribute(struct osl_row *row, void *private_data) } /* FIXME: Need callback */ -int com_lsatt(int fd, int argc, const char **argv) +int com_lsatt(int fd, int argc, char * const * const argv) { struct private_laa_data pld = {.fd = fd, .flags = 0}; int i; @@ -201,7 +201,7 @@ static int com_setatt_callback(const struct osl_object *query, return 1; } -int com_setatt(__a_unused int fd, int argc, const char **argv) +int com_setatt(__a_unused int fd, int argc, char * const * const argv) { if (argc < 2) return -E_ATTR_SYNTAX; @@ -277,7 +277,7 @@ static int com_addatt_callback(const struct osl_object *query, return mood_reload(); } -int com_addatt(__a_unused int fd, int argc, const char **argv) +int com_addatt(__a_unused int fd, int argc, char * const * const argv) { if (argc < 2) return -E_ATTR_SYNTAX; @@ -312,7 +312,7 @@ static int com_rmatt_callback(const struct osl_object *query, return mood_reload(); } -int com_rmatt(__a_unused int fd, int argc, const char **argv) +int com_rmatt(__a_unused int fd, int argc, char * const * const argv) { if (argc < 2) return -E_ATTR_SYNTAX; diff --git a/blob.c b/blob.c index eca3c563..fa5134d7 100644 --- a/blob.c +++ b/blob.c @@ -106,7 +106,7 @@ int com_lsblob_callback(struct osl_table *table, return ret; } -static int com_lsblob(callback_function *f, int fd, int argc, const char **argv) +static int com_lsblob(callback_function *f, int fd, int argc, char * const * const argv) { struct com_lsblob_options clbo = {.flags = 0}; struct osl_object query = {.data = &clbo, .size = sizeof(clbo)}, @@ -163,7 +163,7 @@ static int com_catblob_callback(struct osl_table *table, return osl_close_disk_object(&obj); } static int com_catblob(callback_function *f, int fd, int argc, - const char **argv) + char * const * const argv) { struct osl_object cat_output = {.data = NULL}; int ret; @@ -232,7 +232,7 @@ static int com_addblob_callback(struct osl_table *table, } static int com_addblob(callback_function *f, __a_unused int fd, int argc, - const char **argv) + char * const * const argv) { struct osl_object arg_obj; @@ -272,7 +272,7 @@ static int com_rmblob_callback(struct osl_table *table, } static int com_rmblob(callback_function *f, __a_unused int fd, int argc, - const char **argv) + char * const * const argv) { if (argc < 2) return -E_MOOD_SYNTAX; @@ -298,7 +298,7 @@ static int com_mvblob_callback(struct osl_table *table, } static int com_mvblob(callback_function *f, __a_unused int fd, - int argc, const char **argv) + int argc, char * const * const argv) { if (argc != 3) return -E_MOOD_SYNTAX; @@ -312,7 +312,7 @@ static int com_mvblob(callback_function *f, __a_unused int fd, { \ return com_ ## cmd_name ## blob_callback(table_name ## _table, query, output); \ } \ - int com_ ## cmd_name ## cmd_prefix(__a_unused int fd, int argc, const char **argv) \ + int com_ ## cmd_name ## cmd_prefix(int fd, int argc, char * const * const argv) \ { \ return com_ ## cmd_name ## blob(com_ ## cmd_name ## cmd_prefix ## _callback, fd, argc, argv); \ } diff --git a/command.c b/command.c index 0434a80f..1c1b300f 100644 --- a/command.c +++ b/command.c @@ -179,7 +179,7 @@ static char *get_status(struct misc_meta_data *nmmd) return ret; } -static int check_sender_args(int argc, char **argv, struct sender_command_data *scd) +static int check_sender_args(int argc, char * const * argv, struct sender_command_data *scd) { int i; /* this has to match sender.h */ @@ -245,7 +245,7 @@ static int check_sender_args(int argc, char **argv, struct sender_command_data * return 1; } -int com_sender(int fd, int argc, char **argv) +int com_sender(int fd, int argc, char * const * argv) { int i, ret; struct sender_command_data scd; @@ -287,7 +287,7 @@ int com_sender(int fd, int argc, char **argv) } /* server info */ -int com_si(int fd, int argc, __a_unused char **argv) +int com_si(int fd, int argc, __a_unused char * const * argv) { int i, ret; char *ut; @@ -336,7 +336,7 @@ int com_si(int fd, int argc, __a_unused char **argv) } /* version */ -int com_version(int fd, int argc, __a_unused char **argv) +int com_version(int fd, int argc, __a_unused char * const * argv) { if (argc != 1) return -E_COMMAND_SYNTAX; @@ -347,7 +347,7 @@ int com_version(int fd, int argc, __a_unused char **argv) } /* sc */ -int com_sc(int fd, int argc, char **argv) +int com_sc(int fd, int argc, char * const * argv) { char *name = NULL; int ret, old = 0, count = -1; /* print af change forever */ @@ -375,7 +375,7 @@ repeat: } /* sb */ -int com_sb(int fd, int argc, char **argv) +int com_sb(int fd, int argc, char * const * argv) { char *sb; int ret, nr = -1; /* status bar will be printed that many @@ -402,7 +402,7 @@ int com_sb(int fd, int argc, char **argv) } /* stat */ -int com_stat(int fd, int argc, char **argv) +int com_stat(int fd, int argc, char * const * argv) { int ret, num = 0;/* status will be printed that many * times. num <= 0 means: print forever @@ -452,7 +452,7 @@ static int send_list_of_commands(int fd, struct server_command *cmd, } /* always returns string that must be freed by the caller in handler */ -static struct server_command *get_cmd_ptr(char *name, char **handler) +static struct server_command *get_cmd_ptr(const char *name, char **handler) { struct server_command *cmd; @@ -480,7 +480,7 @@ static struct server_command *get_cmd_ptr(char *name, char **handler) } /* help */ -int com_help(int fd, int argc, char **argv) +int com_help(int fd, int argc, char * const * argv) { struct server_command *cmd; char *perms, *handler; @@ -527,7 +527,7 @@ int com_help(int fd, int argc, char **argv) } /* hup */ -int com_hup(__a_unused int fd, int argc, __a_unused char **argv) +int com_hup(__a_unused int fd, int argc, __a_unused char * const * argv) { if (argc != 1) return -E_COMMAND_SYNTAX; @@ -536,7 +536,7 @@ int com_hup(__a_unused int fd, int argc, __a_unused char **argv) } /* term */ -int com_term(__a_unused int fd, int argc, __a_unused char **argv) +int com_term(__a_unused int fd, int argc, __a_unused char * const * argv) { if (argc != 1) return -E_COMMAND_SYNTAX; @@ -544,7 +544,7 @@ int com_term(__a_unused int fd, int argc, __a_unused char **argv) return 1; } -int com_play(__a_unused int fd, int argc, __a_unused char **argv) +int com_play(__a_unused int fd, int argc, __a_unused char * const * argv) { if (argc != 1) return -E_COMMAND_SYNTAX; @@ -557,7 +557,7 @@ int com_play(__a_unused int fd, int argc, __a_unused char **argv) } /* stop */ -int com_stop(__a_unused int fd, int argc, __a_unused char **argv) +int com_stop(__a_unused int fd, int argc, __a_unused char * const * argv) { if (argc != 1) return -E_COMMAND_SYNTAX; @@ -570,7 +570,7 @@ int com_stop(__a_unused int fd, int argc, __a_unused char **argv) } /* pause */ -int com_pause(__a_unused int fd, int argc, __a_unused char **argv) +int com_pause(__a_unused int fd, int argc, __a_unused char * const * argv) { if (argc != 1) return -E_COMMAND_SYNTAX; @@ -583,7 +583,7 @@ int com_pause(__a_unused int fd, int argc, __a_unused char **argv) return 1; } -int com_chs(int fd, int argc, char **argv) +int com_chs(int fd, int argc, char * const * argv) { int i, ret; @@ -609,7 +609,7 @@ int com_chs(int fd, int argc, char **argv) } /* next */ -int com_next(__a_unused int fd, int argc, __a_unused char **argv) +int com_next(__a_unused int fd, int argc, __a_unused char * const * argv) { if (argc != 1) return -E_COMMAND_SYNTAX; @@ -621,7 +621,7 @@ int com_next(__a_unused int fd, int argc, __a_unused char **argv) } /* nomore */ -int com_nomore(__a_unused int fd, int argc, __a_unused char **argv) +int com_nomore(__a_unused int fd, int argc, __a_unused char * const * argv) { if (argc != 1) return -E_COMMAND_SYNTAX; @@ -633,7 +633,7 @@ int com_nomore(__a_unused int fd, int argc, __a_unused char **argv) } /* ff */ -int com_ff(__a_unused int fd, int argc, char **argv) +int com_ff(__a_unused int fd, int argc, char * const * argv) { long promille; int ret, backwards = 0; @@ -672,7 +672,7 @@ out: } /* jmp */ -int com_jmp(__a_unused int fd, int argc, char **argv) +int com_jmp(__a_unused int fd, int argc, char * const * argv) { long unsigned int i; int ret; diff --git a/exec.c b/exec.c index 42a183a4..0886a0b7 100644 --- a/exec.c +++ b/exec.c @@ -22,7 +22,7 @@ * * \sa null(4), pipe(2), dup2(2), fork(2), exec(3) */ -static int para_exec(pid_t *pid, const char *file, char *const args[], int *fds) +static int para_exec(pid_t *pid, const char *file, char *const *const args, int *fds) { int ret, in[2] = {-1, -1}, out[2] = {-1, -1}, err[2] = {-1, -1}, null = -1; /* ;) */ @@ -131,7 +131,8 @@ err_out: int para_exec_cmdline_pid(pid_t *pid, const char *cmdline, int *fds) { int argc, ret; - char **argv, *tmp = para_strdup(cmdline); + char **argv; + char *tmp = para_strdup(cmdline); if (!tmp) exit(EXIT_FAILURE); diff --git a/mysql_selector.c b/mysql_selector.c index 0635f855..eaee16a9 100644 --- a/mysql_selector.c +++ b/mysql_selector.c @@ -266,7 +266,7 @@ static char *escaped_basename(const char *name) /* * new attribute */ -int com_na(__a_unused int fd, int argc, char *argv[]) +int com_na(__a_unused int fd, int argc, char * const * argv) { char *q, *tmp; int ret; @@ -287,7 +287,7 @@ int com_na(__a_unused int fd, int argc, char *argv[]) /* * delete attribute */ -int com_da(__a_unused int fd, int argc, char *argv[]) +int com_da(__a_unused int fd, int argc, char * const * argv) { char *q, *tmp; int ret; @@ -305,7 +305,7 @@ int com_da(__a_unused int fd, int argc, char *argv[]) } /* stradd/pic_add */ -static int com_stradd_picadd(int fd, int argc, char *argv[]) +static int com_stradd_picadd(int fd, int argc, char * const * argv) { char *blob = NULL, *esc_blob = NULL, *q = NULL, *tmp = NULL; const char *fmt, *del_fmt; @@ -361,13 +361,13 @@ out: } /* stradd */ -int com_stradd(int fd, int argc, char *argv[]) +int com_stradd(int fd, int argc, char * const * argv) { return com_stradd_picadd(fd, argc, argv); } /* pic_add */ -int com_picadd(int fd, int argc, char *argv[]) +int com_picadd(int fd, int argc, char * const * argv) { return com_stradd_picadd(fd, argc, argv); } @@ -403,7 +403,7 @@ static int print_results(int fd, void *result, /* * verbatim */ -int com_verb(int fd, int argc, char *argv[]) +int com_verb(int fd, int argc, char * const * argv) { void *result = NULL; int ret; @@ -450,7 +450,7 @@ static void *get_all_attributes(void) /* * list all attributes */ -int com_laa(int fd, int argc, __a_unused char *argv[]) +int com_laa(int fd, int argc, __a_unused char * const * argv) { void *result; int ret; @@ -473,7 +473,7 @@ int com_laa(int fd, int argc, __a_unused char *argv[]) /* * history */ -int com_hist(int fd, int argc, char *argv[]) +int com_hist(int fd, int argc, char * const * argv) { int ret; void *result = NULL; @@ -509,7 +509,7 @@ int com_hist(int fd, int argc, char *argv[]) /* * get last num audio files */ -int com_last(int fd, int argc, char *argv[]) +int com_last(int fd, int argc, char * const * argv) { void *result = NULL; char *q; @@ -534,7 +534,7 @@ int com_last(int fd, int argc, char *argv[]) return ret; } -int com_mbox(int fd, int argc, char *argv[]) +int com_mbox(int fd, int argc, char * const * argv) { void *result; MYSQL_ROW row; @@ -740,7 +740,7 @@ err_out: * If filename is NULL, query will list everything, otherwise only * the score of given file. */ -static char *get_query(char *streamname, char *filename, int with_path) +static char *get_query(const char *streamname, char *filename, int with_path) { char *accept_opts = NULL, *deny_opts = NULL, *score = NULL; char *where_clause, *order, *query; @@ -951,7 +951,7 @@ static void refresh_selector_info(void) } /* list attributes / print database info */ -static int com_la_info(int fd, int argc, char *argv[]) +static int com_la_info(int fd, int argc, char * const * argv) { char *name = NULL, *meta = NULL, *atts = NULL, *dir = NULL; int ret, la = strcmp(argv[0], "info"); @@ -985,13 +985,13 @@ out: } /* list attributes */ -int com_la(int fd, int argc, char *argv[]) +int com_la(int fd, int argc, char * const * argv) { return com_la_info(fd, argc, argv); } /* print database info */ -int com_info(int fd, int argc, char *argv[]) +int com_info(int fd, int argc, char * const * argv) { return com_la_info(fd, argc, argv); } @@ -1091,7 +1091,7 @@ out: /* * remove/add entries */ -static int com_rm_ne(__a_unused int fd, int argc, char *argv[]) +static int com_rm_ne(__a_unused int fd, int argc, char * const * argv) { int ne = !strcmp(argv[0], "ne"); int i, ret; @@ -1113,7 +1113,7 @@ static int com_rm_ne(__a_unused int fd, int argc, char *argv[]) /* * rm */ -int com_rm(int fd, int argc, char *argv[]) +int com_rm(int fd, int argc, char * const * argv) { return com_rm_ne(fd, argc, argv); } @@ -1121,7 +1121,7 @@ int com_rm(int fd, int argc, char *argv[]) /* * ne */ -int com_ne(int fd, int argc, char *argv[]) +int com_ne(int fd, int argc, char * const * argv) { return com_ne(fd, argc, argv); } @@ -1129,7 +1129,7 @@ int com_ne(int fd, int argc, char *argv[]) /* * mv: rename entry */ -int com_mv(__a_unused int fd, int argc, char *argv[]) +int com_mv(__a_unused int fd, int argc, char * const * argv) { char *q, *dn, *ebn1 = NULL, *ebn2 = NULL, *edn = NULL; int ret; @@ -1187,7 +1187,7 @@ out: /* * set field */ -static int com_set(__a_unused int fd, int argc, char *argv[]) +static int com_set(__a_unused int fd, int argc, char * const * argv) { char *q, *ebn; long unsigned id; @@ -1215,7 +1215,7 @@ static int com_set(__a_unused int fd, int argc, char *argv[]) /* * snp: set numplayed */ -int com_picass(int fd, int argc, char *argv[]) +int com_picass(int fd, int argc, char * const * argv) { return com_set(fd, argc, argv); } @@ -1223,7 +1223,7 @@ int com_picass(int fd, int argc, char *argv[]) /* * snp: set numplayed */ -int com_snp(int fd, int argc, char *argv[]) +int com_snp(int fd, int argc, char * const * argv) { int ret = com_set(fd, argc, argv); if (ret >= 0) @@ -1234,7 +1234,7 @@ int com_snp(int fd, int argc, char *argv[]) /* * picch: change entry's name in pics table */ -int com_picch(__a_unused int fd, int argc, char *argv[]) +int com_picch(__a_unused int fd, int argc, char * const * argv) { int ret; long unsigned id; @@ -1257,7 +1257,7 @@ int com_picch(__a_unused int fd, int argc, char *argv[]) /* * piclist: print list of pics in db */ -int com_piclist(__a_unused int fd, int argc, __a_unused char *argv[]) +int com_piclist(__a_unused int fd, int argc, __a_unused char * const * argv) { void *result = NULL; MYSQL_ROW row; @@ -1286,7 +1286,7 @@ out: /* * picdel: delete picture from database */ -int com_picdel(int fd, int argc, char *argv[]) +int com_picdel(int fd, int argc, char * const * argv) { char *q; long unsigned id; @@ -1318,7 +1318,7 @@ int com_picdel(int fd, int argc, char *argv[]) /* * pic: get picture by name or by number */ -int com_pic(int fd, int argc, char *argv[]) +int com_pic(int fd, int argc, char * const * argv) { void *result = NULL; MYSQL_ROW row; @@ -1359,7 +1359,7 @@ out: } /* strdel */ -int com_strdel(__a_unused int fd, int argc, char *argv[]) +int com_strdel(__a_unused int fd, int argc, char * const * argv) { char *q, *tmp; int ret; @@ -1379,7 +1379,7 @@ int com_strdel(__a_unused int fd, int argc, char *argv[]) /* * ls */ -int com_ls(int fd, int argc, char *argv[]) +int com_ls(int fd, int argc, char * const * argv) { char *q; void *result; @@ -1412,7 +1412,7 @@ int com_ls(int fd, int argc, char *argv[]) /* * summary */ -int com_summary(__a_unused int fd, int argc, __a_unused char *argv[]) +int com_summary(__a_unused int fd, int argc, __a_unused char * const * argv) { MYSQL_ROW row; MYSQL_ROW row2; @@ -1478,7 +1478,7 @@ out: return ret; } -static int update_audio_file(char *name) +static int update_audio_file(const char *name) { int ret; const char *fmt1 = "update data set lastplayed = now() where name = '%s'"; @@ -1514,7 +1514,7 @@ static void update_audio_file_server_handler(char *name) update_audio_file(name); } -int com_us(__a_unused int fd, int argc, char *argv[]) +int com_us(__a_unused int fd, int argc, char * const * argv) { char *tmp; int ret; @@ -1532,7 +1532,7 @@ int com_us(__a_unused int fd, int argc, char *argv[]) } /* select previous / next stream */ -static int com_ps_ns(__a_unused int fd, int argc, char *argv[]) +static int com_ps_ns(__a_unused int fd, int argc, char * const * argv) { char *query, *stream = get_current_stream(); void *result = get_result("select name from streams"); @@ -1598,19 +1598,19 @@ out: } /* select previous stream */ -int com_ps(int fd, int argc, char *argv[]) +int com_ps(int fd, int argc, char * const * argv) { return com_ps_ns(fd, argc, argv); } /* select next stream */ -int com_ns(int fd, int argc, char *argv[]) +int com_ns(int fd, int argc, char * const * argv) { return com_ps_ns(fd, argc, argv); } /* streams */ -int com_streams(int fd, int argc, __a_unused char *argv[]) +int com_streams(int fd, int argc, __a_unused char * const * argv) { unsigned int num_rows; int i, ret = -E_NORESULT; @@ -1648,7 +1648,7 @@ out: } /* query stream definition */ -int com_strq(int fd, int argc, char *argv[]) +int com_strq(int fd, int argc, char * const * argv) { MYSQL_ROW row; char *query, *name; @@ -1684,7 +1684,7 @@ out: } /* change stream / change stream and play */ -static int com_cs_csp(int fd, int argc, char *argv[]) +static int com_cs_csp(int fd, int argc, char * const * argv) { int ret, stream_change; char *query, *stream = NULL; @@ -1732,19 +1732,19 @@ out: } /* change stream */ -int com_cs(int fd, int argc, char *argv[]) +int com_cs(int fd, int argc, char * const * argv) { return com_cs_csp(fd, argc, argv); } /* change stream and play */ -int com_csp(int fd, int argc, char *argv[]) +int com_csp(int fd, int argc, char * const * argv) { return com_cs_csp(fd, argc, argv); } /* score list / skip */ -static int com_sl_skip(int fd, int argc, char *argv[]) +static int com_sl_skip(int fd, int argc, char * const * argv) { void *result = NULL; MYSQL_ROW row; @@ -1797,13 +1797,13 @@ out: } /* score list */ -int com_sl(int fd, int argc, char *argv[]) +int com_sl(int fd, int argc, char * const * argv) { return com_sl_skip(fd, argc, argv); } /* skip */ -int com_skip(int fd, int argc, char *argv[]) +int com_skip(int fd, int argc, char * const * argv) { return com_sl_skip(fd, argc, argv); } @@ -1811,7 +1811,7 @@ int com_skip(int fd, int argc, char *argv[]) /* * update attributes of name */ -static int update_atts(int fd, char *name, char *atts) +static int update_atts(int fd, const char *name, char *atts) { int ret; char *ebn, *q, *old, *new = NULL; @@ -1840,7 +1840,7 @@ out: /* * set attributes */ -int com_sa(int fd, int argc, char *argv[]) +int com_sa(int fd, int argc, char * const * argv) { int i, ret; char *atts = NULL, *name; @@ -1849,12 +1849,12 @@ int com_sa(int fd, int argc, char *argv[]) return -E_MYSQL_SYNTAX; for (i = 1; i < argc; i++) { int unset = 0; - char *esc, *tmp, *p =argv[i]; - int len = strlen(p); + char *esc, *tmp, *p; + int len = strlen(argv[i]); if (!len) continue; - switch (p[len - 1]) { + switch (argv[i][len - 1]) { case '+': unset = 0; break; @@ -1864,8 +1864,10 @@ int com_sa(int fd, int argc, char *argv[]) default: goto no_more_atts; } + p = para_strdup(argv[i]); p[len - 1] = '\0'; esc = escape_str(p); + free(p); if (!esc) return -E_ESCAPE; tmp = make_message("%s%s='%s'", atts? "," : "", esc, @@ -1897,7 +1899,7 @@ out: /* * copy attributes */ -int com_cam(int fd, int argc, char *argv[]) +int com_cam(int fd, int argc, char * const * argv) { char *name = NULL, *meta = NULL, *atts = NULL; int i, ret; @@ -1945,7 +1947,7 @@ out: /* * verify / clean */ -static int com_vrfy_clean(int fd, int argc, __a_unused char *argv[]) +static int com_vrfy_clean(int fd, int argc, __a_unused char * const * argv) { char *query; int ret, vrfy_mode = strcmp(argv[0], "clean"); @@ -1998,7 +2000,7 @@ out: /* * verify */ -int com_vrfy(int fd, int argc, char **argv) +int com_vrfy(int fd, int argc, char * const * argv) { return com_vrfy_clean(fd, argc, argv); } @@ -2006,7 +2008,7 @@ int com_vrfy(int fd, int argc, char **argv) /* * clean */ -int com_clean(int fd, int argc, char **argv) +int com_clean(int fd, int argc, char * const * argv) { return com_vrfy_clean(fd, argc, argv); } @@ -2026,7 +2028,7 @@ static int mysql_write_tmp_file(const char *dir, const char *name) /* * update database */ -int com_upd(int fd, int argc, __a_unused char *argv[]) +int com_upd(int fd, int argc, __a_unused char * const * argv) { char *tempname = NULL, *query = NULL; int ret, out_fd = -1, num = 0; @@ -2197,7 +2199,7 @@ static void write_msg2mmd(int success) } /* create database */ -int com_cdb(int fd, int argc, char *argv[]) +int com_cdb(int fd, int argc, char * const * argv) { char *query; int ret; diff --git a/playlist_selector.c b/playlist_selector.c index 0da63ad1..6866dafb 100644 --- a/playlist_selector.c +++ b/playlist_selector.c @@ -110,7 +110,7 @@ out: return ret; } -int com_lpl(int fd, __a_unused int argc, __a_unused char *argv[]) +int com_lpl(int fd, __a_unused int argc, __a_unused char * const * const argv) { unsigned loaded = 0; size_t bufsize = 4096; /* guess that's enough */ @@ -141,7 +141,7 @@ out: return ret; } -int com_ppl(int fd, __a_unused int argc, __a_unused char *argv[]) +int com_ppl(int fd, __a_unused int argc, __a_unused char * const * const argv) { unsigned i; diff --git a/random_selector.c b/random_selector.c index 36d4d580..bcbdae69 100644 --- a/random_selector.c +++ b/random_selector.c @@ -38,7 +38,7 @@ static int remember_file(const char *dir, const char *name) return 1; } -int com_random_info(int fd, __a_unused int argc, __a_unused char *argv[]) +int com_random_info(int fd, __a_unused int argc, __a_unused char * const * const argv) { return send_buffer(fd, "Don't use for huge directories as it is " "very inefficient in this case.\n"); diff --git a/server.h b/server.h index 0cdd0e60..9c98cf62 100644 --- a/server.h +++ b/server.h @@ -17,7 +17,7 @@ struct server_command { /** the name of the command */ const char *name; /** pointer to the function that handles the command */ - int (*handler)(int, int, char **); + int (*handler)(int, int, char * const * const); /** the privileges a user must have to execute this command */ unsigned int perms; /** one-line description of the command */ diff --git a/string.c b/string.c index 510592ab..60050ad7 100644 --- a/string.c +++ b/string.c @@ -319,7 +319,7 @@ __must_check __malloc char *para_homedir(void) * * \return The number of substrings found in \a args. */ -__must_check unsigned split_args(char *args, char ***argv_ptr, const char *delim) +__must_check unsigned split_args(char *args, char *** const argv_ptr, const char *delim) { char *p = args; char **argv; diff --git a/string.h b/string.h index 0c2090b3..a2dfa422 100644 --- a/string.h +++ b/string.h @@ -25,7 +25,7 @@ __must_check __malloc char *para_tmpname(void); __must_check int para_mkstemp(char *template, mode_t mode); __must_check __malloc char *para_logname(void); __must_check __malloc char *para_homedir(void); -__must_check unsigned split_args(char *args, char ***argv_ptr, const char *delim); +__must_check unsigned split_args(char *args, char *** const argv_ptr, const char *delim); __malloc char *para_hostname(void); void valid_fd_012(void); __printf_2_3 int para_printf(struct para_buffer *b, const char *fmt, ...);