]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Turn PARA_STRERROR into an inline function.
authorAndre Noll <maan@systemlinux.org>
Fri, 28 Dec 2007 13:36:10 +0000 (14:36 +0100)
committerAndre Noll <maan@systemlinux.org>
Fri, 28 Dec 2007 13:36:10 +0000 (14:36 +0100)
Add documentation and an assertion for (num > 0).

30 files changed:
aacdec.c
afh_common.c
afs.c
aft.c
attribute.c
audioc.c
audiod.c
audiod_command.c
blob.c
client.c
client_common.c
command.c
dccp_send.c
error.h
filter.c
fsck.c
http_send.c
mood.c
mp3_afh.c
playlist.c
recv.c
score.c
server.c
signal.c
stdin.c
stdout.c
user_list.c
vss.c
write.c
write_common.c

index 258864a06f4a1e1659be548c139af4c2b0fa7b83..c200c558cc67a705463871964abd058f9eb98f67 100644 (file)
--- a/aacdec.c
+++ b/aacdec.c
@@ -69,7 +69,7 @@ static ssize_t aacdec(char *input_buffer, size_t len, struct filter_node *fn)
                unsigned char channels = 0;
                ret = aac_find_esds(inbuf, len, &skip, &padd->decoder_length);
                if (ret < 0) {
-                       PARA_INFO_LOG("%s\n", PARA_STRERROR(-ret));
+                       PARA_INFO_LOG("%s\n", para_strerror(-ret));
                        ret = NeAACDecInit(padd->handle, inbuf,
                                len, &rate, &channels);
                        PARA_INFO_LOG("decoder init: %d\n", ret);
index 5c283e27d5a0d05209a90e594d533b2af3e533a2..a726254aa29aab7f9b72937900c6999f89a751f7 100644 (file)
@@ -156,7 +156,7 @@ int compute_afhi(const char *path, char *data, size_t size,
                ret = afl[i].get_file_info(data, size, afhi);
                if (ret >= 0)
                        return i;
-               PARA_WARNING_LOG("%s\n", PARA_STRERROR(-ret));
+               PARA_WARNING_LOG("%s\n", para_strerror(-ret));
        }
        return -E_AUDIO_FORMAT;
 }
diff --git a/afs.c b/afs.c
index 295933ec545d7eb60673e8dd002257347730e686..018fc5dcd23f51da96291504b75e16f80fd46aff 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -484,15 +484,15 @@ again:
        PARA_NOTICE_LOG("getting next audio file\n");
        ret = score_get_best(&aft_row, &score);
        if (ret < 0) {
-               PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+               PARA_ERROR_LOG("%s\n", para_strerror(-ret));
                goto no_admissible_files;
        }
        ret = open_and_update_audio_file(aft_row, score, &afd);
        if (ret < 0) {
-               PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+               PARA_ERROR_LOG("%s\n", para_strerror(-ret));
                ret = score_delete(aft_row);
                if (ret < 0) {
-                       PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+                       PARA_ERROR_LOG("%s\n", para_strerror(-ret));
                        goto no_admissible_files;
                }
                goto again;
@@ -576,7 +576,7 @@ static int com_select_callback(const struct osl_object *query,
                playlist_close();
        ret = activate_mood_or_playlist(arg, &num_admissible);
        if (ret < 0) {
-               para_printf(&pb, "%s\n", PARA_STRERROR(-ret));
+               para_printf(&pb, "%s\n", para_strerror(-ret));
                para_printf(&pb, "switching back to %s\n", current_mop?
                        current_mop : "dummy");
                ret = activate_mood_or_playlist(current_mop, &num_admissible);
@@ -626,7 +626,7 @@ static int setup_command_socket_or_die(void)
        ret = create_local_socket(socket_name, &unix_addr,
                S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IWOTH);
        if (ret < 0) {
-               PARA_EMERG_LOG("%s: %s\n", PARA_STRERROR(-ret), socket_name);
+               PARA_EMERG_LOG("%s: %s\n", para_strerror(-ret), socket_name);
                exit(EXIT_FAILURE);
        }
        socket_fd = ret;
@@ -691,7 +691,7 @@ static int open_afs_tables(void)
                if (ret >= 0)
                        continue;
                PARA_ERROR_LOG("%s init: %s\n", afs_tables[i].name,
-                       PARA_STRERROR(-ret));
+                       para_strerror(-ret));
                break;
        }
        if (ret >= 0)
@@ -737,7 +737,7 @@ static void signal_post_select(struct sched *s, struct task *t)
        }
        t->ret = -E_AFS_SIGNAL;
 err:
-       PARA_NOTICE_LOG("%s\n", PARA_STRERROR(-t->ret));
+       PARA_NOTICE_LOG("%s\n", para_strerror(-t->ret));
        unregister_tasks();
 }
 
@@ -844,7 +844,7 @@ static void execute_server_command(void)
 
        if (ret <= 0) {
                if (ret < 0)
-                       PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+                       PARA_ERROR_LOG("%s\n", para_strerror(-ret));
                return;
        }
        buf[ret] = '\0';
