From: Andre Noll Date: Fri, 28 Dec 2007 13:36:10 +0000 (+0100) Subject: Turn PARA_STRERROR into an inline function. X-Git-Tag: v0.3.0~21 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=c73d23911d78ed10179c12ef8f79a3fcf3bbcdaf;p=paraslash.git Turn PARA_STRERROR into an inline function. Add documentation and an assertion for (num > 0). --- diff --git a/aacdec.c b/aacdec.c index 258864a0..c200c558 100644 --- 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); diff --git a/afh_common.c b/afh_common.c index 5c283e27..a726254a 100644 --- a/afh_common.c +++ b/afh_common.c @@ -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 295933ec..018fc5dc 100644 --- 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 2cdeb20c..51703aa4 100644 --- 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; } diff --git a/attribute.c b/attribute.c index dd1be5d8..e306aa2e 100644 --- a/attribute.c +++ b/attribute.c @@ -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; } diff --git a/audioc.c b/audioc.c index aa7184e0..a078c48c 100644 --- 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; } diff --git a/audiod.c b/audiod.c index f83943a6..dfd62e6f 100644 --- 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; } diff --git a/audiod_command.c b/audiod_command.c index 855e5cea..773bba8b 100644 --- a/audiod_command.c +++ b/audiod_command.c @@ -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 8675ee73..b7dd908f 100644 --- 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 { diff --git a/client.c b/client.c index 07da6529..438707d7 100644 --- 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; } diff --git a/client_common.c b/client_common.c index 5359b299..28c03d41 100644 --- a/client_common.c +++ b/client_common.c @@ -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; } diff --git a/command.c b/command.c index 6886ae9b..fee817b0 100644 --- 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); diff --git a/dccp_send.c b/dccp_send.c index f3b9120b..7ec6e686 100644 --- a/dccp_send.c +++ b/dccp_send.c @@ -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 4bc9f155..3fa657e6 100644 --- 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. # diff --git a/filter.c b/filter.c index 27bbe63e..fb36a557 100644 --- 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 04916384..a40ff379 100644 --- 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", diff --git a/http_send.c b/http_send.c index 28e245ea..e60b3f90 100644 --- a/http_send.c +++ b/http_send.c @@ -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 5908a93d..0f907cc0 100644 --- 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; diff --git a/mp3_afh.c b/mp3_afh.c index f5fc7113..a6a421a6 100644 --- 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; } diff --git a/playlist.c b/playlist.c index 826280b9..8955ea9d 100644 --- a/playlist.c +++ b/playlist.c @@ -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 d1909f25..0875d17d 100644 --- 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 7d3b0246..8f75a1a0 100644 --- 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; diff --git a/server.c b/server.c index 17ff7cb4..73986f6d 100644 --- 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); } diff --git a/signal.c b/signal.c index cc49da11..67af1655 100644 --- 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 25eca2ef..40f02c1c 100644 --- 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); } diff --git a/stdout.c b/stdout.c index babed752..178f3eeb 100644 --- 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); } diff --git a/user_list.c b/user_list.c index 8e21b238..45501ad1 100644 --- a/user_list.c +++ b/user_list.c @@ -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 b18c7313..a55e0915 100644 --- 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 125df1c1..c425c7cb 100644 --- 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; diff --git a/write_common.c b/write_common.c index a8d21149..882cbe02 100644 --- a/write_common.c +++ b/write_common.c @@ -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];