From: Andre Noll Date: Fri, 27 Dec 2024 17:24:51 +0000 (+0100) Subject: Rename make_message() -> msg(). X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=f2a5fc677a898a815d6a0aa65ae03f262d3c81c6;p=paraslash.git Rename make_message() -> msg(). This is quite a bit shorter, reducing line length and improving readability. Created with sed -i 's/make_message/msg/g' $(git grep -l make_message) Unfortunately, we had a few local variables named "msg". These needed to be renamed manually. --- diff --git a/acl.c b/acl.c index ddf93ecc..cb4eb82f 100644 --- a/acl.c +++ b/acl.c @@ -133,7 +133,7 @@ char *acl_get_contents(struct list_head *acl) char *ret = NULL; list_for_each_entry_safe(ai, tmp_ai, acl, node) { - char *tmp = make_message("%s%s/%u ", ret? ret : "", + char *tmp = msg("%s%s/%u ", ret? ret : "", inet_ntoa(ai->addr), ai->netmask); free(ret); ret = tmp; diff --git a/afh.c b/afh.c index e419d270..db8bb705 100644 --- a/afh.c +++ b/afh.c @@ -87,7 +87,7 @@ static int rewrite_tags(const char *name, int input_fd, void *map, PARA_ERROR_LOG("failed to fstat fd %d (%s)\n", input_fd, name); return ret; } - tmp_name = make_message("%s.XXXXXX", name); + tmp_name = msg("%s.XXXXXX", name); ret = mkstemp(tmp_name); if (ret < 0) { ret = -ERRNO_TO_PARA_ERROR(errno); @@ -106,7 +106,7 @@ static int rewrite_tags(const char *name, int input_fd, void *map, if (ret < 0) goto out; if (OPT_GIVEN(BACKUP)) { - char *backup_name = make_message("%s~", name); + char *backup_name = msg("%s~", name); ret = xrename(name, backup_name); free(backup_name); if (ret < 0) diff --git a/afh_recv.c b/afh_recv.c index 687b77d9..2dfd8870 100644 --- a/afh_recv.c +++ b/afh_recv.c @@ -37,11 +37,11 @@ static int afh_execute(const struct btr_node *btrn, const char *cmd, char **resu *result = NULL; if (!strcmp(cmd, "seconds_total")) { - *result = make_message("%" PRIu32, pard->afhi.seconds_total); + *result = msg("%" PRIu32, pard->afhi.seconds_total); return 1; } if (!strcmp(cmd, "chunks_total")) { - *result = make_message("%" PRIu32, pard->afhi.chunks_total); + *result = msg("%" PRIu32, pard->afhi.chunks_total); return 1; } if (!strcmp(cmd, "afhi")) { diff --git a/afs.c b/afs.c index 445d5871..21179757 100644 --- a/afs.c +++ b/afs.c @@ -435,24 +435,24 @@ static int activate_mood_or_playlist(const char *arg, struct para_buffer *pb) { enum play_mode mode; int ret; - char *msg; + char *errmsg; if (!arg) { /* load dummy mood */ - ret = mood_load(NULL, NULL, &msg); + ret = mood_load(NULL, NULL, &errmsg); mode = PLAY_MODE_MOOD; } else if (!strncmp(arg, "p/", 2)) { - ret = playlist_load(arg + 2, NULL, &msg); + ret = playlist_load(arg + 2, NULL, &errmsg); mode = PLAY_MODE_PLAYLIST; } else if (!strncmp(arg, "m/", 2)) { - ret = mood_load(arg + 2, NULL, &msg); + ret = mood_load(arg + 2, NULL, &errmsg); mode = PLAY_MODE_MOOD; } else { ret = -ERRNO_TO_PARA_ERROR(EINVAL); - msg = make_message("%s: parse error\n", arg); + errmsg = msg("%s: parse error\n", arg); } if (pb) - para_printf(pb, "%s", msg); - free(msg); + para_printf(pb, "%s", errmsg); + free(errmsg); if (ret < 0) return ret; current_play_mode = mode; @@ -572,8 +572,8 @@ static void get_database_dir(void) database_dir = para_strdup(OPT_STRING_VAL(AFS_DATABASE_DIR)); else { char *home = para_homedir(); - database_dir = make_message( - "%s/.paraslash/afs_database-0.7", home); + database_dir = msg("%s/.paraslash/afs_database-0.7", + home); free(home); } } diff --git a/aft.c b/aft.c index 2fab49b5..8f20980a 100644 --- a/aft.c +++ b/aft.c @@ -1973,7 +1973,7 @@ static int for_each_file_in_dir(const char *dirname, continue; if (!strcmp(entry->d_name, "..")) continue; - tmp = make_message("%s/%s", dirname, entry->d_name); + tmp = msg("%s/%s", dirname, entry->d_name); ret = 0; if (lstat(tmp, &s) != -1) { if (S_ISREG(s.st_mode)) diff --git a/alsa_mix.c b/alsa_mix.c index af4adc46..c53d609b 100644 --- a/alsa_mix.c +++ b/alsa_mix.c @@ -47,7 +47,7 @@ static void alsa_mix_close(struct mixer_handle **handle) static int alsa_mix_open(const char *dev, struct mixer_handle **handle) { int ret; - char *msg; + char *err; struct mixer_handle *h; PARA_INFO_LOG("snd_mixer_{open,attach,register,load}\n"); @@ -56,25 +56,24 @@ static int alsa_mix_open(const char *dev, struct mixer_handle **handle) h->card = para_strdup(dev? dev : "hw:0"); ret = snd_mixer_open(&h->mixer, 0); if (ret < 0) { - msg = make_message("snd_mixer_open() failed: %s", - snd_strerror(ret)); + err = msg("snd_mixer_open() failed: %s", snd_strerror(ret)); goto fail; } ret = snd_mixer_attach(h->mixer, h->card); if (ret < 0) { - msg = make_message("mixer attach error (%s): %s", h->card, + err = msg("mixer attach error (%s): %s", h->card, snd_strerror(ret)); goto fail; } ret = snd_mixer_selem_register(h->mixer, NULL, NULL); if (ret < 0) { - msg = make_message("mixer register error (%s): %s", h->card, + err = msg("mixer register error (%s): %s", h->card, snd_strerror(ret)); goto fail; } ret = snd_mixer_load(h->mixer); if (ret < 0) { - msg = make_message("mixer load error (%s): %s", h->card, + err = msg("mixer load error (%s): %s", h->card, snd_strerror(ret)); goto fail; } @@ -82,8 +81,8 @@ static int alsa_mix_open(const char *dev, struct mixer_handle **handle) *handle = h; return 1; fail: - PARA_NOTICE_LOG("%s\n", msg); - free(msg); + PARA_NOTICE_LOG("%s\n", err); + free(err); alsa_mix_close(&h); return -E_ALSA_MIX_OPEN; } @@ -114,7 +113,7 @@ static char *alsa_mix_get_channels(struct mixer_handle *handle) continue; snd_mixer_selem_get_id(elem, sid); name = snd_mixer_selem_id_get_name(sid); - list = make_message("%s%s%s", + list = msg("%s%s%s", list? list : "", list? ", " : "", name); diff --git a/ao_write.c b/ao_write.c index cc1a4f0f..0a9d3181 100644 --- a/ao_write.c +++ b/ao_write.c @@ -164,7 +164,7 @@ static void aow_show_drivers(void) PARA_DEBUG_LOG("name: %s: %s\n", info->short_name, info->name); PARA_DEBUG_LOG("priority: %d\n", info->priority); for (j = 0; j < info->option_count; j++) { - tmp = make_message("%s%s%s", keys? keys : "", + tmp = msg("%s%s%s", keys? keys : "", keys? ", " : "", info->options[j]); free(keys); diff --git a/attribute.c b/attribute.c index 51630b25..a68b9f33 100644 --- a/attribute.c +++ b/attribute.c @@ -406,7 +406,7 @@ int get_attribute_text(uint64_t *atts, const char *delim, char **text) if (ret < 0) goto err; if (*text) { - char *tmp = make_message("%s%s%s", *text, delim, (char *)obj.data); + char *tmp = msg("%s%s%s", *text, delim, (char *)obj.data); free(*text); *text = tmp; } else diff --git a/audioc.c b/audioc.c index f2e4cb91..3f2f7238 100644 --- a/audioc.c +++ b/audioc.c @@ -246,7 +246,7 @@ __noreturn static void interactive_session(void) history_file = para_strdup(OPT_STRING_VAL(HISTORY_FILE)); else { char *home = para_homedir(); - history_file = make_message("%s/.paraslash/audioc.history", + history_file = msg("%s/.paraslash/audioc.history", home); free(home); } @@ -351,7 +351,7 @@ int main(int argc, char *argv[]) socket_name = para_strdup(OPT_STRING_VAL(SOCKET)); else { char *hn = para_hostname(); - socket_name = make_message("/var/paraslash/audiod_socket.%s", + socket_name = msg("/var/paraslash/audiod_socket.%s", hn); free(hn); } diff --git a/audiod.c b/audiod.c index 3e86af53..cf7044a1 100644 --- a/audiod.c +++ b/audiod.c @@ -302,7 +302,7 @@ __malloc char *get_time_string(void) int slot_num = get_play_time_slot_num(); struct slot_info *s = slot_num < 0? NULL : &slot[slot_num]; bool writer_active = s && s->wns && s->wns[0].btrn; - char *msg; + char *result; if (audiod_status == AUDIOD_OFF) goto empty; @@ -359,7 +359,7 @@ __malloc char *get_time_string(void) out: seconds = PARA_MIN(seconds, length); seconds = PARA_MAX(seconds, 0); - msg = make_message( + result = msg( "%s%d:%02d [%d:%02d] (%d%%/%d:%02d)", s? "" : "~", seconds / 60, @@ -370,8 +370,7 @@ out: length / 60, length % 60 ); - //PARA_DEBUG_LOG("slot %d: %s\n", slot_num, msg); - return msg; + return result; empty: return para_strdup(NULL); } @@ -968,7 +967,7 @@ static int init_default_filters(void) goto out; } /* add "dec" to audio format name */ - tmp = make_message("%sdec", audio_formats[i]); + tmp = msg("%sdec", audio_formats[i]); for (j = 1; filter_get(j); j++) if (!strcmp(tmp, filter_name(j))) break; @@ -1040,7 +1039,7 @@ static void init_local_socket(struct command_task *ct) socket_name = para_strdup(OPT_STRING_VAL(SOCKET)); else { char *hn = para_hostname(); - socket_name = make_message("/var/paraslash/audiod_socket.%s", + socket_name = msg("/var/paraslash/audiod_socket.%s", hn); free(hn); } diff --git a/audiod_command.c b/audiod_command.c index 5f0b35a5..51f4e5a4 100644 --- a/audiod_command.c +++ b/audiod_command.c @@ -225,18 +225,18 @@ static int com_ll(int fd, struct lls_parse_result *lpr) int ret = lls(lls_check_arg_count(lpr, 0, 1, &errctx)); if (ret < 0) { - char *tmp = make_message("%s\n", errctx); + char *tmp = msg("%s\n", errctx); free(errctx); client_write(fd, tmp); free(tmp); return ret; } if (lls_num_inputs(lpr) == 0) { - char *msg; + char *tmp; ll = daemon_get_loglevel(); - msg = make_message("%s\n", sev[ll]); - ret = client_write(fd, msg); - free(msg); + tmp = msg("%s\n", sev[ll]); + ret = client_write(fd, tmp); + free(tmp); return ret; } arg = lls_input(0, lpr); @@ -355,16 +355,16 @@ EXPORT_AUDIOD_CMD_HANDLER(cycle) static int com_version(int fd, struct lls_parse_result *lpr) { int ret; - char *msg; + char *ver; const struct lls_opt_result *r_v; r_v = lls_opt_result(LSG_AUDIOD_CMD_VERSION_OPT_VERBOSE, lpr); if (lls_opt_given(r_v)) - msg = make_message("%s", version_text("audiod")); + ver = msg("%s", version_text("audiod")); else - msg = make_message("%s\n", version_single_line("audiod")); - ret = client_write(fd, msg); - free(msg); + ver = msg("%s\n", version_single_line("audiod")); + ret = client_write(fd, ver); + free(ver); return ret < 0? ret : 0; } EXPORT_AUDIOD_CMD_HANDLER(version) @@ -426,12 +426,12 @@ out: if (ret < 0 && ret != -E_CLIENT_WRITE) { char *tmp; if (errctx) { - tmp = make_message("%s\n", errctx); + tmp = msg("%s\n", errctx); free(errctx); client_write(clifd, tmp); free(tmp); } - tmp = make_message("%s\n", para_strerror(-ret)); + tmp = msg("%s\n", para_strerror(-ret)); client_write(clifd, tmp); free(tmp); } diff --git a/check_wav.c b/check_wav.c index 48a204bb..723913cd 100644 --- a/check_wav.c +++ b/check_wav.c @@ -101,7 +101,7 @@ out: return -E_BTR_NAVAIL; } } - *result = make_message("%d", val); + *result = msg("%d", val); return 1; } diff --git a/client.c b/client.c index d2d11fd3..9cb98e17 100644 --- a/client.c +++ b/client.c @@ -86,7 +86,7 @@ static int create_merged_lpr(const char *line) if (!orig_lpr) orig_lpr = ct->lpr; ct->lpr = NULL; - cmdline = make_message("-- %s", line); + cmdline = msg("-- %s", line); ret = create_shifted_argv(cmdline, " ", &argv); free(cmdline); if (ret < 0) @@ -350,8 +350,8 @@ static void setatt_completer(struct i9e_completion_info *ci, sl = arr_realloc(sl, 2 * num_atts + 1, sizeof(char *)); for (i = 0; i < num_atts; i++) { char *orig = sl[i]; - sl[i] = make_message("%s+", orig); - sl[num_atts + i] = make_message("%s-", orig); + sl[i] = msg("%s+", orig); + sl[num_atts + i] = msg("%s-", orig); free(orig); } sl[2 * num_atts] = NULL; @@ -443,9 +443,9 @@ static void select_completer(struct i9e_completion_info *ci, n = num_moods + num_pl; mops = arr_alloc(n + 1, sizeof(char *)); for (i = 0; i < num_moods; i++) - mops[i] = make_message("m/%s", moods[i]); + mops[i] = msg("m/%s", moods[i]); for (i = 0; i < num_pl; i++) - mops[num_moods + i] = make_message("p/%s", playlists[i]); + mops[num_moods + i] = msg("p/%s", playlists[i]); mops[n] = NULL; i9e_extract_completions(ci->word, mops, &cr->matches); free_argv(mops); @@ -530,7 +530,7 @@ __noreturn static void interactive_session(void) HISTORY_FILE, ct->lpr)); else { char *home = para_homedir(); - ici.history_file = make_message("%s/.paraslash/client.history", + ici.history_file = msg("%s/.paraslash/client.history", home); free(home); } diff --git a/client_common.c b/client_common.c index 396fd88c..962d1fe6 100644 --- a/client_common.c +++ b/client_common.c @@ -588,10 +588,10 @@ int client_parse_config(int argc, char *argv[], struct client_task **ct_ptr, kf = para_strdup(CLIENT_OPT_STRING_VAL(KEY_FILE, lpr)); else { struct stat statbuf; - kf = make_message("%s/.paraslash/key.%s", home, user); + kf = msg("%s/.paraslash/key.%s", home, user); if (stat(kf, &statbuf) != 0) { /* assume file does not exist */ free(kf); - kf = make_message("%s/.ssh/id_rsa", home); + kf = msg("%s/.ssh/id_rsa", home); } } PARA_INFO_LOG("user: %s\n", user); diff --git a/daemon.c b/daemon.c index d8f598be..f0137fbe 100644 --- a/daemon.c +++ b/daemon.c @@ -133,7 +133,7 @@ void daemon_set_logfile(const char *logfile_name) if (!logfile_name) return; if (me->old_cwd && logfile_name[0] != '/') - me->logfile_name = make_message("%s/%s", me->old_cwd, + me->logfile_name = msg("%s/%s", me->old_cwd, logfile_name); else me->logfile_name = para_strdup(logfile_name); @@ -431,8 +431,7 @@ time_t daemon_get_uptime(const struct timeval *current_time) __malloc char *daemon_get_uptime_str(const struct timeval *current_time) { long t = daemon_get_uptime(current_time); - return make_message("%li:%02li:%02li", t / 86400, - (t / 3600) % 24, (t / 60) % 60); + return msg("%li:%02li:%02li", t / 86400, (t / 3600) % 24, (t / 60) % 60); } /** diff --git a/dccp_send.c b/dccp_send.c index 6182c964..c76b1dce 100644 --- a/dccp_send.c +++ b/dccp_send.c @@ -143,7 +143,7 @@ static void dccp_post_monitor(__a_unused struct sched *s) /* If CCID identifiable, present client as #~ */ tx_ccid = dccp_get_tx_ccid(sc->fd); if (tx_ccid != -1) { - char *tmp = make_message("%s~%d", sc->name, tx_ccid); + char *tmp = msg("%s~%d", sc->name, tx_ccid); free(sc->name); sc->name = tmp; @@ -226,7 +226,7 @@ static const char *dccp_list_available_ccids(void) static char *dccp_status(void) { char *status = generic_sender_status(dss, "dccp"); - char *result = make_message("%ssupported ccids: %s\n", status, + char *result = msg("%ssupported ccids: %s\n", status, dccp_list_available_ccids()); free(status); return result; diff --git a/file_write.c b/file_write.c index ba902070..5dfb106c 100644 --- a/file_write.c +++ b/file_write.c @@ -34,8 +34,7 @@ __must_check __malloc static char *random_filename(void) char *result, *home = para_homedir(); srandom(clock_get_realtime(NULL)->tv_usec); - result = make_message("%s/.paraslash/%08ld", home, - para_random(99999999)); + result = msg("%s/.paraslash/%08ld", home, para_random(99999999)); free(home); return result; } diff --git a/filter_common.c b/filter_common.c index bcc79f55..8bfd744e 100644 --- a/filter_common.c +++ b/filter_common.c @@ -92,8 +92,7 @@ int filter_setup(const char *fa, void **conf, struct lls_parse_result **lprp) cmd = FILTER_CMD(filter_num); if (!filter_supported(filter_num)) { ret = -E_UNSUPPORTED_FILTER; - errctx = make_message("bad filter name: %s", - lls_command_name(cmd)); + errctx = msg("bad filter name: %s", lls_command_name(cmd)); goto free_argv; } ret = lls(lls_parse(argc, argv, cmd, lprp, &errctx)); @@ -212,17 +211,17 @@ int decoder_execute(const char *cmd, unsigned sample_rate, unsigned channels, if (!strcmp(cmd, "sample_rate")) { if (sample_rate == 0) return -E_BTR_NAVAIL; - *result = make_message("%u", sample_rate); + *result = msg("%u", sample_rate); return 1; } if (!strcmp(cmd, "channels")) { if (channels == 0) return -E_BTR_NAVAIL; - *result = make_message("%u", channels); + *result = msg("%u", channels); return 1; } if (!strcmp(cmd, "sample_format")) { - *result = make_message("%d", DECODER_SAMPLE_FORMAT); + *result = msg("%d", DECODER_SAMPLE_FORMAT); return 1; } return -ERRNO_TO_PARA_ERROR(ENOTSUP); diff --git a/flac_afh.c b/flac_afh.c index 2b5b6c1d..851d7281 100644 --- a/flac_afh.c +++ b/flac_afh.c @@ -418,7 +418,7 @@ static int flac_get_file_info(char *map, size_t map_bytes, __a_unused int fd, free_tags(&afhi->tags); return ret; } - afhi->techinfo = make_message("blocksize: %u", pfad->blocksize); + afhi->techinfo = msg("blocksize: %u", pfad->blocksize); afhi->seconds_total = DIV_ROUND_UP(afhi->chunks_total * pfad->blocksize, afhi->frequency); afhi->bitrate = pfad->map_bytes * 8 / afhi->seconds_total / 1024; diff --git a/gui.c b/gui.c index 2ad8ae46..3a12cae0 100644 --- a/gui.c +++ b/gui.c @@ -550,7 +550,7 @@ static void print_stat_item(int i) if (!curses_active() || !d.len || !c) return; - tmp = make_message("%s%s%s", d.prefix, c, d.postfix); + tmp = msg("%s%s%s", d.prefix, c, d.postfix); wmove(top.win, d.y * top_lines / 100, d.x * COLS / 100); wattron(top.win, COLOR_PAIR(i + 1)); align_str(top.win, tmp, d.len * COLS / 100, d.align); @@ -1029,7 +1029,7 @@ static void exec_para(const char *args) { char *file_and_args; - file_and_args = make_message(BINDIR "/para_client -- %s", args); + file_and_args = msg(BINDIR "/para_client -- %s", args); exec_and_display(file_and_args); free(file_and_args); } diff --git a/http_recv.c b/http_recv.c index 8d2add19..4e3bfaf9 100644 --- a/http_recv.c +++ b/http_recv.c @@ -50,7 +50,7 @@ struct private_http_recv_data { static char *make_request_msg(void) { char *ret, *hn = para_hostname(); - ret = make_message("%s1.0\nHost: %s\nUser-Agent: para_recv/%s\n\n\n", + ret = msg("%s1.0\nHost: %s\nUser-Agent: para_recv/%s\n\n\n", HTTP_GET_MSG, hn, PACKAGE_VERSION); free(hn); return ret; diff --git a/lsu.c b/lsu.c index 8ccf80d5..3e22d36d 100644 --- a/lsu.c +++ b/lsu.c @@ -183,7 +183,7 @@ int lsu_merge_config_file_options(const char *path, const char *dflt, cf = para_strdup(path); else { char *home = para_homedir(); - cf = make_message("%s/.paraslash/%s", home, dflt); + cf = msg("%s/.paraslash/%s", home, dflt); free(home); } ret = mmap_full_file(cf, O_RDONLY, &map, &sz, NULL); diff --git a/mixer.c b/mixer.c index dda7fc1d..dbffb79a 100644 --- a/mixer.c +++ b/mixer.c @@ -191,7 +191,7 @@ static void run(const char *exe, const char *cmd) { int ret, status, fds[3] = {0, 0, 0}; pid_t pid; - char *cmdline = make_message("%s %s", exe, cmd); + char *cmdline = msg("%s %s", exe, cmd); PARA_NOTICE_LOG("%s\n", cmdline); ret = para_exec_cmdline_pid(&pid, cmdline, fds); @@ -229,7 +229,7 @@ static void change_afs_mode(const char *afs_mode) { char *cmd; - cmd = make_message("select %s", afs_mode); + cmd = msg("select %s", afs_mode); client_cmd(cmd); free(cmd); } diff --git a/mood.c b/mood.c index 1e15ef0e..8eddf61c 100644 --- a/mood.c +++ b/mood.c @@ -158,13 +158,13 @@ static int init_mood_parser(const char *mood_name, struct mood_instance **m, if (!*mood_name) { if (err) - *err = make_message("empty mood name\n"); + *err = msg("empty mood name\n"); return -ERRNO_TO_PARA_ERROR(EINVAL); } ret = mood_get_def_by_name(mood_name, &mood_def); if (ret < 0) { if (err) - *err = make_message("could not read mood definition\n"); + *err = msg("could not read mood definition\n"); return ret; } *m = alloc_new_mood(mood_name); @@ -534,10 +534,10 @@ static char *get_statistics(struct mood_instance *m, int64_t sse) int mean_days, sigma_days; if (n == 0) - return make_message("no admissible files\n"); + return msg("no admissible files\n"); mean_days = (sse - m->stats.last_played_sum / n) / 3600 / 24; sigma_days = int_sqrt(m->stats.last_played_qd / n) / 3600 / 24; - return make_message( + return msg( "loaded mood %s (%u files)\n" "last_played mean/sigma: %d/%d days\n" "num_played mean/sigma: %" PRId64 "/%" PRIu64 "\n" @@ -596,7 +596,7 @@ static void compute_correction_factors(int64_t sse, struct afs_statistics *s) * * \param mood_name The name of the mood to load. * \param result Opaque, refers to the mood parser and the score table. - * \param msg Error message or mood info is returned here. + * \param errmsg Error message or mood info is returned here. * * If the mood name is NULL, the dummy mood is loaded. This mood regards every * audio file as admissible. @@ -620,7 +620,7 @@ static void compute_correction_factors(int64_t sse, struct afs_statistics *s) * * \sa \ref mp_eval_row(). */ -int mood_load(const char *mood_name, struct mood_instance **result, char **msg) +int mood_load(const char *mood_name, struct mood_instance **result, char **errmsg) { int i, ret; struct admissible_array aa = {.size = 0}; @@ -631,7 +631,7 @@ int mood_load(const char *mood_name, struct mood_instance **result, char **msg) struct timeval rnow; if (mood_name) { - ret = init_mood_parser(mood_name, &aa.m, msg); + ret = init_mood_parser(mood_name, &aa.m, errmsg); if (ret < 0) return ret; } else /* load dummy mood */ @@ -639,8 +639,8 @@ int mood_load(const char *mood_name, struct mood_instance **result, char **msg) PARA_NOTICE_LOG("computing statistics of admissible files\n"); ret = audio_file_loop(&aa, add_if_admissible); if (ret < 0) { - if (msg) /* false if we are called via the event handler */ - *msg = make_message("audio file loop failed\n"); + if (errmsg) /* false if we are called via the event handler */ + *errmsg = msg("audio file loop failed\n"); goto out; } clock_get_realtime(&rnow); @@ -650,15 +650,15 @@ int mood_load(const char *mood_name, struct mood_instance **result, char **msg) for (i = 0; i < aa.m->stats.num; i++) { ret = add_to_score_table(aa.array[i], aa.m); if (ret < 0) { - if (msg) - *msg = make_message( + if (errmsg) + *errmsg = msg( "could not add row to score table\n"); goto out; } } /* success */ - if (msg) - *msg = get_statistics(aa.m, rnow.tv_sec); + if (errmsg) + *errmsg = get_statistics(aa.m, rnow.tv_sec); ret = aa.m->stats.num; if (result) *result = aa.m; diff --git a/mp3_afh.c b/mp3_afh.c index 56f28a09..f7834243 100644 --- a/mp3_afh.c +++ b/mp3_afh.c @@ -80,7 +80,7 @@ static char *get_stringlist(union id3_field *field) char *tmp = (char *)get_utf8(id3_field_getstrings(field, k)); if (result) { char *tmp2 = result; - result = make_message("%s %s", tmp2, tmp); + result = msg("%s %s", tmp2, tmp); free(tmp); free(tmp2); } else @@ -650,7 +650,7 @@ static int mp3_read_info(unsigned char *map, size_t numbytes, int fd, tv2ms(&afhi->chunk_tv)); set_max_chunk_size(afhi); ret = mp3_get_id3(map, numbytes, fd, &afhi->tags); - afhi->techinfo = make_message("%cbr, %s, %s tags", vbr? 'v' : 'c', + afhi->techinfo = msg("%cbr, %s, %s tags", vbr? 'v' : 'c', header_mode(&header), tag_versions[ret]); return 1; err_out: diff --git a/net.c b/net.c index 9b362442..97f4ae67 100644 --- a/net.c +++ b/net.c @@ -196,11 +196,11 @@ __malloc char *format_url(const char *url, int default_port) int url_port; if (!url) - return make_message("0.0.0.0:%d", default_port); + return msg("0.0.0.0:%d", default_port); if (!parse_url(url, host, sizeof(host), &url_port)) - return make_message("?"); + return msg("?"); if (url_port < 0) - return make_message("%s:%d", url, default_port); + return msg("%s:%d", url, default_port); else return para_strdup(url); } diff --git a/opus_afh.c b/opus_afh.c index 0a291bb1..5db33d58 100644 --- a/opus_afh.c +++ b/opus_afh.c @@ -100,7 +100,7 @@ static int opus_packet_callback(ogg_packet *packet, int packet_num, if (ret < 0) return ret; afhi->channels = oh->channels; - afhi->techinfo = make_message( + afhi->techinfo = msg( "header version %d, input sample rate: %" PRIu32 "Hz", oh->version, oh->input_sample_rate); /* diff --git a/oss_mix.c b/oss_mix.c index 0814336f..290ea50d 100644 --- a/oss_mix.c +++ b/oss_mix.c @@ -70,7 +70,7 @@ static char *oss_mix_get_channels(__a_unused struct mixer_handle *handle) FOR_EACH_CHANNEL(i) { const char *name = channels[i].name; char *tmp = list; - list = make_message("%s%s%s", + list = msg("%s%s%s", list? list : "", list? ", " : "", name); diff --git a/play.c b/play.c index 596b4b6d..f30b093c 100644 --- a/play.c +++ b/play.c @@ -322,7 +322,7 @@ static int open_new_file(void) free(pt->afhi_txt); ret = btr_exec_up(pt->rn.btrn, "afhi", &pt->afhi_txt); if (ret < 0) - pt->afhi_txt = make_message("[afhi command failed]\n"); + pt->afhi_txt = msg("[afhi command failed]\n"); ret = btr_exec_up(pt->rn.btrn, "seconds_total", &tmp); if (ret < 0) pt->seconds = 1; @@ -374,7 +374,7 @@ static int load_file(void) return 0; /* set up decoding filter */ af = audio_format_name(pt->audio_format_num); - tmp = make_message("%sdec", af); + tmp = msg("%sdec", af); ret = filter_setup(tmp, &pt->fn.conf, &filter_lpr); freep(&tmp); if (ret < 0) @@ -1038,7 +1038,7 @@ static void session_open(void) history_file = para_strdup(OPT_STRING_VAL(HISTORY_FILE)); else { char *home = para_homedir(); - char *dot_para = make_message("%s/.paraslash", home); + char *dot_para = msg("%s/.paraslash", home); free(home); ret = para_mkdir(dot_para); @@ -1046,7 +1046,7 @@ static void session_open(void) if (ret < 0) PARA_WARNING_LOG("Can not create %s: %s\n", dot_para, para_strerror(-ret)); - history_file = make_message("%s/play.history", dot_para); + history_file = msg("%s/play.history", dot_para); free(dot_para); } ici.history_file = history_file; diff --git a/playlist.c b/playlist.c index 0a246244..b5234a71 100644 --- a/playlist.c +++ b/playlist.c @@ -140,21 +140,21 @@ void playlist_unload(struct playlist_instance *pi) * * \param name The name of the playlist to load. * \param result Opaque, refers to the underlying score table. - * \param msg Error message or playlist info is returned here. + * \param errmsg Error message or playlist info is returned here. * * \return The length of the loaded playlist on success, negative error code * else. Files which are listed in the playlist, but are not contained in the * database are ignored. This is not considered an error. */ -int playlist_load(const char *name, struct playlist_instance **result, char **msg) +int playlist_load(const char *name, struct playlist_instance **result, char **errmsg) { int ret; struct playlist_instance *pi; struct osl_object playlist_def; if (!name || !*name) { - if (msg) - *msg = make_message("empty playlist name\n"); + if (errmsg) + *errmsg = msg("empty playlist name\n"); return -ERRNO_TO_PARA_ERROR(EINVAL); } ret = pl_get_def_by_name(name, &playlist_def); @@ -172,8 +172,8 @@ int playlist_load(const char *name, struct playlist_instance **result, char **ms if (pi->length == 0) goto close_score_table; /* success */ - if (msg) - *msg = make_message("loaded playlist %s (%u files)\n", name, + if (errmsg) + *errmsg = msg("loaded playlist %s (%u files)\n", name, pi->length); pi->name = para_strdup(name); if (result) { @@ -190,8 +190,8 @@ close_score_table: free(pi); err: PARA_NOTICE_LOG("unable to load playlist %s\n", name); - if (msg) - *msg = make_message("unable to load playlist %s\n", name); + if (errmsg) + *errmsg = msg("unable to load playlist %s\n", name); return ret; } diff --git a/sched.c b/sched.c index 20822038..0ab61202 100644 --- a/sched.c +++ b/sched.c @@ -255,18 +255,18 @@ struct task *task_register(struct task_info *info, struct sched *s) char *get_task_list(struct sched *s) { struct task *t, *tmp; - char *msg = NULL; + char *result = NULL; list_for_each_entry_safe(t, tmp, &s->task_list, node) { char *tmp_msg; - tmp_msg = make_message("%s%p\t%s\t%s\n", msg? msg : "", t, + tmp_msg = msg("%s%p\t%s\t%s\n", result? result : "", t, t->status == TS_DEAD? "dead" : (t->status == TS_RUNNING? "running" : "zombie"), t->name); - free(msg); - msg = tmp_msg; + free(result); + result = tmp_msg; } - return msg; + return result; } /** diff --git a/send_common.c b/send_common.c index 8dc82e9c..6010ac8c 100644 --- a/send_common.c +++ b/send_common.c @@ -189,20 +189,20 @@ __malloc char *generic_sender_status(struct sender_status *ss, const char *name) char *acl_contents = acl_get_contents(&ss->acl); list_for_each_entry_safe(sc, tmp_sc, &ss->client_list, node) { - char *tmp = make_message("%s%s ", clnts? clnts : "", sc->name); + char *tmp = msg("%s%s ", clnts? clnts : "", sc->name); free(clnts); clnts = tmp; } FOR_EACH_LISTEN_FD(n, ss) { char *url = format_url(ss->listen_addresses[n], ss->default_port); - char *tmp = make_message("%s%s%s (fd %d)", addr? + char *tmp = msg("%s%s%s (fd %d)", addr? addr : "", addr? ", " : "", url, ss->listen_fds[n]); free(url); free(addr); addr = tmp; } - ret = make_message( + ret = msg( "listening address(es): %s\n" "default port: %s\n" "number of connected clients: %d\n" @@ -415,7 +415,7 @@ warn: */ __malloc char *generic_sender_help(void) { - return make_message( + return msg( "usage: {on|off}\n" "usage: {allow|deny} IP[/netmask]\n" " where mask defaults to 32\n" diff --git a/server.c b/server.c index ea9cc9c0..b78ca0b2 100644 --- a/server.c +++ b/server.c @@ -233,7 +233,7 @@ void parse_config_or_die(bool reload) user_list_file = para_strdup(OPT_STRING_VAL(USER_LIST)); else { char *home = para_homedir(); - user_list_file = make_message("%s/.paraslash/server.users", home); + user_list_file = msg("%s/.paraslash/server.users", home); free(home); } user_list_init(user_list_file); diff --git a/spx_afh.c b/spx_afh.c index cd3b7cde..f5eb3459 100644 --- a/spx_afh.c +++ b/spx_afh.c @@ -129,7 +129,7 @@ static int spx_packet_callback(ogg_packet *packet, int packet_num, afhi->channels = psd->shi.channels; afhi->frequency = psd->shi.sample_rate; afhi->bitrate = psd->shi.bitrate / 1000; - afhi->techinfo = make_message("%s, v%d", psd->shi.mode->modeName, + afhi->techinfo = msg("%s, v%d", psd->shi.mode->modeName, psd->shi.mode->bitstream_version); return 1; } diff --git a/string.c b/string.c index d8bd027b..d125bdf1 100644 --- a/string.c +++ b/string.c @@ -234,7 +234,7 @@ __printf_2_3 unsigned xasprintf(char **result, const char *fmt, ...) * * \sa printf(3), \ref xasprintf(). */ -__must_check __printf_1_2 __malloc char *make_message(const char *fmt, ...) +__must_check __printf_1_2 __malloc char *msg(const char *fmt, ...) { char *msg; va_list ap; @@ -287,7 +287,7 @@ __must_check __malloc char *para_strcat(char *a, const char *b) return para_strdup(b); if (!b) return a; - tmp = make_message("%s%s", a, b); + tmp = msg("%s%s", a, b); free(a); return tmp; } @@ -500,7 +500,7 @@ int read_size_header(const char *buf) * size-bound on \a b, i.e. if \p b->max_size is zero, this function never * fails. * - * \sa make_message(), vsnprintf(3). + * \sa msg(), vsnprintf(3). */ __printf_2_3 int para_printf(struct para_buffer *b, const char *fmt, ...) { diff --git a/string.h b/string.h index d773600f..440aead5 100644 --- a/string.h +++ b/string.h @@ -77,7 +77,7 @@ __must_check __malloc char *para_strdup(const char *s); __printf_2_0 unsigned xvasprintf(char **result, const char *fmt, va_list ap); __printf_2_3 unsigned xasprintf(char **result, const char *fmt, ...); -__must_check __malloc __printf_1_2 char *make_message(const char *fmt, ...); +__must_check __malloc __printf_1_2 char *msg(const char *fmt, ...); __must_check __malloc char *para_strcat(char *a, const char *b); __must_check __malloc char *para_logname(void); __must_check __malloc char *para_homedir(void); diff --git a/udp_send.c b/udp_send.c index fe001025..ff79b5d6 100644 --- a/udp_send.c +++ b/udp_send.c @@ -370,7 +370,7 @@ static char *udp_status(void) list_for_each_entry(sc, &targets, node) { struct udp_target *ut = sc->private_data; - char *tmp = make_message("%s%s/%u:%u ", + char *tmp = msg("%s%s/%u:%u ", tgts ? : "", sc->name, ut->fcp.data_slices_per_group, ut->fcp.slices_per_group @@ -378,7 +378,7 @@ static char *udp_status(void) free(tgts); tgts = tmp; } - ret = make_message( + ret = msg( "status: %s\n" "port: %s\n" "targets: %s\n", @@ -408,7 +408,7 @@ static void udp_init_target_list(void) static char *udp_help(void) { - return make_message( + return msg( "usage: {on|off}\n" "usage: {add|delete} ip_address[:port][/[packet_size:]k:n]\n" " - k is the number of data slices per FEC group\n" diff --git a/upgrade_db.c b/upgrade_db.c index 487d46c0..e1fef5cb 100644 --- a/upgrade_db.c +++ b/upgrade_db.c @@ -82,17 +82,15 @@ static void set_paths(const struct lls_parse_result *lpr) src_db_dir = para_strdup(OPT_STRING_VAL(SRC_DATABASE_DIR, lpr)); else - src_db_dir = make_message( - "%s/.paraslash/afs_database-0.4", home); + src_db_dir = msg( "%s/.paraslash/afs_database-0.4", home); if (OPT_GIVEN(DST_DATABASE_DIR, lpr)) dst_db_dir = para_strdup(OPT_STRING_VAL(DST_DATABASE_DIR, lpr)); else - dst_db_dir = make_message( - "%s/.paraslash/afs_database-0.7", home); + dst_db_dir = msg( "%s/.paraslash/afs_database-0.7", home); free(home); - src_aft_dir = make_message("%s/audio_files", src_db_dir); - dst_aft_dir = make_message("%s/audio-files", src_db_dir); + src_aft_dir = msg("%s/audio_files", src_db_dir); + dst_aft_dir = msg("%s/audio-files", src_db_dir); PARA_NOTICE_LOG("source aft dir: %s\n", src_aft_dir); PARA_NOTICE_LOG("destination aft dir: %s\n", dst_aft_dir); } @@ -314,7 +312,7 @@ static int remove_source_aft(void) pid_t pid; int fds[3] = {-1, -1, -1}; /* no redirection of stdin/stdout/stderr */ int ret, wstatus; - char *cmdline = make_message("rm -rf %s", src_aft_dir); + char *cmdline = msg("rm -rf %s", src_aft_dir); PARA_NOTICE_LOG("removing %s\n", src_aft_dir); ret = para_exec_cmdline_pid(&pid, cmdline, fds); diff --git a/wma_afh.c b/wma_afh.c index 8bff7cfc..906664d0 100644 --- a/wma_afh.c +++ b/wma_afh.c @@ -250,7 +250,7 @@ static int wma_get_file_info(char *map, size_t numbytes, __a_unused int fd, afhi->channels = ahi.channels; afhi->header_len = ahi.header_len; - afhi->techinfo = make_message("%s%s%s%s%s", + afhi->techinfo = msg("%s%s%s%s%s", ahi.use_exp_vlc? "exp vlc" : "", (ahi.use_bit_reservoir && ahi.use_exp_vlc)? ", " : "", ahi.use_bit_reservoir? "bit reservoir" : "", diff --git a/write_common.c b/write_common.c index 9a130905..295109ee 100644 --- a/write_common.c +++ b/write_common.c @@ -102,7 +102,7 @@ int check_writer_arg_or_die(const char *wa, struct lls_parse_result **lprp) cmd = WRITE_CMD(writer_num); if (!writer_supported(writer_num)) { ret = -ERRNO_TO_PARA_ERROR(EINVAL); - errctx = make_message("%s writer is not supported", + errctx = msg("%s writer is not supported", lls_command_name(cmd)); goto free_argv; }