From: Andre Noll Date: Thu, 11 Jun 2009 22:35:15 +0000 (+0200) Subject: Fix para_strerror() and use osl() wrapper for osl library calls. X-Git-Tag: v0.4.0~75^2~9 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=6494f4bfddde1b9e06c4cb8bcd3acf7b9cc762f1;p=paraslash.git Fix para_strerror() and use osl() wrapper for osl library calls. --- diff --git a/aac_afh.c b/aac_afh.c index 80b50a4d..fdc22276 100644 --- a/aac_afh.c +++ b/aac_afh.c @@ -10,6 +10,7 @@ /** \file aac_afh.c para_server's aac audio format handler */ +#include #include "para.h" #include "error.h" #include "string.h" diff --git a/afs.c b/afs.c index 6b86cb0a..8e374f1e 100644 --- a/afs.c +++ b/afs.c @@ -8,6 +8,7 @@ #include #include +#include #include "server.cmdline.h" #include "para.h" #include "error.h" @@ -341,7 +342,7 @@ static int action_if_pattern_matches(struct osl_row *row, void *data) struct pattern_match_data *pmd = data; struct osl_object name_obj; const char *p, *name; - int ret = osl_get_object(pmd->table, row, pmd->match_col_num, &name_obj); + int ret = osl(osl_get_object(pmd->table, row, pmd->match_col_num, &name_obj)); const char *pattern_txt = (const char *)pmd->patterns.data; if (ret < 0) @@ -368,16 +369,15 @@ static int action_if_pattern_matches(struct osl_row *row, void *data) * * \param pmd Describes what to match and how. * - * \return The return value of the underlying call to osl_rbtree_loop() - * or osl_rbtree_loop_reverse(). + * \return Standard. */ int for_each_matching_row(struct pattern_match_data *pmd) { if (pmd->pm_flags & PM_REVERSE_LOOP) - return osl_rbtree_loop_reverse(pmd->table, pmd->loop_col_num, pmd, - action_if_pattern_matches); - return osl_rbtree_loop(pmd->table, pmd->loop_col_num, pmd, - action_if_pattern_matches); + return osl(osl_rbtree_loop_reverse(pmd->table, pmd->loop_col_num, pmd, + action_if_pattern_matches)); + return osl(osl_rbtree_loop(pmd->table, pmd->loop_col_num, pmd, + action_if_pattern_matches)); } /** diff --git a/afs.h b/afs.h index d20b6f20..a58518bb 100644 --- a/afs.h +++ b/afs.h @@ -7,7 +7,6 @@ /** \file afs.h Exported symbols of the audio file selector. */ #include -#include #include "hash.h" /** Audio file selector data stored in the audio file table. */ diff --git a/aft.c b/aft.c index 12424c40..db4c494d 100644 --- a/aft.c +++ b/aft.c @@ -7,6 +7,7 @@ /** \file aft.c Audio file table functions. */ #include /* readdir() */ +#include #include "para.h" #include "error.h" #include "string.h" @@ -432,13 +433,13 @@ static void load_chunk_table(struct afh_info *afhi, char *buf) * \param path The full path of the audio file. * \param row Result pointer. * - * \return The return value of the underlying call to osl_get_row(). + * \return Standard. */ int aft_get_row_of_path(const char *path, struct osl_row **row) { struct osl_object obj = {.data = (char *)path, .size = strlen(path) + 1}; - return osl_get_row(audio_file_table, AFTCOL_PATH, &obj, row); + return osl(osl_get_row(audio_file_table, AFTCOL_PATH, &obj, row)); } /** @@ -447,12 +448,12 @@ int aft_get_row_of_path(const char *path, struct osl_row **row) * \param hash The hash value of the desired audio file. * \param row resul pointer. * - * \return The return value of the underlying call to osl_get_row(). + * \return Standard. */ int aft_get_row_of_hash(HASH_TYPE *hash, struct osl_row **row) { const struct osl_object obj = {.data = hash, .size = HASH_SIZE}; - return osl_get_row(audio_file_table, AFTCOL_HASH, &obj, row); + return osl(osl_get_row(audio_file_table, AFTCOL_HASH, &obj, row)); } /** @@ -461,11 +462,11 @@ int aft_get_row_of_hash(HASH_TYPE *hash, struct osl_row **row) * \param row Pointer to a row in the audio file table. * \param obj Result pointer. * - * \return The return value of the underlying call to osl_get_object(). + * \return Standard. */ int get_afsi_object_of_row(const struct osl_row *row, struct osl_object *obj) { - return osl_get_object(audio_file_table, row, AFTCOL_AFSI, obj); + return osl(osl_get_object(audio_file_table, row, AFTCOL_AFSI, obj)); } /** @@ -534,8 +535,8 @@ int get_afsi_of_path(const char *path, struct afs_info *afsi) int get_audio_file_path_of_row(const struct osl_row *row, char **path) { struct osl_object path_obj; - int ret = osl_get_object(audio_file_table, row, AFTCOL_PATH, - &path_obj); + int ret = osl(osl_get_object(audio_file_table, row, AFTCOL_PATH, + &path_obj)); if (ret < 0) return ret; *path = path_obj.data; @@ -552,9 +553,10 @@ int get_audio_file_path_of_row(const struct osl_row *row, char **path) * * \sa get_hash_of_row(). */ -static int get_hash_object_of_aft_row(const struct osl_row *row, struct osl_object *obj) +static int get_hash_object_of_aft_row(const struct osl_row *row, + struct osl_object *obj) { - return osl_get_object(audio_file_table, row, AFTCOL_HASH, obj); + return osl(osl_get_object(audio_file_table, row, AFTCOL_HASH, obj)); } /** @@ -592,8 +594,8 @@ static int get_hash_of_row(const struct osl_row *row, HASH_TYPE **hash) int get_afhi_of_row(const struct osl_row *row, struct afh_info *afhi) { struct osl_object obj; - int ret = osl_get_object(audio_file_table, row, AFTCOL_AFHI, - &obj); + int ret = osl(osl_get_object(audio_file_table, row, AFTCOL_AFHI, + &obj)); if (ret < 0) return ret; load_afhi(obj.data, afhi); @@ -1383,8 +1385,8 @@ static void com_ls_callback(int fd, const struct osl_object *query) if (opts->flags & LS_FLAG_ADMISSIBLE_ONLY) ret = admissible_file_loop(opts, prepare_ls_row); else - ret = osl_rbtree_loop(audio_file_table, AFTCOL_PATH, opts, - prepare_ls_row); + ret = osl(osl_rbtree_loop(audio_file_table, AFTCOL_PATH, opts, + prepare_ls_row)); if (ret < 0) goto out; if (!opts->num_matching_paths) @@ -1532,12 +1534,12 @@ int com_ls(int fd, int argc, char * const * const argv) * \param private_data An arbitrary data pointer, passed to \a func. * \param func The custom function to be called. * - * \return The return value of the underlying call to osl_rbtree_loop(). + * \return Standard. */ int audio_file_loop(void *private_data, osl_rbtree_loop_func *func) { - return osl_rbtree_loop(audio_file_table, AFTCOL_HASH, private_data, - func); + return osl(osl_rbtree_loop(audio_file_table, AFTCOL_HASH, private_data, + func)); } static struct osl_row *find_hash_sister(HASH_TYPE *hash) @@ -1697,7 +1699,7 @@ static void com_add_callback(int fd, const struct osl_object *query) PARA_INFO_LOG("request to add %s\n", path); hs = find_hash_sister(hash); ret = aft_get_row_of_path(path, &pb); - if (ret < 0 && ret != -E_OSL_RB_KEY_NOT_FOUND) + if (ret < 0 && ret != -OSL_ERRNO_TO_PARA_ERROR(E_OSL_RB_KEY_NOT_FOUND)) goto out; if (hs && pb && hs == pb && !(flags & ADD_FLAG_FORCE)) { if (flags & ADD_FLAG_VERBOSE) @@ -1714,23 +1716,23 @@ static void com_add_callback(int fd, const struct osl_object *query) if (ret < 0) goto out; } - ret = osl_del_row(audio_file_table, pb); + ret = osl(osl_del_row(audio_file_table, pb)); if (ret < 0) goto out; pb = NULL; } /* file rename, update hs' path */ if (flags & ADD_FLAG_VERBOSE) { - ret = osl_get_object(audio_file_table, hs, - AFTCOL_PATH, &obj); + ret = osl(osl_get_object(audio_file_table, hs, + AFTCOL_PATH, &obj)); if (ret < 0) goto out; ret = para_printf(&msg, "renamed from %s\n", (char *)obj.data); if (ret < 0) goto out; } - ret = osl_update_object(audio_file_table, hs, AFTCOL_PATH, - &objs[AFTCOL_PATH]); + ret = osl(osl_update_object(audio_file_table, hs, AFTCOL_PATH, + &objs[AFTCOL_PATH])); if (ret < 0) goto out; afs_event(AUDIO_FILE_RENAME, &msg, hs); @@ -1774,12 +1776,12 @@ static void com_add_callback(int fd, const struct osl_object *query) if (ret < 0) goto out; } - ret = osl_update_object(audio_file_table, row, AFTCOL_AFHI, - &objs[AFTCOL_AFHI]); + ret = osl(osl_update_object(audio_file_table, row, AFTCOL_AFHI, + &objs[AFTCOL_AFHI])); if (ret < 0) goto out; - ret = osl_update_object(audio_file_table, row, AFTCOL_CHUNKS, - &objs[AFTCOL_CHUNKS]); + ret = osl(osl_update_object(audio_file_table, row, AFTCOL_CHUNKS, + &objs[AFTCOL_CHUNKS])); if (ret < 0) goto out; afs_event(AFHI_CHANGE, &msg, row); @@ -1797,7 +1799,7 @@ static void com_add_callback(int fd, const struct osl_object *query) objs[AFTCOL_AFSI].data = &afsi_buf; objs[AFTCOL_AFSI].size = AFSI_SIZE; save_afsi(&default_afsi, &objs[AFTCOL_AFSI]); - ret = osl_add_and_get_row(audio_file_table, objs, &aft_row); + ret = osl(osl_add_and_get_row(audio_file_table, objs, &aft_row)); afs_event(AUDIO_FILE_ADD, &msg, aft_row); out: if (ret < 0) @@ -1860,7 +1862,7 @@ static int add_one_audio_file(const char *path, void *private_data) query.size = strlen(path) + 1; ret = send_callback_request(path_brother_callback, &query, get_row_pointer_from_result, &pb); - if (ret < 0 && ret != -E_OSL_RB_KEY_NOT_FOUND) + if (ret < 0 && ret != -OSL_ERRNO_TO_PARA_ERROR(E_OSL_RB_KEY_NOT_FOUND)) goto out_free; ret = 1; if (pb && (pad->flags & ADD_FLAG_LAZY)) { /* lazy is really cheap */ @@ -2224,7 +2226,7 @@ static int remove_audio_file(__a_unused struct osl_table *table, return ret; } afs_event(AUDIO_FILE_REMOVE, &crd->pb, row); - ret = osl_del_row(audio_file_table, row); + ret = osl(osl_del_row(audio_file_table, row)); if (ret < 0) para_printf(&crd->pb, "%s: %s\n", name, para_strerror(-ret)); else @@ -2563,7 +2565,7 @@ static int aft_open(const char *dir) int ret; audio_file_table_desc.dir = dir; - ret = osl_open_table(&audio_file_table_desc, &audio_file_table); + ret = osl(osl_open_table(&audio_file_table_desc, &audio_file_table)); if (ret >= 0) { unsigned num; osl_get_num_rows(audio_file_table, &num); @@ -2580,7 +2582,7 @@ static int aft_open(const char *dir) static int aft_create(const char *dir) { audio_file_table_desc.dir = dir; - return osl_create_table(&audio_file_table_desc); + return osl(osl_create_table(&audio_file_table_desc)); } static int clear_attribute(struct osl_row *row, void *data) diff --git a/attribute.c b/attribute.c index ec2eae73..4784aee9 100644 --- a/attribute.c +++ b/attribute.c @@ -5,6 +5,7 @@ */ /** \file attribute.c Attribute handling functions. */ +#include #include "para.h" #include "error.h" #include "string.h" @@ -89,11 +90,11 @@ int get_attribute_bitnum_by_name(const char *att_name, unsigned char *bitnum) struct osl_object obj = {.data = (char *)att_name, .size = strlen(att_name) + 1}; struct osl_row *row; - int ret = osl_get_row(attribute_table, ATTCOL_NAME, &obj, &row); + int ret = osl(osl_get_row(attribute_table, ATTCOL_NAME, &obj, &row)); if (ret < 0) return ret; - ret = osl_get_object(attribute_table, row, ATTCOL_BITNUM, &obj); + ret = osl(osl_get_object(attribute_table, row, ATTCOL_BITNUM, &obj)); if (ret < 0) return ret; *bitnum = *(unsigned char *)obj.data; @@ -131,7 +132,7 @@ static int print_attribute(struct osl_table *table, struct osl_row *row, if (!(laad->flags & LSATT_FLAG_LONG)) return para_printf(&laad->pb, "%s\n", name); - ret = osl_get_object(table, row, ATTCOL_BITNUM, &bitnum_obj); + ret = osl(osl_get_object(table, row, ATTCOL_BITNUM, &bitnum_obj)); if (ret < 0) { para_printf(&laad->pb, "%s: %s\n", name, para_strerror(-ret)); return ret; @@ -230,11 +231,11 @@ static void com_setatt_callback(__a_unused int fd, const struct osl_object *quer p[len - 1] = '\0'; obj.data = p; obj.size = len + 1; - ret = osl_get_row(attribute_table, ATTCOL_NAME, &obj, &row); + ret = osl(osl_get_row(attribute_table, ATTCOL_NAME, &obj, &row)); if (ret < 0) goto out; - ret = osl_get_object(attribute_table, row, ATTCOL_BITNUM, - &obj); + ret = osl(osl_get_object(attribute_table, row, ATTCOL_BITNUM, + &obj)); if (ret < 0) goto out; if (c == '+') @@ -317,15 +318,15 @@ static void com_addatt_callback(int fd, const struct osl_object *query) goto out; continue; } - if (ret != -E_OSL_RB_KEY_NOT_FOUND) /* error */ + if (ret != -OSL_ERRNO_TO_PARA_ERROR(E_OSL_RB_KEY_NOT_FOUND)) /* error */ goto out; objs[ATTCOL_BITNUM].size = 1; /* find smallest unused attribute */ for (bitnum = 0; bitnum < 64; bitnum++) { objs[ATTCOL_BITNUM].data = &bitnum; - ret = osl_get_row(attribute_table, ATTCOL_BITNUM, - &objs[ATTCOL_BITNUM], &row); - if (ret == -E_OSL_RB_KEY_NOT_FOUND) + ret = osl(osl_get_row(attribute_table, ATTCOL_BITNUM, + &objs[ATTCOL_BITNUM], &row)); + if (ret == -OSL_ERRNO_TO_PARA_ERROR(E_OSL_RB_KEY_NOT_FOUND)) break; /* this bitnum is unused, use it */ if (ret < 0) /* error */ goto out; @@ -337,7 +338,7 @@ static void com_addatt_callback(int fd, const struct osl_object *query) } objs[ATTCOL_NAME].data = p; objs[ATTCOL_NAME].size = len + 1; - ret = osl_add_row(attribute_table, objs); + ret = osl(osl_add_row(attribute_table, objs)); if (ret < 0) goto out; aed.name = p; @@ -380,12 +381,12 @@ static void com_mvatt_callback(int fd, const struct osl_object *query) }; int ret; - ret = osl_get_row(attribute_table, ATTCOL_NAME, &obj, &row); + ret = osl(osl_get_row(attribute_table, ATTCOL_NAME, &obj, &row)); if (ret < 0) goto out; obj.data = new; obj.size = strlen(new) + 1; - ret = osl_update_object(attribute_table, row, ATTCOL_NAME, &obj); + ret = osl(osl_update_object(attribute_table, row, ATTCOL_NAME, &obj)); out: if (ret < 0) para_printf(&pb, "%s\n", para_strerror(-ret)); @@ -429,7 +430,7 @@ static int remove_attribute(struct osl_table *table, struct osl_row *row, ret = get_attribute_bitnum_by_name(name, &red.bitnum); if (ret < 0) return para_printf(&raad->pb, "%s: %s\n", name, para_strerror(-ret)); - ret = osl_del_row(table, row); + ret = osl(osl_del_row(table, row)); if (ret < 0) return para_printf(&raad->pb, "%s: %s\n", name, para_strerror(-ret)); ret = para_printf(&raad->pb, "removed attribute %s\n", name); @@ -533,10 +534,10 @@ int get_attribute_text(uint64_t *atts, const char *delim, char **text) if (!(*atts & (one << i))) continue; - ret = osl_get_row(attribute_table, ATTCOL_BITNUM, &obj, &row); + ret = osl(osl_get_row(attribute_table, ATTCOL_BITNUM, &obj, &row)); if (ret < 0) goto err; - ret = osl_get_object(attribute_table, row, ATTCOL_NAME, &obj); + ret = osl(osl_get_object(attribute_table, row, ATTCOL_NAME, &obj)); if (ret < 0) goto err; if (*text) { @@ -579,7 +580,7 @@ static int attribute_open(const char *dir) int ret; attribute_table_desc.dir = dir; - ret = osl_open_table(&attribute_table_desc, &attribute_table); + ret = osl(osl_open_table(&attribute_table_desc, &attribute_table)); greatest_att_bitnum = -1; /* no atts available */ if (ret >= 0) { find_greatest_att_bitnum(); @@ -594,7 +595,7 @@ static int attribute_open(const char *dir) static int attribute_create(const char *dir) { attribute_table_desc.dir = dir; - return osl_create_table(&attribute_table_desc); + return osl(osl_create_table(&attribute_table_desc)); } /** diff --git a/blob.c b/blob.c index 5ac35895..f635eb0d 100644 --- a/blob.c +++ b/blob.c @@ -7,6 +7,7 @@ /** \file blob.c Macros and functions for blob handling. */ #include +#include #include "para.h" #include "error.h" #include "string.h" @@ -94,7 +95,7 @@ static int print_blob(struct osl_table *table, struct osl_row *row, if (!(lbad->flags & BLOB_LS_FLAG_LONG)) return para_printf(&lbad->pb, "%s\n", name); - ret = osl_get_object(table, row, BLOBCOL_ID, &obj); + ret = osl(osl_get_object(table, row, BLOBCOL_ID, &obj)); if (ret < 0) { para_printf(&lbad->pb, "%s: %s\n", name, para_strerror(-ret)); return ret; @@ -179,12 +180,12 @@ static int cat_blob(struct osl_table *table, struct osl_row *row, int ret = 0, ret2; struct osl_object obj; - ret = osl_open_disk_object(table, row, BLOBCOL_DEF, &obj); + ret = osl(osl_open_disk_object(table, row, BLOBCOL_DEF, &obj)); if (ret < 0) return ret; if (obj.size) ret = pass_buffer_as_shm(obj.data, obj.size, data); - ret2 = osl_close_disk_object(&obj); + ret2 = osl(osl_close_disk_object(&obj)); return (ret < 0)? ret : ret2; } @@ -223,7 +224,7 @@ static int remove_blob(struct osl_table *table, struct osl_row *row, const char *name, void *data) { struct rmblob_data *rmbd = data; - int ret = osl_del_row(table, row); + int ret = osl(osl_del_row(table, row)); if (ret < 0) { para_printf(&rmbd->pb, "%s: %s\n", name, para_strerror(-ret)); return ret; @@ -290,7 +291,7 @@ static void com_addblob_callback(struct osl_table *table, __a_unused int fd, unsigned num_rows; int ret; - ret = osl_get_num_rows(table, &num_rows); + ret = osl(osl_get_num_rows(table, &num_rows)); if (ret < 0) goto out; if (!num_rows) { /* this is the first entry ever added */ @@ -302,34 +303,34 @@ static void com_addblob_callback(struct osl_table *table, __a_unused int fd, objs[BLOBCOL_NAME].size = 1; objs[BLOBCOL_DEF].data = ""; objs[BLOBCOL_DEF].size = 1; - ret = osl_add_row(table, objs); + ret = osl(osl_add_row(table, objs)); if (ret < 0) goto out; } else { /* check if name already exists */ struct osl_row *row; struct osl_object obj = {.data = name, .size = name_len}; - ret = osl_get_row(table, BLOBCOL_NAME, &obj, &row); - if (ret < 0 && ret != -E_OSL_RB_KEY_NOT_FOUND) + ret = osl(osl_get_row(table, BLOBCOL_NAME, &obj, &row)); + if (ret < 0 && ret != -OSL_ERRNO_TO_PARA_ERROR(E_OSL_RB_KEY_NOT_FOUND)) goto out; if (ret >= 0) { /* we already have a blob with this name */ obj.data = name + name_len; obj.size = query->size - name_len; - ret = osl_update_object(table, row, BLOBCOL_DEF, &obj); + ret = osl(osl_update_object(table, row, BLOBCOL_DEF, &obj)); goto out; } /* new blob, get id of the dummy row and increment it */ obj.data = ""; obj.size = 1; - ret = osl_get_row(table, BLOBCOL_NAME, &obj, &row); + ret = osl(osl_get_row(table, BLOBCOL_NAME, &obj, &row)); if (ret < 0) goto out; - ret = osl_get_object(table, row, BLOBCOL_ID, &obj); + ret = osl(osl_get_object(table, row, BLOBCOL_ID, &obj)); if (ret < 0) goto out; id = *(uint32_t *)obj.data + 1; obj.data = &id; - ret = osl_update_object(table, row, BLOBCOL_ID, &obj); + ret = osl(osl_update_object(table, row, BLOBCOL_ID, &obj)); if (ret < 0) goto out; } @@ -340,7 +341,7 @@ static void com_addblob_callback(struct osl_table *table, __a_unused int fd, objs[BLOBCOL_NAME].size = name_len; objs[BLOBCOL_DEF].data = name + name_len; objs[BLOBCOL_DEF].size = query->size - name_len; - ret = osl_add_row(table, objs); + ret = osl(osl_add_row(table, objs)); if (ret < 0) goto out; afs_event(BLOB_ADD, NULL, table); @@ -371,13 +372,13 @@ static void com_mvblob_callback(struct osl_table *table, __a_unused int fd, struct osl_object obj = {.data = src, .size = strlen(src) + 1}; char *dest = src + obj.size; struct osl_row *row; - int ret = osl_get_row(table, BLOBCOL_NAME, &obj, &row); + int ret = osl(osl_get_row(table, BLOBCOL_NAME, &obj, &row)); if (ret < 0) goto out; obj.data = dest; obj.size = strlen(dest) + 1; - ret = osl_update_object(table, row, BLOBCOL_NAME, &obj); + ret = osl(osl_update_object(table, row, BLOBCOL_NAME, &obj)); if (ret < 0) goto out; afs_event(BLOB_RENAME, NULL, table); @@ -415,10 +416,10 @@ static int blob_get_name_by_id(struct osl_table *table, uint32_t id, *name = NULL; if (!id) return 1; - ret = osl_get_row(table, BLOBCOL_ID, &obj, &row); + ret = osl(osl_get_row(table, BLOBCOL_ID, &obj, &row)); if (ret < 0) return ret; - ret = osl_get_object(table, row, BLOBCOL_NAME, &obj); + ret = osl(osl_get_object(table, row, BLOBCOL_NAME, &obj)); if (ret < 0) return ret; *name = (char *)obj.data; @@ -443,10 +444,10 @@ static int blob_get_def_by_name(struct osl_table *table, char *name, def->data = NULL; if (!*name) return 1; - ret = osl_get_row(table, BLOBCOL_NAME, &obj, &row); + ret = osl(osl_get_row(table, BLOBCOL_NAME, &obj, &row)); if (ret < 0) return ret; - return osl_open_disk_object(table, row, BLOBCOL_DEF, def); + return osl(osl_open_disk_object(table, row, BLOBCOL_DEF, def)); } /** Define the \p get_def_by_id function for this blob type. */ @@ -466,10 +467,10 @@ static int blob_get_def_by_id(struct osl_table *table, uint32_t id, def->data = NULL; if (!id) return 1; - ret = osl_get_row(table, BLOBCOL_ID, &obj, &row); + ret = osl(osl_get_row(table, BLOBCOL_ID, &obj, &row)); if (ret < 0) return ret; - return osl_open_disk_object(table, row, BLOBCOL_DEF, def); + return osl(osl_open_disk_object(table, row, BLOBCOL_DEF, def)); } /** Define the \p get_def_by_id function for this blob type. */ @@ -483,11 +484,11 @@ static int blob_get_name_and_def_by_row(struct osl_table *table, const struct osl_row *row, char **name, struct osl_object *def) { struct osl_object obj; - int ret = osl_get_object(table, row, BLOBCOL_NAME, &obj); + int ret = osl(osl_get_object(table, row, BLOBCOL_NAME, &obj)); if (ret < 0) return ret; *name = obj.data; - return osl_open_disk_object(table, row, BLOBCOL_DEF, def); + return osl(osl_open_disk_object(table, row, BLOBCOL_DEF, def)); } /** Define the \p get_name_and_def_by_row function for this blob type. */ #define DEFINE_GET_NAME_AND_DEF_BY_ROW(table_name, cmd_prefix) \ @@ -520,7 +521,7 @@ static int blob_open(struct osl_table **table, { int ret; desc->dir = dir; - ret = osl_open_table(desc, table); + ret = osl(osl_open_table(desc, table)); if (ret >= 0) return ret; *table = NULL; diff --git a/command.c b/command.c index 1ca54da9..603715b4 100644 --- a/command.c +++ b/command.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "para.h" #include "error.h" diff --git a/dccp_send.c b/dccp_send.c index 9b72b7c9..1e62d289 100644 --- a/dccp_send.c +++ b/dccp_send.c @@ -13,6 +13,7 @@ #include #include +#include #include "para.h" #include "error.h" diff --git a/error.h b/error.h index ba18c6dc..fb46ec54 100644 --- a/error.h +++ b/error.h @@ -6,8 +6,6 @@ /** \file error.h List of error messages for all subsystems. */ -#include - /** \cond */ /* List of all subsystems that use paraslash's error facility. */ @@ -483,8 +481,10 @@ _static_inline_ int is_errno(int num, int _errno) _static_inline_ const char *para_strerror(int num) { assert(num > 0); +#ifdef _OSL_H if (IS_OSL_ERROR(num)) return osl_strerror(num & ((1 << OSL_ERROR_BIT) - 1)); +#endif if (IS_SYSTEM_ERROR(num)) return strerror(num & ((1 << SYSTEM_ERROR_BIT) - 1)); return para_errlist[ERRNUM_TO_SS(num)][ERRNUM_TO_INDEX(num)]; @@ -496,10 +496,10 @@ _static_inline_ const char *para_strerror(int num) * \param ret The return value of an osl library function. * * This should be used for all calls to osl functions that return an osl error - * code. It changes the return value to \p -E_OSL appropriately so that it can - * be used for printing the correct error message. + * code. It changes the return value appropriately so that it can be used for + * printing the correct error message vi para_strerror(). * - * \return \a ret if \a ret >= 0, \p -E_OSL otherwise. + * \return \a ret if \a ret >= 0, a paraslash error code otherwise. */ _static_inline_ int osl(int ret) { @@ -508,7 +508,6 @@ _static_inline_ int osl(int ret) return OSL_ERRNO_TO_PARA_ERROR(-ret); } - /** * Define the error list for one subsystem. # diff --git a/http_send.c b/http_send.c index 5b98bbf4..feb1a842 100644 --- a/http_send.c +++ b/http_send.c @@ -8,6 +8,7 @@ #include #include +#include #include "para.h" #include "error.h" diff --git a/mood.c b/mood.c index 540d0c70..feeae8bd 100644 --- a/mood.c +++ b/mood.c @@ -7,6 +7,7 @@ /** \file mood.c Paraslash's mood handling functions. */ #include +#include #include "para.h" #include "error.h" #include "string.h" @@ -972,7 +973,7 @@ int change_current_mood(char *mood_name) .data = mood_name, .size = strlen(mood_name) + 1 }; - ret = osl_get_row(moods_table, BLOBCOL_NAME, &obj, &row); + ret = osl(osl_get_row(moods_table, BLOBCOL_NAME, &obj, &row)); if (ret < 0) { PARA_NOTICE_LOG("no such mood: %s\n", mood_name); return ret; diff --git a/mp3_afh.c b/mp3_afh.c index 2d18d5e5..969a230c 100644 --- a/mp3_afh.c +++ b/mp3_afh.c @@ -16,6 +16,7 @@ * Johannes Overmann */ +#include #include "para.h" #include "error.h" #include "afh.h" diff --git a/ogg_afh.c b/ogg_afh.c index 55cf4ced..40aa6b64 100644 --- a/ogg_afh.c +++ b/ogg_afh.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "para.h" #include "afh.h" diff --git a/playlist.c b/playlist.c index a9925cd3..d1e16f8e 100644 --- a/playlist.c +++ b/playlist.c @@ -4,6 +4,7 @@ * Licensed under the GPL v2. For licencing details see COPYING. */ +#include #include "para.h" #include "error.h" #include "string.h" @@ -174,7 +175,7 @@ int playlist_open(char *name) obj.data = name; obj.size = strlen(obj.data); - ret = osl_get_row(playlists_table, BLOBCOL_NAME, &obj, &row); + ret = osl(osl_get_row(playlists_table, BLOBCOL_NAME, &obj, &row)); if (ret < 0) { PARA_NOTICE_LOG("failed to load playlist %s\n", name); return ret; diff --git a/score.c b/score.c index 89a0fbe9..3557b042 100644 --- a/score.c +++ b/score.c @@ -5,6 +5,7 @@ */ /** \file score.c Scoring functions to determine the audio file streaming order. */ +#include #include "para.h" #include "error.h" #include "string.h" @@ -93,7 +94,7 @@ static struct osl_table_description score_table_desc = { */ int get_num_admissible_files(unsigned *num) { - return osl_get_num_rows(score_table, num); + return osl(osl_get_num_rows(score_table, num)); } /** @@ -109,7 +110,7 @@ int get_num_admissible_files(unsigned *num) static int get_score_of_row(void *score_row, long *score) { struct osl_object obj; - int ret = osl_get_object(score_table, score_row, SCORECOL_SCORE, &obj); + int ret = osl(osl_get_object(score_table, score_row, SCORECOL_SCORE, &obj)); if (ret >= 0) *score = *(long *)obj.data; @@ -141,7 +142,7 @@ int score_add(const struct osl_row *aft_row, long score) *(int *)(score_objs[SCORECOL_SCORE].data) = score; // PARA_DEBUG_LOG("adding %p\n", *(void **) (score_objs[SCORECOL_AFT_ROW].data)); - ret = osl_add_row(score_table, score_objs); + ret = osl(osl_add_row(score_table, score_objs)); if (ret < 0) { PARA_ERROR_LOG("%s\n", para_strerror(-ret)); free(score_objs[SCORECOL_SCORE].data); @@ -152,7 +153,7 @@ int score_add(const struct osl_row *aft_row, long score) static int get_nth_score(unsigned n, long *score) { struct osl_row *row; - int ret = osl_get_nth_row(score_table, SCORECOL_SCORE, n, &row); + int ret = osl(osl_get_nth_row(score_table, SCORECOL_SCORE, n, &row)); if (ret < 0) return ret; @@ -180,9 +181,9 @@ int score_update(const struct osl_row *aft_row, long percent) unsigned n, new_pos; struct osl_object obj = {.data = (struct osl_row *)aft_row, .size = sizeof(aft_row)}; - int ret = osl_get_row(score_table, SCORECOL_AFT_ROW, &obj, &row); + int ret = osl(osl_get_row(score_table, SCORECOL_AFT_ROW, &obj, &row)); - if (ret == -E_OSL_RB_KEY_NOT_FOUND) /* not an error */ + if (ret == -OSL_ERRNO_TO_PARA_ERROR(E_OSL_RB_KEY_NOT_FOUND)) /* not an error */ return 1; if (ret < 0) return ret; @@ -198,7 +199,7 @@ int score_update(const struct osl_row *aft_row, long percent) obj.data = para_malloc(obj.size); *(long *)obj.data = new_score; PARA_DEBUG_LOG("new score: %ld, rank %u/%u\n", new_score, new_pos, n); - return osl_update_object(score_table, row, SCORECOL_SCORE, &obj); + return osl(osl_update_object(score_table, row, SCORECOL_SCORE, &obj)); } /** @@ -219,7 +220,7 @@ int get_score_and_aft_row(struct osl_row *score_row, long *score, if (ret < 0) return ret; - ret = osl_get_object(score_table, score_row, SCORECOL_AFT_ROW, &obj); + ret = osl(osl_get_object(score_table, score_row, SCORECOL_AFT_ROW, &obj)); if (ret < 0) return ret; *aft_row = obj.data; @@ -231,8 +232,7 @@ static int get_score_row_from_aft_row(const struct osl_row *aft_row, { struct osl_object obj = {.data = (struct osl_row *)aft_row, .size = sizeof(aft_row)}; - return osl_get_row(score_table, SCORECOL_AFT_ROW, &obj, score_row); - + return osl(osl_get_row(score_table, SCORECOL_AFT_ROW, &obj, score_row)); } /** @@ -250,7 +250,7 @@ static int get_score_row_from_aft_row(const struct osl_row *aft_row, */ int admissible_file_loop(void *data, osl_rbtree_loop_func *func) { - return osl_rbtree_loop(score_table, SCORECOL_SCORE, data, func); + return osl(osl_rbtree_loop(score_table, SCORECOL_SCORE, data, func)); } /** @@ -265,7 +265,7 @@ int admissible_file_loop(void *data, osl_rbtree_loop_func *func) */ int admissible_file_loop_reverse(void *data, osl_rbtree_loop_func *func) { - return osl_rbtree_loop_reverse(score_table, SCORECOL_SCORE, data, func); + return osl(osl_rbtree_loop_reverse(score_table, SCORECOL_SCORE, data, func)); } /** @@ -281,11 +281,11 @@ int score_get_best(struct osl_row **aft_row, long *score) { struct osl_row *row; struct osl_object obj; - int ret = osl_rbtree_last_row(score_table, SCORECOL_SCORE, &row); + int ret = osl(osl_rbtree_last_row(score_table, SCORECOL_SCORE, &row)); if (ret < 0) return ret; - ret = osl_get_object(score_table, row, SCORECOL_AFT_ROW, &obj); + ret = osl(osl_get_object(score_table, row, SCORECOL_AFT_ROW, &obj)); if (ret < 0) return ret; *aft_row = obj.data; @@ -309,7 +309,7 @@ int score_delete(const struct osl_row *aft_row) if (ret < 0) return ret; - return osl_del_row(score_table, score_row); + return osl(osl_del_row(score_table, score_row)); } /** @@ -327,13 +327,13 @@ int row_belongs_to_score_table(const struct osl_row *aft_row, unsigned *rank) struct osl_row *score_row; int ret = get_score_row_from_aft_row(aft_row, &score_row); - if (ret == -E_OSL_RB_KEY_NOT_FOUND) + if (ret == -OSL_ERRNO_TO_PARA_ERROR(E_OSL_RB_KEY_NOT_FOUND)) return 0; if (ret < 0) return ret; if (!rank) return 1; - ret = osl_get_rank(score_table, score_row, SCORECOL_SCORE, rank); + ret = osl(osl_get_rank(score_table, score_row, SCORECOL_SCORE, rank)); if (ret < 0) return ret; return 1; @@ -356,7 +356,7 @@ static void score_close(void) static int score_open(__a_unused const char *dir) { score_table_desc.dir = NULL; /* this table has only volatile columns */ - return osl_open_table(&score_table_desc, &score_table); + return osl(osl_open_table(&score_table_desc, &score_table)); } /** diff --git a/send_common.c b/send_common.c index d14080ce..12d7ee1d 100644 --- a/send_common.c +++ b/send_common.c @@ -7,6 +7,7 @@ /** \file send_common.c Functions used by more than one paraslash sender. */ #include +#include #include "para.h" #include "error.h" #include "string.h" diff --git a/server.c b/server.c index 2e5f5f74..89f1e20f 100644 --- a/server.c +++ b/server.c @@ -65,6 +65,7 @@ #include #include #include +#include #include "para.h" #include "error.h" diff --git a/udp_send.c b/udp_send.c index 7217c960..499af66e 100644 --- a/udp_send.c +++ b/udp_send.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "server.cmdline.h" #include "para.h" diff --git a/vss.c b/vss.c index 6304fc53..da8510ee 100644 --- a/vss.c +++ b/vss.c @@ -12,6 +12,7 @@ */ #include +#include #include "para.h" #include "error.h"