@@ -852,7 +852,7 @@ static void execute_server_command(void)
        if (!strcmp(buf, "new")) {
                ret = open_next_audio_file();
                if (ret < 0) {
-                       PARA_EMERG_LOG("%s\n", PARA_STRERROR(-ret));
+                       PARA_EMERG_LOG("%s\n", para_strerror(-ret));
                        unregister_tasks();
                }
                return;
@@ -869,7 +869,7 @@ static void execute_afs_command(int fd, uint32_t expected_cookie)
        int ret = recv_bin_buffer(fd, buf, sizeof(buf));
 
        if (ret < 0) {
-               PARA_NOTICE_LOG("%s\n", PARA_STRERROR(-ret));
+               PARA_NOTICE_LOG("%s\n", para_strerror(-ret));
                return;
        }
        if (ret != sizeof(buf)) {
@@ -925,13 +925,13 @@ static void command_post_select(struct sched *s, struct task *t)
                goto out;
        t->ret = para_accept(ct->fd, &unix_addr, sizeof(unix_addr));
        if (t->ret < 0) {
-               PARA_NOTICE_LOG("%s\n", PARA_STRERROR(-t->ret));
+               PARA_NOTICE_LOG("%s\n", para_strerror(-t->ret));
                goto out;
        }
        fd = t->ret;
        t->ret = mark_fd_nonblocking(fd);
        if (t->ret < 0) {
-               PARA_NOTICE_LOG("%s\n", PARA_STRERROR(-t->ret));
+               PARA_NOTICE_LOG("%s\n", para_strerror(-t->ret));
                close(fd);
                goto out;
        }
@@ -979,7 +979,7 @@ __noreturn void afs_init(uint32_t cookie, int socket_fd)
        ret = open_afs_tables();
 
        if (ret < 0) {
-               PARA_EMERG_LOG("%s\n", PARA_STRERROR(-ret));
+               PARA_EMERG_LOG("%s\n", para_strerror(-ret));
                exit(EXIT_FAILURE);
        }
        server_socket = socket_fd;
@@ -994,7 +994,7 @@ __noreturn void afs_init(uint32_t cookie, int socket_fd)
        s.default_timeout.tv_usec = 999 * 1000;
        ret = schedule(&s);
        if (ret < 0)
-               PARA_EMERG_LOG("%s\n", PARA_STRERROR(-ret));
+               PARA_EMERG_LOG("%s\n", para_strerror(-ret));
        close_afs_tables();
        exit(EXIT_FAILURE);
 }
@@ -1145,7 +1145,7 @@ void afs_event(enum afs_events event, struct para_buffer *pb,
                        continue;
                ret = t->event_handler(event, pb, data);
                if (ret < 0)
-                       PARA_CRIT_LOG("%s\n", PARA_STRERROR(-ret));
+                       PARA_CRIT_LOG("%s\n", para_strerror(-ret));
        }
 }
 
diff --git a/aft.c b/aft.c
index 2cdeb20cec5da5e8695d25bfe631a1a3d04c0f99..51703aa4583ace19696db9e317e9135a9d285904 100644 (file)
--- a/aft.c
+++ b/aft.c
@@ -1631,7 +1631,7 @@ static int com_add_callback(const struct osl_object *query,
        afs_event(AUDIO_FILE_ADD, &msg, aft_row);
 out:
        if (ret < 0)
-               para_printf(&msg, "%s\n", PARA_STRERROR(-ret));
+               para_printf(&msg, "%s\n", para_strerror(-ret));
        if (!msg.buf)
                return 0;
        result->data = msg.buf;
@@ -1761,7 +1761,7 @@ out_unmap:
 out_free:
        if (ret < 0 && send_ret >= 0)
                send_ret = send_va_buffer(pad->fd, "failed to add %s (%s)\n", path,
-                       PARA_STRERROR(-ret));
+                       para_strerror(-ret));
        free(obj.data);
        if (afhi_ptr)
                free(afhi_ptr->chunk_table);
