From 59a4f545566f77a22a8c27ece5155ecd154d4145 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 12 May 2015 09:44:42 +0200 Subject: [PATCH] afs: Make afs callbacks more flexible. Currently we pass the information for callbacks (an int and a pointer to an osl_object) as separate arguments. If additional information must be passed to some callbacks, every callback must be modified to match the new prototype, even those which won't use the new argument. This commit introduces struct afs_callback_arg which contains the two callback arguments and changes all callbacks to receive a pointer to such a structure. This is an equivalent transformation with no visible change in semantics. With this commit in place it is easy to provide additional information by simply extending struct afs_callback as appropriate. --- afs.c | 20 ++++++------- afs.h | 15 +++++++--- aft.c | 85 +++++++++++++++++++++++++++-------------------------- attribute.c | 39 ++++++++++++------------ blob.c | 50 +++++++++++++++---------------- mood.c | 7 ++--- mood.h | 2 +- playlist.c | 7 ++--- 8 files changed, 118 insertions(+), 107 deletions(-) diff --git a/afs.c b/afs.c index fa750d21..30acfa04 100644 --- a/afs.c +++ b/afs.c @@ -588,17 +588,17 @@ void flush_and_free_pb(struct para_buffer *pb) free(pb->buf); } -static int com_select_callback(int fd, const struct osl_object *query) +static int com_select_callback(struct afs_callback_arg *aca) { struct para_buffer pb = { .max_size = shm_get_shmmax(), .private_data = &(struct afs_max_size_handler_data) { - .fd = fd, + .fd = aca->fd, .band = SBD_OUTPUT }, .max_size_handler = afs_max_size_handler, }; - char *arg = query->data; + char *arg = aca->query.data; int num_admissible, ret; ret = clear_score_table(); @@ -849,16 +849,16 @@ static int call_callback(int fd, int query_shmid) { void *query_shm; struct callback_query *cq; - struct osl_object query; int ret, ret2; + struct afs_callback_arg aca = {.fd = fd}; ret = shm_attach(query_shmid, ATTACH_RW, &query_shm); if (ret < 0) return ret; cq = query_shm; - query.data = (char *)query_shm + sizeof(*cq); - query.size = cq->query_size; - ret = cq->handler(fd, &query); + aca.query.data = (char *)query_shm + sizeof(*cq); + aca.query.size = cq->query_size; + ret = cq->handler(&aca); ret2 = shm_detach(query_shm); if (ret2 < 0) { if (ret < 0) /* ignore (but log) detach error */ @@ -1033,14 +1033,14 @@ out: exit(EXIT_FAILURE); } -static int com_init_callback(int fd, const struct osl_object *query) +static int com_init_callback(struct afs_callback_arg *aca) { - uint32_t table_mask = *(uint32_t *)query->data; + uint32_t table_mask = *(uint32_t *)aca->query.data; int i, ret; struct para_buffer pb = { .max_size = shm_get_shmmax(), .private_data = &(struct afs_max_size_handler_data) { - .fd = fd, + .fd = aca->fd, .band = SBD_OUTPUT } }; diff --git a/afs.h b/afs.h index fb704046..81012ff8 100644 --- a/afs.h +++ b/afs.h @@ -157,6 +157,13 @@ struct pattern_match_data { int (*action)(struct osl_table *table, struct osl_row *row, const char *name, void *data); }; +/** Arguments passed to each afs callback. */ +struct afs_callback_arg { + /** The local socket connecting afs and the command handler. */ + int fd; + /** Callback-specific data. */ + struct osl_object query; +}; /** * Afs command handlers run as a process which is not related to the afs @@ -166,7 +173,7 @@ struct pattern_match_data { * * \sa send_callback_request(). */ -typedef int afs_callback(int fd, const struct osl_object *); +typedef int afs_callback(struct afs_callback_arg *aca); /** * Callbacks send chunks to data back to the command handler. Pointers to @@ -242,7 +249,7 @@ void attribute_init(struct afs_table *t); void get_attribute_bitmap(const uint64_t *atts, char *buf); /* needed by com_ls() */ int get_attribute_bitnum_by_name(const char *att_name, unsigned char *bitnum); int get_attribute_text(uint64_t *atts, const char *delim, char **text); -int attribute_check_callback(int fd, __a_unused const struct osl_object *query); +int attribute_check_callback(struct afs_callback_arg *aca); /* aft */ void aft_init(struct afs_table *t); @@ -254,12 +261,12 @@ int get_afsi_of_row(const struct osl_row *row, struct afs_info *afsi); int get_afhi_of_row(const struct osl_row *row, struct afh_info *afhi); int get_audio_file_path_of_row(const struct osl_row *row, char **path); int audio_file_loop(void *private_data, osl_rbtree_loop_func *func); -int aft_check_callback(int fd, __a_unused const struct osl_object *query); +int aft_check_callback(struct afs_callback_arg *aca); /* playlist */ int playlist_open(char *name); void playlist_close(void); -int playlist_check_callback(int fd, __a_unused const struct osl_object *query); +int playlist_check_callback(struct afs_callback_arg *aca); /** evaluates to 1 if x < y, to -1 if x > y and to 0 if x == y */ #define NUM_COMPARE(x, y) ((int)((x) < (y)) - (int)((x) > (y))) diff --git a/aft.c b/aft.c index 3d5170cc..07d8805f 100644 --- a/aft.c +++ b/aft.c @@ -1293,16 +1293,16 @@ err: return ret; } -static int com_ls_callback(int fd, const struct osl_object *query) +static int com_ls_callback(struct afs_callback_arg *aca) { - struct ls_options *opts = query->data; - char *p, *pattern_start = (char *)query->data + sizeof(*opts); + struct ls_options *opts = aca->query.data; + char *p, *pattern_start = (char *)aca->query.data + sizeof(*opts); struct para_buffer b = { .max_size = shm_get_shmmax(), .flags = (opts->mode == LS_MODE_PARSER)? PBF_SIZE_PREFIX : 0, .max_size_handler = afs_max_size_handler, .private_data = &(struct afs_max_size_handler_data) { - .fd = fd, + .fd = aca->fd, .band = SBD_OUTPUT } }; @@ -1613,9 +1613,9 @@ enum com_add_flags { ADD_FLAG_ALL = 8, }; -static int com_add_callback(int fd, const struct osl_object *query) +static int com_add_callback(struct afs_callback_arg *aca) { - char *buf = query->data, *path; + char *buf = aca->query.data, *path; struct osl_row *pb, *aft_row; struct osl_row *hs; struct osl_object objs[NUM_AFT_COLUMNS]; @@ -1629,7 +1629,7 @@ static int com_add_callback(int fd, const struct osl_object *query) .max_size = shm_get_shmmax(), .max_size_handler = afs_max_size_handler, .private_data = &(struct afs_max_size_handler_data) { - .fd = fd, + .fd = aca->fd, .band = SBD_OUTPUT } }; @@ -1696,7 +1696,7 @@ static int com_add_callback(int fd, const struct osl_object *query) if (!objs[AFTCOL_AFHI].size) /* "impossible" */ goto out; objs[AFTCOL_CHUNKS].data = buf + chunks_offset; - objs[AFTCOL_CHUNKS].size = query->size - chunks_offset; + objs[AFTCOL_CHUNKS].size = aca->query.size - chunks_offset; if (pb && !hs) { /* update pb's hash */ char old_asc[2 * HASH_SIZE + 1]; unsigned char *old_hash; @@ -1756,26 +1756,26 @@ struct private_add_data { uint32_t flags; }; -static int path_brother_callback(int fd, const struct osl_object *query) +static int path_brother_callback(struct afs_callback_arg *aca) { - char *path = query->data; + char *path = aca->query.data; struct osl_row *path_brother; int ret = aft_get_row_of_path(path, &path_brother); if (ret < 0) return ret; - return pass_buffer_as_shm(fd, SBD_OUTPUT, (char *)&path_brother, + return pass_buffer_as_shm(aca->fd, SBD_OUTPUT, (char *)&path_brother, sizeof(path_brother)); } -static int hash_sister_callback(int fd, const struct osl_object *query) +static int hash_sister_callback(struct afs_callback_arg *aca) { - unsigned char *hash = query->data; + unsigned char *hash = aca->query.data; struct osl_row *hash_sister; hash_sister = find_hash_sister(hash); if (!hash_sister) return 0; - return pass_buffer_as_shm(fd, SBD_OUTPUT, (char *)&hash_sister, + return pass_buffer_as_shm(aca->fd, SBD_OUTPUT, (char *)&hash_sister, sizeof(hash_sister)); } @@ -2018,13 +2018,13 @@ static int touch_audio_file(__a_unused struct osl_table *table, return afs_event(AFSI_CHANGE, &tad->pb, &aced); } -static int com_touch_callback(int fd, const struct osl_object *query) +static int com_touch_callback(struct afs_callback_arg *aca) { - struct touch_action_data tad = {.cto = query->data, + struct touch_action_data tad = {.cto = aca->query.data, .pb = { .max_size = shm_get_shmmax(), .private_data = &(struct afs_max_size_handler_data) { - .fd = fd, + .fd = aca->fd, .band = SBD_OUTPUT }, .max_size_handler = afs_max_size_handler @@ -2035,8 +2035,8 @@ static int com_touch_callback(int fd, const struct osl_object *query) .table = audio_file_table, .loop_col_num = AFTCOL_HASH, .match_col_num = AFTCOL_PATH, - .patterns = {.data = (char *)query->data + sizeof(*tad.cto), - .size = query->size - sizeof(*tad.cto)}, + .patterns = {.data = (char *)aca->query.data + sizeof(*tad.cto), + .size = aca->query.size - sizeof(*tad.cto)}, .data = &tad, .action = touch_audio_file }; @@ -2155,13 +2155,13 @@ static int remove_audio_file(__a_unused struct osl_table *table, return ret; } -static int com_rm_callback(int fd, const struct osl_object *query) +static int com_rm_callback(struct afs_callback_arg *aca) { - struct com_rm_action_data crd = {.flags = *(uint32_t *)query->data, + struct com_rm_action_data crd = {.flags = *(uint32_t *)aca->query.data, .pb = { .max_size = shm_get_shmmax(), .private_data = &(struct afs_max_size_handler_data) { - .fd = fd, + .fd = aca->fd, .band = SBD_OUTPUT }, .max_size_handler = afs_max_size_handler @@ -2172,8 +2172,8 @@ static int com_rm_callback(int fd, const struct osl_object *query) .table = audio_file_table, .loop_col_num = AFTCOL_HASH, .match_col_num = AFTCOL_PATH, - .patterns = {.data = (char *)query->data + sizeof(uint32_t), - .size = query->size - sizeof(uint32_t)}, + .patterns = {.data = (char *)aca->query.data + sizeof(uint32_t), + .size = aca->query.size - sizeof(uint32_t)}, .data = &crd, .action = remove_audio_file }; @@ -2288,27 +2288,27 @@ static int copy_selector_info(__a_unused struct osl_table *table, return afs_event(AFSI_CHANGE, &cad->pb, &aced); } -static int com_cpsi_callback(int fd, const struct osl_object *query) +static int com_cpsi_callback(struct afs_callback_arg *aca) { struct cpsi_action_data cad = { - .flags = *(unsigned *)query->data, + .flags = *(unsigned *)aca->query.data, .pb = { .max_size = shm_get_shmmax(), .private_data = &(struct afs_max_size_handler_data) { - .fd = fd, + .fd = aca->fd, .band = SBD_OUTPUT }, .max_size_handler = afs_max_size_handler } }; int ret; - char *source_path = (char *)query->data + sizeof(cad.flags); + char *source_path = (char *)aca->query.data + sizeof(cad.flags); struct pattern_match_data pmd = { .table = audio_file_table, .loop_col_num = AFTCOL_HASH, .match_col_num = AFTCOL_PATH, .patterns = {.data = source_path + strlen(source_path) + 1, - .size = query->size - sizeof(cad.flags) + .size = aca->query.size - sizeof(cad.flags) - strlen(source_path) - 1}, .data = &cad, .action = copy_selector_info @@ -2409,7 +2409,7 @@ static int change_atts(__a_unused struct osl_table *table, return afs_event(AFSI_CHANGE, &cad->pb, &aced); } -static int com_setatt_callback(int fd, const struct osl_object *query) +static int com_setatt_callback(struct afs_callback_arg *aca) { char *p; int ret; @@ -2419,7 +2419,7 @@ static int com_setatt_callback(int fd, const struct osl_object *query) .max_size = shm_get_shmmax(), .max_size_handler = afs_max_size_handler, .private_data = &(struct afs_max_size_handler_data) { - .fd = fd, + .fd = aca->fd, .band = SBD_OUTPUT } } @@ -2433,7 +2433,11 @@ static int com_setatt_callback(int fd, const struct osl_object *query) .action = change_atts }; - for (p = query->data; p < (char *)query->data + query->size; p += len + 1) { + for ( + p = aca->query.data; + p < (char *)aca->query.data + aca->query.size; + p += len + 1 + ) { char c; unsigned char bitnum; @@ -2459,8 +2463,8 @@ static int com_setatt_callback(int fd, const struct osl_object *query) if (!cad.add_mask && !cad.del_mask) goto out; pmd.patterns.data = p; - assert(p < (char *)query->data + query->size); - pmd.patterns.size = (char *)query->data + query->size - p; + assert(p < (char *)aca->query.data + aca->query.size); + pmd.patterns.size = (char *)aca->query.data + aca->query.size - p; ret = for_each_matching_row(&pmd); if (ret < 0) goto out; @@ -2479,15 +2483,15 @@ int com_setatt(struct command_context *cc) com_setatt_callback, afs_cb_result_handler, cc); } -static int afs_stat_callback(int fd, const struct osl_object *query) +static int afs_stat_callback(struct afs_callback_arg *aca) { - int *parser_friendly = query->data; + int *parser_friendly = aca->query.data; char *buf = *parser_friendly? parser_friendly_status_items : status_items; if (!buf) return 0; - return pass_buffer_as_shm(fd, SBD_OUTPUT, buf, strlen(buf)); + return pass_buffer_as_shm(aca->fd, SBD_OUTPUT, buf, strlen(buf)); } /** @@ -2550,20 +2554,19 @@ static int check_audio_file(struct osl_row *row, void *data) /** * Check the audio file table for inconsistencies. * - * \param fd The afs socket. - * \param query Unused. + * \param aca Only ->pbout is used for diagnostics. * * \return Standard. Inconsistencies are reported but not regarded as an error. * * \sa com_check(). */ -int aft_check_callback(int fd, __a_unused const struct osl_object *query) +int aft_check_callback(struct afs_callback_arg *aca) { int ret; struct para_buffer pb = { .max_size = shm_get_shmmax(), .private_data = &(struct afs_max_size_handler_data) { - .fd = fd, + .fd = aca->fd, .band = SBD_OUTPUT }, .max_size_handler = afs_max_size_handler diff --git a/attribute.c b/attribute.c index f31da53a..313f7af9 100644 --- a/attribute.c +++ b/attribute.c @@ -149,15 +149,15 @@ static int print_attribute(struct osl_table *table, struct osl_row *row, return 1; } -static int com_lsatt_callback(int fd, const struct osl_object *query) +static int com_lsatt_callback(struct afs_callback_arg *aca) { int ret; struct lsatt_action_data laad = { - .flags = *(unsigned *) query->data, + .flags = *(unsigned *)aca->query.data, .pb = { .max_size = shm_get_shmmax(), .private_data = &(struct afs_max_size_handler_data) { - .fd = fd, + .fd = aca->fd, .band = SBD_OUTPUT }, .max_size_handler = afs_max_size_handler @@ -168,8 +168,8 @@ static int com_lsatt_callback(int fd, const struct osl_object *query) .table = attribute_table, .loop_col_num = ATTCOL_BITNUM, .match_col_num = ATTCOL_NAME, - .patterns = {.data = (char *)query->data + sizeof(laad.flags), - .size = query->size - sizeof(laad.flags)}, + .patterns = {.data = (char *)aca->query.data + sizeof(laad.flags), + .size = aca->query.size - sizeof(laad.flags)}, .pm_flags = PM_NO_PATTERN_MATCHES_EVERYTHING, .data = &laad, .action = print_attribute @@ -225,21 +225,25 @@ struct addatt_event_data { }; -static int com_addatt_callback(int fd, const struct osl_object *query) +static int com_addatt_callback(struct afs_callback_arg *aca) { char *p; int ret = 1; struct para_buffer pb = { .max_size = shm_get_shmmax(), .private_data = &(struct afs_max_size_handler_data) { - .fd = fd, + .fd = aca->fd, .band = SBD_OUTPUT }, .max_size_handler = afs_max_size_handler }; size_t len; - for (p = query->data; p < (char *)query->data + query->size; p += len + 1) { + for ( + p = aca->query.data; + p < (char *)aca->query.data + aca->query.size; + p += len + 1 + ) { struct osl_object objs[NUM_ATT_COLUMNS]; struct osl_row *row; unsigned char bitnum; @@ -305,9 +309,9 @@ int com_addatt(struct command_context *cc) return ret; } -static int com_mvatt_callback(int fd, const struct osl_object *query) +static int com_mvatt_callback(struct afs_callback_arg *aca) { - char *old = query->data; + char *old = aca->query.data; size_t size = strlen(old) + 1; char *new = old + size; struct osl_object obj = {.data = old, .size = size}; @@ -315,7 +319,7 @@ static int com_mvatt_callback(int fd, const struct osl_object *query) struct para_buffer pb = { .max_size = shm_get_shmmax(), .private_data = &(struct afs_max_size_handler_data) { - .fd = fd, + .fd = aca->fd, .band = SBD_OUTPUT }, .max_size_handler = afs_max_size_handler, @@ -366,12 +370,12 @@ static int remove_attribute(struct osl_table *table, struct osl_row *row, return afs_event(ATTRIBUTE_REMOVE, pb, &red); } -static int com_rmatt_callback(int fd, const struct osl_object *query) +static int com_rmatt_callback(struct afs_callback_arg *aca) { struct para_buffer pb = { .max_size = shm_get_shmmax(), .private_data = &(struct afs_max_size_handler_data) { - .fd = fd, + .fd = aca->fd, .band = SBD_OUTPUT }, .max_size_handler = afs_max_size_handler, @@ -379,7 +383,7 @@ static int com_rmatt_callback(int fd, const struct osl_object *query) int ret; struct pattern_match_data pmd = { .table = attribute_table, - .patterns = *query, + .patterns = aca->query, .loop_col_num = ATTCOL_BITNUM, .match_col_num = ATTCOL_NAME, .data = &pb, @@ -491,8 +495,7 @@ static int att_logical_or(struct osl_row *row, void *data) /** * Compute the attribute bit mask and check each afs info bitmap. * - * \param fd Needed for the para buffer. - * \param query Unused. + * \param aca The query field of \a aca is ignored. * * This iterates over all attributes in the attribute table and computes the * logical or of 1 << b where b is the bit number of the attribute. The @@ -503,14 +506,14 @@ static int att_logical_or(struct osl_row *row, void *data) * * \sa \ref aft_check_attributes(). */ -int attribute_check_callback(int fd, __a_unused const struct osl_object *query) +int attribute_check_callback(struct afs_callback_arg *aca) { int ret; uint64_t att_mask = 0; /* bits corresponding to a attributes */ struct para_buffer pb = { .max_size = shm_get_shmmax(), .private_data = &(struct afs_max_size_handler_data) { - .fd = fd, + .fd = aca->fd, .band = SBD_OUTPUT }, .max_size_handler = afs_max_size_handler, diff --git a/blob.c b/blob.c index 33a6f63b..0b5f1f9b 100644 --- a/blob.c +++ b/blob.c @@ -131,14 +131,14 @@ static int print_blob(struct osl_table *table, struct osl_row *row, } static int com_lsblob_callback(struct osl_table *table, - int fd, const struct osl_object *query) + struct afs_callback_arg *aca) { struct lsblob_action_data lbad = { - .flags = *(uint32_t *)query->data, + .flags = *(uint32_t *)aca->query.data, .pb = { .max_size = shm_get_shmmax(), .private_data = &(struct afs_max_size_handler_data) { - .fd = fd, + .fd = aca->fd, .band = SBD_OUTPUT }, .max_size_handler = afs_max_size_handler, @@ -146,8 +146,8 @@ static int com_lsblob_callback(struct osl_table *table, }; struct pattern_match_data pmd = { .table = table, - .patterns = {.data = (char *)query->data + sizeof(uint32_t), - .size = query->size - sizeof(uint32_t)}, + .patterns = {.data = (char *)aca->query.data + sizeof(uint32_t), + .size = aca->query.size - sizeof(uint32_t)}, .pm_flags = PM_NO_PATTERN_MATCHES_EVERYTHING | PM_SKIP_EMPTY_NAME, .match_col_num = BLOBCOL_NAME, .data = &lbad, @@ -220,17 +220,17 @@ static int cat_blob(struct osl_table *table, struct osl_row *row, return (ret < 0)? ret : ret2; } -static int com_catblob_callback(struct osl_table *table, int fd, - const struct osl_object *query) +static int com_catblob_callback(struct osl_table *table, + struct afs_callback_arg *aca) { int ret; struct pattern_match_data pmd = { .table = table, - .patterns = *query, + .patterns = aca->query, .loop_col_num = BLOBCOL_NAME, .match_col_num = BLOBCOL_NAME, .pm_flags = PM_SKIP_EMPTY_NAME, - .data = &fd, + .data = &aca->fd, .action = cat_blob }; ret = for_each_matching_row(&pmd); @@ -261,21 +261,21 @@ static int remove_blob(struct osl_table *table, struct osl_row *row, return 1; } -static int com_rmblob_callback(struct osl_table *table, int fd, - const struct osl_object *query) +static int com_rmblob_callback(struct osl_table *table, + struct afs_callback_arg *aca) { int ret; struct para_buffer pb = { .max_size = shm_get_shmmax(), .private_data = &(struct afs_max_size_handler_data) { - .fd = fd, + .fd = aca->fd, .band = SBD_OUTPUT }, .max_size_handler = afs_max_size_handler, }; struct pattern_match_data pmd = { .table = table, - .patterns = *query, + .patterns = aca->query, .loop_col_num = BLOBCOL_NAME, .match_col_num = BLOBCOL_NAME, .pm_flags = PM_SKIP_EMPTY_NAME, @@ -304,11 +304,11 @@ static int com_rmblob(afs_callback *f, struct command_context *cc) afs_cb_result_handler, cc); } -static int com_addblob_callback(struct osl_table *table, int fd, - const struct osl_object *query) +static int com_addblob_callback(struct osl_table *table, + struct afs_callback_arg *aca) { struct osl_object objs[NUM_BLOB_COLUMNS]; - char *name = query->data, *msg; + char *name = aca->query.data, *msg; size_t name_len = strlen(name) + 1, msg_len; uint32_t id; unsigned num_rows; @@ -342,7 +342,7 @@ static int com_addblob_callback(struct osl_table *table, int fd, goto out; id = *(uint32_t *)obj.data; obj.data = name + name_len; - obj.size = query->size - name_len; + obj.size = aca->query.size - name_len; ret = osl(osl_update_object(table, row, BLOBCOL_DEF, &obj)); goto out; } @@ -367,7 +367,7 @@ static int com_addblob_callback(struct osl_table *table, int fd, objs[BLOBCOL_NAME].data = name; objs[BLOBCOL_NAME].size = name_len; objs[BLOBCOL_DEF].data = name + name_len; - objs[BLOBCOL_DEF].size = query->size - name_len; + objs[BLOBCOL_DEF].size = aca->query.size - name_len; ret = osl(osl_add_row(table, objs)); if (ret < 0) goto out; @@ -377,7 +377,7 @@ out: msg_len = xasprintf(&msg, "cannot add %s\n", name); else msg_len = xasprintf(&msg, "added %s as id %u\n", name, id); - pass_buffer_as_shm(fd, SBD_OUTPUT, msg, msg_len); + pass_buffer_as_shm(aca->fd, SBD_OUTPUT, msg, msg_len); free(msg); return ret; } @@ -464,16 +464,16 @@ static int com_addblob(afs_callback *f, struct command_context *cc) return stdin_command(cc, &arg_obj, f); } -static int com_mvblob_callback(struct osl_table *table, int fd, - const struct osl_object *query) +static int com_mvblob_callback(struct osl_table *table, + struct afs_callback_arg *aca) { - char *src = (char *) query->data; + char *src = (char *)aca->query.data; struct osl_object obj = {.data = src, .size = strlen(src) + 1}; char *dest = src + obj.size; struct osl_row *row; struct para_buffer pb = { .max_size = shm_get_shmmax(), - .private_data = &fd, + .private_data = &aca->fd, .max_size_handler = afs_max_size_handler }; int ret = osl(osl_get_row(table, BLOBCOL_NAME, &obj, &row)); @@ -504,9 +504,9 @@ static int com_mvblob(afs_callback *f, struct command_context *cc) } #define DEFINE_BLOB_COMMAND(cmd_name, table_name, cmd_prefix) \ - static int com_ ## cmd_name ## cmd_prefix ## _callback(int fd, const struct osl_object *query) \ + static int com_ ## cmd_name ## cmd_prefix ## _callback(struct afs_callback_arg *aca) \ { \ - return com_ ## cmd_name ## blob_callback(table_name ## _table, fd, query); \ + return com_ ## cmd_name ## blob_callback(table_name ## _table, aca); \ } \ int com_ ## cmd_name ## cmd_prefix(struct command_context *cc) \ { \ diff --git a/mood.c b/mood.c index fb988b2f..639818c5 100644 --- a/mood.c +++ b/mood.c @@ -430,19 +430,18 @@ out: /** * Check all moods for syntax errors. * - * \param fd The afs socket. - * \param query Unused. + * \param aca Only ->pbout is used for diagnostics. * * \return Negative on fatal errors. Inconsistent mood definitions are not * considered an error. */ -int mood_check_callback(int fd, __a_unused const struct osl_object *query) +int mood_check_callback(struct afs_callback_arg *aca) { int ret; struct para_buffer pb = { .max_size = shm_get_shmmax(), .private_data = &(struct afs_max_size_handler_data) { - .fd = fd, + .fd = aca->fd, .band = SBD_OUTPUT }, .max_size_handler = afs_max_size_handler diff --git a/mood.h b/mood.h index 4ea10ef8..10e9319b 100644 --- a/mood.h +++ b/mood.h @@ -8,4 +8,4 @@ int change_current_mood(char *mood_name); void close_current_mood(void); -int mood_check_callback(int fd, __a_unused const struct osl_object *query); +int mood_check_callback(struct afs_callback_arg *aca); diff --git a/playlist.c b/playlist.c index e8037fbc..4b2d17c0 100644 --- a/playlist.c +++ b/playlist.c @@ -124,19 +124,18 @@ static int check_playlist(struct osl_row *row, void *data) /** * Check the playlist table for inconsistencies. * - * \param fd The afs socket. - * \param query Unused. + * \param aca This callback ignores ->query. * * \return Standard. Invalid paths are reported, but are not considered an * error. */ -int playlist_check_callback(int fd, __a_unused const struct osl_object *query) +int playlist_check_callback(struct afs_callback_arg *aca) { int ret; struct para_buffer pb = { .max_size = shm_get_shmmax(), .private_data = &(struct afs_max_size_handler_data) { - .fd = fd, + .fd = aca->fd, .band = SBD_OUTPUT }, .max_size_handler = afs_max_size_handler, -- 2.30.2