@@ -1806,7 +1806,8 @@ int com_add(int fd, int argc, char * const * const argv)
                char *path;
                ret = verify_path(argv[i], &path);
                if (ret < 0) {
-                       ret = send_va_buffer(fd, "%s: %s\n", argv[i], PARA_STRERROR(-ret));
+                       ret = send_va_buffer(fd, "%s: %s\n", argv[i],
+                               para_strerror(-ret));
                        if (ret < 0)
                                return ret;
                        continue;
@@ -1826,7 +1827,7 @@ int com_add(int fd, int argc, char * const * const argv)
                else
                        ret = add_one_audio_file(path, &pad);
                if (ret < 0) {
-                       send_va_buffer(fd, "%s: %s\n", path, PARA_STRERROR(-ret));
+                       send_va_buffer(fd, "%s: %s\n", path, para_strerror(-ret));
                        free(path);
                        return ret;
                }
@@ -1882,12 +1883,12 @@ static int touch_audio_file(__a_unused struct osl_table *table,
 
        ret = get_afsi_object_of_row(row, &obj);
        if (ret < 0) {
-               para_printf(&tad->pb, "%s: %s\n", name, PARA_STRERROR(-ret));
+               para_printf(&tad->pb, "%s: %s\n", name, para_strerror(-ret));
                return 1;
        }
        ret = load_afsi(&old_afsi, &obj);
        if (ret < 0) {
-               para_printf(&tad->pb, "%s: %s\n", name, PARA_STRERROR(-ret));
+               para_printf(&tad->pb, "%s: %s\n", name, para_strerror(-ret));
                return 1;
        }
        new_afsi = old_afsi;
@@ -1935,7 +1936,7 @@ static int com_touch_callback(const struct osl_object *query,
                pmd.fnmatch_flags |= FNM_PATHNAME;
        ret = for_each_matching_row(&pmd);
        if (ret < 0)
-               para_printf(&tad.pb, "%s\n", PARA_STRERROR(-ret));
+               para_printf(&tad.pb, "%s\n", para_strerror(-ret));
        if (tad.pb.buf) {
                result->data = tad.pb.buf;
                result->size = tad.pb.size;
@@ -2007,7 +2008,7 @@ int com_touch(int fd, int argc, char * const * const argv)
                send_buffer(fd, (char *)result.data);
                free(result.data);
        } else if (ret < 0)
-               send_va_buffer(fd, "%s\n", PARA_STRERROR(-ret));
+               send_va_buffer(fd, "%s\n", para_strerror(-ret));
        return ret;
 }
 
@@ -2042,7 +2043,7 @@ static int remove_audio_file(__a_unused struct osl_table *table,
        afs_event(AUDIO_FILE_REMOVE, &crd->pb, row);
        ret = osl_del_row(audio_file_table, row);
        if (ret < 0)
-               para_printf(&crd->pb, "%s: %s\n", name, PARA_STRERROR(-ret));
+               para_printf(&crd->pb, "%s: %s\n", name, para_strerror(-ret));
        else
                crd->num_removed++;
        return 1;
@@ -2066,7 +2067,7 @@ static int com_rm_callback(const struct osl_object *query,
                pmd.fnmatch_flags |= FNM_PATHNAME;
        ret = for_each_matching_row(&pmd);
        if (ret < 0)
-               para_printf(&crd.pb, "%s\n", PARA_STRERROR(-ret));
+               para_printf(&crd.pb, "%s\n", para_strerror(-ret));
        if (!crd.num_removed && !(crd.flags & RM_FLAG_FORCE))
                para_printf(&crd.pb, "no matches -- nothing removed\n");
        else {
@@ -2119,7 +2120,7 @@ int com_rm(int fd, int argc,  char * const * const argv)
                send_buffer(fd, (char *)result.data);
                free(result.data);
        } else if (ret < 0)
-               send_va_buffer(fd, "%s\n", PARA_STRERROR(-ret));
+               send_va_buffer(fd, "%s\n", para_strerror(-ret));
        return ret;
 }
 
@@ -2212,7 +2213,7 @@ static int com_cpsi_callback(const struct osl_object *query,
        ret = for_each_matching_row(&pmd);
 out:
        if (ret < 0)
-               para_printf(&cad.pb, "%s\n", PARA_STRERROR(-ret));
+               para_printf(&cad.pb, "%s\n", para_strerror(-ret));
        if (cad.flags & CPSI_FLAG_VERBOSE) {
                if (cad.num_copied)
                        para_printf(&cad.pb, "copied requested afsi from %s "
@@ -2280,7 +2281,7 @@ int com_cpsi(int fd, int argc,  char * const * const argv)
                send_buffer(fd, (char *)result.data);
                free(result.data);
        } else
-               send_va_buffer(fd, "%s\n", PARA_STRERROR(-ret));
+               send_va_buffer(fd, "%s\n", para_strerror(-ret));
        return ret;
 }
 
@@ -2295,7 +2296,7 @@ static int check_audio_file(struct osl_row *row, void *data)
        char *blob_name;
 
        if (ret < 0) {
-               para_printf(pb, "%s\n", PARA_STRERROR(-ret));
+               para_printf(pb, "%s\n", para_strerror(-ret));
                return 1;
        }
        if (stat(path, &statbuf) < 0)
@@ -2306,17 +2307,17 @@ static int check_audio_file(struct osl_row *row, void *data)
        }
        ret = get_afsi_of_row(row, &afsi);
        if (ret < 0) {
-               para_printf(pb, "%s: %s\n", path, PARA_STRERROR(-ret));
+               para_printf(pb, "%s: %s\n", path, para_strerror(-ret));
                return 1;
        }
        ret = lyr_get_name_by_id(afsi.lyrics_id, &blob_name);
        if (ret < 0)
                para_printf(pb, "%s lyrics id %u: %s\n", path, afsi.lyrics_id,
-                       PARA_STRERROR(-ret));
+                       para_strerror(-ret));
        ret = img_get_name_by_id(afsi.image_id, &blob_name);
        if (ret < 0)
                para_printf(pb, "%s image id %u: %s\n", path, afsi.image_id,
-                       PARA_STRERROR(-ret));
+                       para_strerror(-ret));
        return 1;
 }
 
index dd1be5d89ae4f1298250c1e9bbd4eab06d5b376b..e306aa2e1889b05b8646b650dd0d8e42e1e861de 100644 (file)
@@ -134,7 +134,7 @@ static int print_attribute(struct osl_table *table, struct osl_row *row,
        }
        ret = osl_get_object(table, row, ATTCOL_BITNUM, &bitnum_obj);
        if (ret < 0) {
-               para_printf(&laad->pb, "%s: %s\n", name, PARA_STRERROR(-ret));
+               para_printf(&laad->pb, "%s: %s\n", name, para_strerror(-ret));
                return ret;
        }
        para_printf(&laad->pb, "%u\t%s\n", *(unsigned char*)bitnum_obj.data,
@@ -164,7 +164,7 @@ static int com_lsatt_callback(const struct osl_object *query,
                pmd.pm_flags |= PM_REVERSE_LOOP;
        ret = for_each_matching_row(&pmd);
        if (ret < 0)
-               para_printf(&laad.pb, "%s\n", PARA_STRERROR(-ret));
+               para_printf(&laad.pb, "%s\n", para_strerror(-ret));
        if (!laad.pb.buf)
                return 0;
        result->data = laad.pb.buf;
@@ -206,7 +206,7 @@ int com_lsatt(int fd, int argc, char * const * const argv)
                ret = send_buffer(fd, (char *)result.data);
                free(result.data);
        } else if (ret < 0)
-               send_va_buffer(fd, "%s\n", PARA_STRERROR(-ret));
+               send_va_buffer(fd, "%s\n", para_strerror(-ret));
        else if (argc > 1)
                send_va_buffer(fd, "no matches\n");
        return ret;
@@ -341,7 +341,7 @@ static int com_addatt_callback(const struct osl_object *query,
        }
 out:
        if (ret < 0)
-               para_printf(&pb, "%s: %s\n", p, PARA_STRERROR(-ret));
+               para_printf(&pb, "%s: %s\n", p, para_strerror(-ret));
        result->data = pb.buf;
        result->size = pb.size;
        return result->data? 0 : 1;
@@ -386,7 +386,7 @@ static int com_mvatt_callback(const struct osl_object *query,
        ret = osl_update_object(attribute_table, row, ATTCOL_NAME, &obj);
 out:
        if (ret < 0)
-               para_printf(&pb, "%s\n", PARA_STRERROR(-ret));
+               para_printf(&pb, "%s\n", para_strerror(-ret));
        else
                afs_event(ATTRIBUTE_RENAME, &pb, NULL);
        if (!pb.buf)
@@ -435,12 +435,12 @@ static int remove_attribute(struct osl_table *table, struct osl_row *row,
 
        ret = get_attribute_bitnum_by_name(name, &red.bitnum);
        if (ret < 0) {
-               para_printf(&raad->pb, "%s: %s\n", name, PARA_STRERROR(-ret));
+               para_printf(&raad->pb, "%s: %s\n", name, para_strerror(-ret));
                return 1;
        }
        ret = osl_del_row(table, row);
        if (ret < 0) {
-               para_printf(&raad->pb, "%s: %s\n", name, PARA_STRERROR(-ret));
+               para_printf(&raad->pb, "%s: %s\n", name, para_strerror(-ret));
                return 1;
        }
        para_printf(&raad->pb, "removed attribute %s\n", name);
@@ -465,7 +465,7 @@ static int com_rmatt_callback(const struct osl_object *query,
        };
        ret = for_each_matching_row(&pmd);
        if (ret < 0)
-               para_printf(&raad.pb, "%s\n", PARA_STRERROR(-ret));
+               para_printf(&raad.pb, "%s\n", para_strerror(-ret));
        if (!raad.num_removed)
                para_printf(&raad.pb, "no match -- nothing removed\n");
        result->data = raad.pb.buf;
@@ -486,7 +486,7 @@ int com_rmatt(int fd, int argc, char * const * const argv)
                send_buffer(fd, (char *)result.data);
                free(result.data);
        } else
-               send_va_buffer(fd, "%s\n", PARA_STRERROR(-ret));
+               send_va_buffer(fd, "%s\n", para_strerror(-ret));
        return ret;
 }
 
index aa7184e09070d4742650cc7b72904ab066ebc482..a078c48c02b6a1b166f60878bab83d80bf00aac2 100644 (file)
--- a/audioc.c
+++ b/audioc.c
@@ -150,6 +150,6 @@ out:
        if (!ret && loaded && buf)
                ret = write(STDOUT_FILENO, buf, loaded);
        if (ret < 0)
-               PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+               PARA_ERROR_LOG("%s\n", para_strerror(-ret));
        return ret < 0? EXIT_FAILURE : EXIT_SUCCESS;
 }
index f83943a682f5c86496f1bd6efe1cd6b265443268..dfd62e6f47d0072172ed6d0ee8872350b88792e6 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -264,7 +264,7 @@ int num_filters(int audio_format_num)
 
 static void filter_event_handler(struct task *t)
 {
-       PARA_NOTICE_LOG("%s\n", PARA_STRERROR(-t->ret));
+       PARA_NOTICE_LOG("%s\n", para_strerror(-t->ret));
        struct filter_chain *fc = t->private_data;
        fc->error = t->ret;
        unregister_task(t);
@@ -314,7 +314,7 @@ static void wng_event_handler(struct task *t)
 {
        struct writer_node_group *wng = t->private_data;
 
-       PARA_INFO_LOG("%s\n", PARA_STRERROR(-t->ret));
+       PARA_INFO_LOG("%s\n", para_strerror(-t->ret));
        wng->error = t->ret;
        wng_unregister(wng);
 }
@@ -350,7 +350,7 @@ static void open_writers(int slot_num)
        }
        ret = wng_open(s->wng);
        if (ret < 0) {
-               PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+               PARA_ERROR_LOG("%s\n", para_strerror(-ret));
                return;
        }
        s->wstime = *now;
@@ -362,7 +362,7 @@ static void rn_event_handler(struct task *t)
        struct receiver_node *rn = t->private_data;
        int i;
 
-       PARA_NOTICE_LOG("%s\n", PARA_STRERROR(-t->ret));
+       PARA_NOTICE_LOG("%s\n", para_strerror(-t->ret));
        unregister_task(t);
        rn->error = t->ret;
        /* set restart barrier */
@@ -411,7 +411,7 @@ static int open_receiver(int format)
        register_task(&rn->task);
        return 1;
 err:
-       PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+       PARA_ERROR_LOG("%s\n", para_strerror(-ret));
        tv_add(now, &restart_delay, &afi[format].restart_barrier);
        return ret;
 }
@@ -933,7 +933,7 @@ static void command_post_select(struct sched *s, struct task *t)
                return;
        ret = handle_connect(ct->fd);
        if (ret < 0)
-               PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+               PARA_ERROR_LOG("%s\n", para_strerror(-ret));
 }
 
 static void init_command_task(struct command_task *ct)
@@ -1146,7 +1146,7 @@ int main(int argc, char *argv[])
        log_welcome("para_audiod", conf.loglevel_arg);
        i = init_stream_io();
        if (i < 0) {
-               PARA_EMERG_LOG("init stream io error: %s\n", PARA_STRERROR(-i));
+               PARA_EMERG_LOG("init stream io error: %s\n", para_strerror(-i));
                exit(EXIT_FAILURE);
        }
        server_uptime(UPTIME_SET);
@@ -1173,6 +1173,6 @@ int main(int argc, char *argv[])
        s.default_timeout.tv_usec = 99 * 1000;
        ret = schedule(&s);
 
-       PARA_EMERG_LOG("%s\n", PARA_STRERROR(-ret));
+       PARA_EMERG_LOG("%s\n", para_strerror(-ret));
        return EXIT_FAILURE;
 }
index 855e5cea102e51076b50ad345d014096d9c08e4a..773bba8b07e1e1c06468d79cedb4a7f115aeec42 100644 (file)
@@ -461,7 +461,7 @@ out:
        free(buf);
        free(argv);
        if (clifd > 0 && ret < 0 && ret != -E_CLIENT_WRITE) {
-               char *tmp = make_message("%s\n", PARA_STRERROR(-ret));
+               char *tmp = make_message("%s\n", para_strerror(-ret));
                client_write(clifd, tmp);
                free(tmp);
                close(clifd);
diff --git a/blob.c b/blob.c
index 8675ee73330fb1f87a1f4ef0a2780b445a2a7b5b..b7dd908fc9cda0b0b4b579464bfa0de634e99a99 100644 (file)
--- a/blob.c
+++ b/blob.c
@@ -74,7 +74,7 @@ static int print_blob(struct osl_table *table, struct osl_row *row,
        }
        ret = osl_get_object(table, row, BLOBCOL_ID, &obj);
        if (ret < 0) {
-               para_printf(&lbad->pb, "%s: %s\n", name, PARA_STRERROR(-ret));
+               para_printf(&lbad->pb, "%s: %s\n", name, para_strerror(-ret));
                return ret;
        }
        id = *(uint32_t *)obj.data;
@@ -105,7 +105,7 @@ static int com_lsblob_callback(struct osl_table *table,
                pmd.loop_col_num = BLOBCOL_ID;
        ret = for_each_matching_row(&pmd);
        if (ret < 0)
-               para_printf(&lbad.pb, "%s\n", PARA_STRERROR(-ret));
+               para_printf(&lbad.pb, "%s\n", para_strerror(-ret));
        if (!lbad.pb.buf)
                return 0;
        result->data = lbad.pb.buf;
@@ -221,7 +221,7 @@ static int remove_blob(struct osl_table *table, struct osl_row *row,
        struct rmblob_data *rmbd = data;
        int ret = osl_del_row(table, row);
        if (ret < 0) {
-               para_printf(&rmbd->pb, "%s: %s\n", name, PARA_STRERROR(-ret));
+               para_printf(&rmbd->pb, "%s: %s\n", name, para_strerror(-ret));
                return ret;
        }
        rmbd->num_removed++;
@@ -246,7 +246,7 @@ static int com_rmblob_callback(struct osl_table *table,
        result->data = NULL;
        ret = for_each_matching_row(&pmd);
        if (ret < 0)
-               para_printf(&rmbd.pb, "%s\n", PARA_STRERROR(-ret));
+               para_printf(&rmbd.pb, "%s\n", para_strerror(-ret));
        if (!rmbd.num_removed)
                para_printf(&rmbd.pb, "no matches, nothing removed\n");
        else {
index 07da6529c5f690929d678678489317d9b4d29d74..438707d7328696f5d6285d8a3cb9dae6cd23eaec 100644 (file)
--- a/client.c
+++ b/client.c
@@ -29,7 +29,7 @@ static void client_event_handler(struct task *t)
 {
        struct private_client_data *p = t->private_data;
 
-       PARA_NOTICE_LOG("%s\n", PARA_STRERROR(-t->ret));
+       PARA_NOTICE_LOG("%s\n", para_strerror(-t->ret));
        if (t->ret != -E_HANDSHAKE_COMPLETE) {
                unregister_task(t);
                p->error = t->ret;
@@ -79,7 +79,7 @@ int main(int argc, char *argv[])
        pcd->task.event_handler = client_event_handler;
        ret = schedule(&s);
        if (ret < 0)
-               PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+               PARA_ERROR_LOG("%s\n", para_strerror(-ret));
        client_close(pcd);
        return ret >= 0? EXIT_SUCCESS: EXIT_FAILURE;
 }
index 5359b29944d0f52242fe31cb25bfc9a0b9065ab6..28c03d41ba08b75173da3e89dc96743c8cab9427 100644 (file)
@@ -371,7 +371,7 @@ int client_open(int argc, char *argv[], struct private_client_data **pcd_ptr)
 out:
        free(home);
        if (ret < 0) {
-               PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+               PARA_ERROR_LOG("%s\n", para_strerror(-ret));
                client_close(pcd);
                *pcd_ptr = NULL;
        }
index 6886ae9b71d442b1169ad05293ae67eeba0fc19e..fee817b005f69c7325760238725700d04046a25e 100644 (file)
--- a/command.c
+++ b/command.c
@@ -804,9 +804,9 @@ int handle_connect(int fd, const char *peername)
                goto out;
        }
 err_out:
-       send_va_buffer(fd, "%s\n", PARA_STRERROR(-ret));
+       send_va_buffer(fd, "%s\n", para_strerror(-ret));
 net_err:
-       PARA_NOTICE_LOG("%s\n", PARA_STRERROR(-ret));
+       PARA_NOTICE_LOG("%s\n", para_strerror(-ret));
        ret = EXIT_FAILURE;
 out:
        free(command);
index f3b9120b3dfd75ef913a1d4b1f6a2b968e887ba1..7ec6e686bd5659b79b54ec49247d587e05110851 100644 (file)
@@ -69,7 +69,7 @@ static void dccp_post_select(fd_set *rfds, __a_unused fd_set *wfds)
                return;
        ret = para_accept(listen_fd, NULL, 0);
        if (ret < 0) {
-               PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+               PARA_ERROR_LOG("%s\n", para_strerror(-ret));
                return;
        }
        /*
@@ -200,7 +200,7 @@ static void dccp_send(long unsigned current_chunk,
 //             PARA_DEBUG_LOG("writing %d bytes to fd %d\n", len, dc->fd);
                ret = dccp_write(dc->fd, buf, len);
                if (ret < 0) {
-                       PARA_NOTICE_LOG("%s\n", PARA_STRERROR(-ret));
+                       PARA_NOTICE_LOG("%s\n", para_strerror(-ret));
                        dccp_shutdown_client(dc);
                        continue;
                }
@@ -263,7 +263,7 @@ void dccp_send_init(struct sender *s)
        self = s;
        ret = dccp_open();
        if (ret < 0) {
-               PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+               PARA_ERROR_LOG("%s\n", para_strerror(-ret));
                s->status = SENDER_OFF;
        } else
                s->status = SENDER_ON;
diff --git a/error.h b/error.h
index 4bc9f1555e274049d041e2895d31c1263469845f..3fa657e693d1098e49d8449417ff64decc9f78de 100644 (file)
--- a/error.h
+++ b/error.h
@@ -446,27 +446,48 @@ extern const char **para_errlist[];
  */
 #define ERRNUM_TO_INDEX(num) (((1 << SS_SHIFT) - 1) & (num))
 
+/**
+ * This bit indicates whether a number is considered a system error number
+ * If yes, the system errno is just the result of clearing this bit from
+ * the given number.
+ */
 #define SYSTEM_ERROR_BIT 30
 
+/** Check whether the system error bit is set. */
 #define IS_SYSTEM_ERROR(num) (!!((num) & (1 << SYSTEM_ERROR_BIT)))
 
+/** Set the system error bit for the given number. */
 #define ERRNO_TO_PARA_ERROR(num) ((num) | (1 << SYSTEM_ERROR_BIT))
 
-static inline int is_errno(int val, int _errno)
+/** Check whether a given number is a system error number.
+ *
+ * \param num The value to be checked.
+ * \param _errno The system error number.
+ *
+ * \return True if \a num is paraslash's representation of the system
+ * error identified by \a _errno.
+ */
+_static_inline_ int is_errno(int num, int _errno)
 {
-       assert(val > 0 && _errno > 0);
-       return ERRNO_TO_PARA_ERROR(_errno) == val;
+       assert(num > 0 && _errno > 0);
+       return ERRNO_TO_PARA_ERROR(_errno) == num;
 }
 
 /**
  * Paraslash's version of strerror(3).
  *
- * Expands to the error text of \a num (a string constant).
+ * \param int The error number.
+ *
+ * \return The error text of \a num.
  */
-#define PARA_STRERROR(num) IS_SYSTEM_ERROR(num)? \
-       strerror((num) & ((1 << SYSTEM_ERROR_BIT) - 1)) : \
-       para_errlist[ERRNUM_TO_SS(num)] [ERRNUM_TO_INDEX(num)]
-
+_static_inline_ const char *para_strerror(int num)
+{
+       assert(num > 0);
+       if (IS_SYSTEM_ERROR(num))
+               return strerror((num) & ((1 << SYSTEM_ERROR_BIT) - 1));
+       else
+               return para_errlist[ERRNUM_TO_SS(num)][ERRNUM_TO_INDEX(num)];
+}
 /**
  * Define the error list for one subsystem.
  #
index 27bbe63ee190b989e9396cff9e27763859ac2d38..fb36a557be40f75504cdfc47ba91f5b275516250 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -41,7 +41,7 @@ INIT_STDERR_LOGGING(conf.loglevel_arg);
 
 static void filter_event_handler(struct task *t)
 {
-       PARA_NOTICE_LOG("%s\n", PARA_STRERROR(-t->ret));
+       PARA_NOTICE_LOG("%s\n", para_strerror(-t->ret));
        unregister_task(t);
 }
 
@@ -172,6 +172,6 @@ out:
        free(sit->buf);
        close_filters(fc);
        if (ret < 0)
-               PARA_EMERG_LOG("%s\n", PARA_STRERROR(-ret));
+               PARA_EMERG_LOG("%s\n", para_strerror(-ret));
        return ret < 0? EXIT_FAILURE : EXIT_SUCCESS;
 }
diff --git a/fsck.c b/fsck.c
index 04916384c30d4d18417afafd58472d1dfad5689f..a40ff37950626207e9c3575bfc1044792671b347 100644 (file)
--- a/fsck.c
+++ b/fsck.c
@@ -967,7 +967,7 @@ out:
                PARA_ERROR_LOG("%s%s: %s\n",
                        base_dir? "base_dir: " : "",
                        base_dir? base_dir : "",
-                       PARA_STRERROR(-ret)
+                       para_strerror(-ret)
                );
                if (conf.loglevel_arg > 1)
                        PARA_EMERG_LOG("re-run with \"--logelvel %d\" to increase verbosity\n",
index 28e245eae13ac6b7ce8e0a5f162ab88be52b5a60..e60b3f90f2853c6ff12f9958d642cb8b3e691e36 100644 (file)
@@ -364,7 +364,7 @@ static int open_tcp_port(int port)
        }
        ret = mark_fd_nonblocking(server_fd);
        if (ret < 0) {
-               PARA_EMERG_LOG("%s\n", PARA_STRERROR(-ret));
+               PARA_EMERG_LOG("%s\n", para_strerror(-ret));
                exit(EXIT_FAILURE);
        }
        self->status = SENDER_ON;
diff --git a/mood.c b/mood.c
index 5908a93dc7a77c92c8e556957eb8c122d2470335..0f907cc0d6ac204669400f0825d736cabbd06042 100644 (file)
--- a/mood.c
+++ b/mood.c
@@ -520,7 +520,7 @@ static int load_mood(const struct osl_row *mood_row, struct mood **m)
        osl_close_disk_object(&mood_def);
        if (ret < 0) {
                PARA_ERROR_LOG("unable to load mood %s: %s\n", mlpd.m->name,
-                       PARA_STRERROR(-ret));
+                       para_strerror(-ret));
                destroy_mood(mlpd.m);
                return ret;
        }
@@ -548,7 +548,7 @@ static int check_mood(struct osl_row *mood_row, void *data)
                parse_mood_line, &mlpd);
        if (ret < 0)
                para_printf(pb, "%s line %u: %s\n", mood_name, mlpd.line_num,
-                       PARA_STRERROR(-ret));
+                       para_strerror(-ret));
 out:
        osl_close_disk_object(&mood_def);
        return 1;
index f5fc7113d14bed295f862de00f5d5c093941d47d..a6a421a640195cee964e2b33c908e05934a04243 100644 (file)
--- a/mp3_afh.c
+++ b/mp3_afh.c
@@ -395,7 +395,7 @@ static int mp3_read_info(unsigned char *map, size_t numbytes,
        PARA_DEBUG_LOG("eof timeout: %lu\n", tv2ms(&afhi->eof_tv));
        return 1;
 err_out:
-       PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+       PARA_ERROR_LOG("%s\n", para_strerror(-ret));
        free(afhi->chunk_table);
        return ret;
 }
index 826280b9270ff9bc8c9a37f46e376d69a1422671..8955ea9dc6793eb9d646c708f59313d6a41c3549 100644 (file)
@@ -41,12 +41,12 @@ static int add_playlist_entry(char *path, void *data)
        int ret = aft_get_row_of_path(path, &aft_row);
 
        if (ret < 0) {
-               PARA_NOTICE_LOG("%s: %s\n", path, PARA_STRERROR(-ret));
+               PARA_NOTICE_LOG("%s: %s\n", path, para_strerror(-ret));
                return 1;
        }
        ret = score_add(aft_row, -playlist->length);
        if (ret < 0) {
-               PARA_ERROR_LOG("failed to add %s: %s\n", path, PARA_STRERROR(-ret));
+               PARA_ERROR_LOG("failed to add %s: %s\n", path, para_strerror(-ret));
                return ret;
        }
        playlist->length++;
@@ -80,7 +80,7 @@ static int load_playlist(struct osl_row *row, void *data)
 err:
        if (ret != -E_DUMMY_ROW)
                PARA_NOTICE_LOG("unable to load playlist (%s)\n",
-                       PARA_STRERROR(-ret));
+                       para_strerror(-ret));
        return 1;
 }
 
@@ -91,7 +91,7 @@ static int check_playlist_path(char *path, void *data)
        int ret = aft_get_row_of_path(path, &aft_row);
 
        if (ret < 0)
-               para_printf(pb, "%s: %s\n", path, PARA_STRERROR(-ret));
+               para_printf(pb, "%s: %s\n", path, para_strerror(-ret));
        return 1;
 }
 
@@ -104,7 +104,7 @@ static int check_playlist(struct osl_row *row, void *data)
 
        if (ret < 0) {
                para_printf(pb, "failed to get playlist data: %s\n",
-                       PARA_STRERROR(-ret));
+                       para_strerror(-ret));
                return 1;
        }
        if (*playlist_name) { /* skip dummy row */
diff --git a/recv.c b/recv.c
index d1909f25a6b288f0801fad4c095fd768e38041de..0875d17d0dd0ebba5141f7db53be474f89597924 100644 (file)
--- a/recv.c
+++ b/recv.c
@@ -48,7 +48,7 @@ static void *parse_config(int argc, char *argv[], int *receiver_num)
 static void rn_event_handler(struct task *t)
 {
        struct receiver_node *rn = t->private_data;
-       PARA_NOTICE_LOG("%s\n", PARA_STRERROR(-t->ret));
+       PARA_NOTICE_LOG("%s\n", para_strerror(-t->ret));
        rn->error = t->ret;
        unregister_task(t);
 }
@@ -111,6 +111,6 @@ out:
        if (r)
                r->shutdown();
        if (ret < 0)
-               PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+               PARA_ERROR_LOG("%s\n", para_strerror(-ret));
        return ret < 0? EXIT_FAILURE : EXIT_SUCCESS;
 }
diff --git a/score.c b/score.c
index 7d3b024690d432ee9d4fb9b77a0388fabee90e6b..8f75a1a02f6091c957b51472f8168c1fd550bb2d 100644 (file)
--- a/score.c
+++ b/score.c
@@ -143,7 +143,7 @@ int score_add(const struct osl_row *aft_row, long score)
 //     PARA_DEBUG_LOG("adding %p\n", *(void **) (score_objs[SCORECOL_AFT_ROW].data));
        ret = osl_add_row(score_table, score_objs);
        if (ret < 0) {
-               PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+               PARA_ERROR_LOG("%s\n", para_strerror(-ret));
                free(score_objs[SCORECOL_SCORE].data);
        }
        return ret;
index 17ff7cb408ae62e551b8e0ce754fe4a1e667c901..73986f6df3bf00d080bd7b9e2f12f4efa2e9a5f1 100644 (file)
--- a/server.c
+++ b/server.c
@@ -204,7 +204,7 @@ static void shm_init(void)
        mmd->sender_cmd_data.cmd_num = -1;
        return;
 err_out:
-       PARA_EMERG_LOG("%s", PARA_STRERROR(-ret));
+       PARA_EMERG_LOG("%s", para_strerror(-ret));
        exit(EXIT_FAILURE);
 }
 
@@ -318,7 +318,7 @@ static unsigned init_network(void)
        add_close_on_fork_list(fd); /* child doesn't need the listener */
        return fd;
 err:
-       PARA_EMERG_LOG("%s\n", PARA_STRERROR(-ret));
+       PARA_EMERG_LOG("%s\n", para_strerror(-ret));
        exit(EXIT_FAILURE);
 }
 
index cc49da11f2b647c83cb068b0cecab439419eb571..67af16558fa9357518eaef956d74f477c8625794 100644 (file)
--- a/signal.c
+++ b/signal.c
@@ -48,7 +48,7 @@ int para_signal_init(void)
                goto err_out;
        return signal_pipe[0];
 err_out:
-       PARA_EMERG_LOG("%s\n", PARA_STRERROR(-ret));
+       PARA_EMERG_LOG("%s\n", para_strerror(-ret));
        exit(EXIT_FAILURE);
 }
 
diff --git a/stdin.c b/stdin.c
index 25eca2ef224f312a1249493d2bc9b192ce066d76..40f02c1cef0a945546966fef4f2cea033d54fc17 100644 (file)
--- a/stdin.c
+++ b/stdin.c
@@ -41,7 +41,7 @@ static void stdin_pre_select(struct sched *s, struct task *t)
 
 static void stdin_default_event_handler(struct task *t)
 {
-       PARA_NOTICE_LOG("%p: %s\n", t, PARA_STRERROR(-t->ret));
+       PARA_NOTICE_LOG("%p: %s\n", t, para_strerror(-t->ret));
        unregister_task(t);
 }
 
index babed7525e53db3997d7c792bb75f7b72b881a75..178f3eebe5cab4e8f0df1d9fdf3e03b813a14f16 100644 (file)
--- a/stdout.c
+++ b/stdout.c
@@ -80,7 +80,7 @@ static void stdout_post_select(struct sched *s, struct task *t)
 
 static void stdout_default_event_handler(struct task *t)
 {
-       PARA_NOTICE_LOG("%p: %s\n", t, PARA_STRERROR(-t->ret));
+       PARA_NOTICE_LOG("%p: %s\n", t, para_strerror(-t->ret));
        unregister_task(t);
 }
 
index 8e21b238a26a0e7a4da29e0d210dfd64ecadf74d..45501ad1e2984147839d2098597ee06db902fa39 100644 (file)
@@ -40,7 +40,7 @@ static void populate_user_list(char *user_list_file)
                struct user *u;
                ret = para_fgets(line, MAXLINE, file_ptr);
                if (ret < 0)
-                       PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+                       PARA_ERROR_LOG("%s\n", para_strerror(-ret));
                if (ret <= 0)
                        break;
                if (sscanf(line,"%200s %200s %200s %200s", w, n, k, p) < 3)
@@ -79,7 +79,7 @@ out:
                fclose(file_ptr);
        if (ret >= 0)
                return;
-       PARA_EMERG_LOG("%s\n", PARA_STRERROR(-ret));
+       PARA_EMERG_LOG("%s\n", para_strerror(-ret));
        exit(EXIT_FAILURE);
 }
 
diff --git a/vss.c b/vss.c
index b18c73139a51eb86de3754d356c6727d1bf4d30d..a55e09151a35e116fe17445721348970f32330bc 100644 (file)
--- a/vss.c
+++ b/vss.c
@@ -421,7 +421,7 @@ static void recv_afs_result(void)
 err:
        if (passed_fd >= 0)
                close(passed_fd);
-       PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+       PARA_ERROR_LOG("%s\n", para_strerror(-ret));
        mmd->new_vss_status_flags = VSS_NEXT;
 }
 
diff --git a/write.c b/write.c
index 125df1c1d94440f7cfabad1b56ef55f1ffaa4110..c425c7cb72235ae2d8f620e04a633524fd917ea8 100644 (file)
--- a/write.c
+++ b/write.c
@@ -156,7 +156,7 @@ static void wng_event_handler(struct task *t)
 {
        struct writer_node_group *g = t->private_data;
 
-       PARA_INFO_LOG("%s\n", PARA_STRERROR(-t->ret));
+       PARA_INFO_LOG("%s\n", para_strerror(-t->ret));
        unregister_task(t);
        wng_close(g);
 }
@@ -166,7 +166,7 @@ static void idt_event_handler(struct task *t)
 {
        int ret;
 
-       PARA_INFO_LOG("%s\n", PARA_STRERROR(-t->ret));
+       PARA_INFO_LOG("%s\n", para_strerror(-t->ret));
        unregister_task(t);
        wng->buf = sit.buf;
        wng->loaded = &sit.loaded;
@@ -176,7 +176,7 @@ static void idt_event_handler(struct task *t)
        wng->samplerate = &cwt.samplerate;
        ret = wng_open(wng);
        if (ret < 0) {
-               PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+               PARA_ERROR_LOG("%s\n", para_strerror(-ret));
                exit(EXIT_FAILURE);
        }
 }
@@ -184,10 +184,10 @@ static void idt_event_handler(struct task *t)
 static void cwt_event_handler(struct task *t)
 {
        if (t->ret != -E_NO_WAV_HEADER && t->ret != -E_WAV_HEADER_SUCCESS) {
-               PARA_ERROR_LOG("%s\n", PARA_STRERROR(-t->ret));
+               PARA_ERROR_LOG("%s\n", para_strerror(-t->ret));
                exit(EXIT_FAILURE);
        }
-       PARA_INFO_LOG("%s\n", PARA_STRERROR(-t->ret));
+       PARA_INFO_LOG("%s\n", para_strerror(-t->ret));
        unregister_task(t);
 //     if (t->ret == -E_WAV_HEADER_SUCCESS) {
 //             conf.channels_arg = cwt.channels;
@@ -244,7 +244,7 @@ int main(int argc, char *argv[])
 
 out:
        if (ret < 0) {
-               PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+               PARA_ERROR_LOG("%s\n", para_strerror(-ret));
                ret = EXIT_FAILURE;
        } else
                ret = EXIT_SUCCESS;
index a8d2114995bcafb74b692ef5a47d275c0a266d4c..882cbe02f45ebc2c8738b06414dd1bff59193922 100644 (file)
@@ -99,7 +99,7 @@ int wng_open(struct writer_node_group *g)
        g->error = 0;
        return 1;
 err_out:
-       PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+       PARA_ERROR_LOG("%s\n", para_strerror(-ret));
        unregister_task(&g->task);
        while (i > 0) {
                struct writer_node *wn = &g->writer_nodes[--i];