From: Andre Noll Date: Wed, 28 Dec 2016 19:38:34 +0000 (+0100) Subject: Merge branch 'refs/heads/t/format-signedness' X-Git-Tag: v0.5.7~6 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=b52342d0b5df5446f149f0c1daf26f6e25b2aba7;hp=ee1015b8fbb06705fcddff926cb028ff61adaff6 Merge branch 'refs/heads/t/format-signedness' This series fixes all warnings produced by compiling with -Wformat-signedness and adds the flag to CFLAGS if the compiler supports it. * refs/heads/t/format-signedness (cooking for ~2 weeks): gcrypt: Fix a few format-signedness issues. Compile with -Wformat-signedness if possible. Fix signedness issues in format strings. --- diff --git a/Makefile.real b/Makefile.real index ce4881d2..464cd68e 100644 --- a/Makefile.real +++ b/Makefile.real @@ -128,6 +128,13 @@ ifeq ($(uname_s),Linux) LDFLAGS += -Wl,--gc-sections endif +cc-option = $(shell \ + $(CC) $(1) -Werror -c -x c /dev/null -o /dev/null > /dev/null 2>&1 \ + && echo "$(1)" \ +) + +STRICT_CFLAGS += $(call cc-option, -Wformat-signedness) + # To put more focus on warnings, be less verbose as default # Use 'make V=1' to see the full commands ifeq ("$(origin V)", "command line") diff --git a/NEWS.md b/NEWS.md index 10e78ca5..a7af7717 100644 --- a/NEWS.md +++ b/NEWS.md @@ -14,6 +14,7 @@ NEWS - The openssl code has been adjusted to work also with openssl-1.1. - The wma decoder and audio format handler now correctly decodes files with unusual block sizes. +- We now compile with -Wformat-signedness if possible. Download: [tarball](./releases/paraslash-git.tar.bz2) diff --git a/aac_afh.c b/aac_afh.c index a30be96f..1c7fd706 100644 --- a/aac_afh.c +++ b/aac_afh.c @@ -34,11 +34,11 @@ static int aac_find_stsz(char *buf, size_t buflen, off_t *skip) PARA_DEBUG_LOG("found stsz@%d\n", i); i += 8; sample_size = read_u32_be(buf + i); - PARA_DEBUG_LOG("sample size: %d\n", sample_size); + PARA_DEBUG_LOG("sample size: %u\n", sample_size); i += 4; sample_count = read_u32_be(buf + i); i += 4; - PARA_DEBUG_LOG("sample count: %d\n", sample_count); + PARA_DEBUG_LOG("sample count: %u\n", sample_count); *skip = i; return sample_count; } diff --git a/aac_common.c b/aac_common.c index 70a9d77d..812c742c 100644 --- a/aac_common.c +++ b/aac_common.c @@ -73,18 +73,18 @@ int aac_find_esds(char *buf, size_t buflen, size_t *skip, continue; i += 8; p = buf + i; - PARA_INFO_LOG("found esds@%zu, next: %x\n", i, *p); + PARA_INFO_LOG("found esds@%zu, next: %x\n", i, (unsigned)*p); if (*p == 3) i += 8; else i += 6; p = buf + i; - PARA_INFO_LOG("next: %x\n", *p); + PARA_INFO_LOG("next: %x\n", (unsigned)*p); if (*p != 4) continue; i += 18; p = buf + i; - PARA_INFO_LOG("next: %x\n", *p); + PARA_INFO_LOG("next: %x\n", (unsigned)*p); if (*p != 5) continue; i++; diff --git a/aacdec_filter.c b/aacdec_filter.c index 9791175e..5725ce04 100644 --- a/aacdec_filter.c +++ b/aacdec_filter.c @@ -127,7 +127,7 @@ next_buffer: } padd->sample_rate = rate; padd->channels = channels; - PARA_INFO_LOG("rate: %u, channels: %d\n", + PARA_INFO_LOG("rate: %u, channels: %u\n", padd->sample_rate, padd->channels); padd->initialized = 1; } @@ -171,7 +171,7 @@ next_buffer: goto success; } PARA_ERROR_LOG("%s\n", NeAACDecGetErrorMessage(err)); - PARA_ERROR_LOG("consumed: %zu + %zd + %lu\n", + PARA_ERROR_LOG("consumed: %zu + %zu + %lu\n", padd->consumed_total, consumed, padd->frame_info.bytesconsumed); if (consumed < len) diff --git a/acl.c b/acl.c index 5ef9a51c..560ff999 100644 --- a/acl.c +++ b/acl.c @@ -87,7 +87,7 @@ static void acl_add_entry(struct list_head *acl, char *addr, int netmask) inet_pton(AF_INET, addr, &ai->addr); ai->netmask = netmask; - PARA_INFO_LOG("adding %s/%i to access list\n", addr, ai->netmask); + PARA_INFO_LOG("adding %s/%u to access list\n", addr, ai->netmask); para_list_add(&ai->node, acl); } @@ -109,7 +109,7 @@ static void acl_del_entry(struct list_head *acl, char *addr, unsigned netmask) if (v4_addr_match(to_delete.s_addr, ai->addr.s_addr, PARA_MIN(netmask, ai->netmask))) { - PARA_NOTICE_LOG("removing %s/%i from access list\n", + PARA_NOTICE_LOG("removing %s/%u from access list\n", addr, ai->netmask); list_del(&ai->node); free(ai); @@ -131,7 +131,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/%d ", ret? ret : "", + char *tmp = make_message("%s%s/%u ", ret? ret : "", inet_ntoa(ai->addr), ai->netmask); free(ret); ret = tmp; diff --git a/afh_recv.c b/afh_recv.c index 16463463..28d8f398 100644 --- a/afh_recv.c +++ b/afh_recv.c @@ -205,7 +205,7 @@ static int afh_recv_post_select(__a_unused struct sched *s, void *context) afh_get_chunk(pard->first_chunk, afhi, pard->map, &start, &size); afh_get_chunk(pard->last_chunk, afhi, pard->map, &end, &size); end += size; - PARA_INFO_LOG("adding %zu bytes\n", end - start); + PARA_INFO_LOG("adding %td bytes\n", end - start); btr_add_output_dont_free(start, end - start, btrn); ret = -E_RECV_EOF; goto out; diff --git a/afs.c b/afs.c index 071f657c..0946b6df 100644 --- a/afs.c +++ b/afs.c @@ -706,7 +706,7 @@ static int open_afs_tables(void) int i, ret; get_database_dir(); - PARA_NOTICE_LOG("opening %u osl tables in %s\n", NUM_AFS_TABLES, + PARA_NOTICE_LOG("opening %d osl tables in %s\n", NUM_AFS_TABLES, database_dir); for (i = 0; i < NUM_AFS_TABLES; i++) { ret = afs_tables[i].open(database_dir); @@ -1202,7 +1202,7 @@ __must_check int afs_event(enum afs_events event, struct para_buffer *pb, continue; ret = t->event_handler(event, pb, data); if (ret < 0) { - PARA_CRIT_LOG("table %s, event %d: %s\n", t->name, + PARA_CRIT_LOG("table %s, event %u: %s\n", t->name, event, para_strerror(-ret)); return ret; } diff --git a/aft.c b/aft.c index df295246..77891342 100644 --- a/aft.c +++ b/aft.c @@ -738,11 +738,11 @@ static void get_duration_buf(int seconds, char *buf, struct ls_options *opts) if (!hours) { /* m:ss or mm:ss */ max_width = opts->mode == LS_MODE_LONG? opts->widths.duration_width : 4; - sprintf(buf, "%*u:%02u", max_width - 3, mins, seconds % 60); + sprintf(buf, "%*u:%02d", max_width - 3, mins, seconds % 60); } else { /* more than one hour => h:mm:ss, hh:mm:ss, hhh:mm:ss, ... */ max_width = opts->mode == LS_MODE_LONG? opts->widths.duration_width : 7; - sprintf(buf, "%*u:%02u:%02u", max_width - 6, hours, mins, + sprintf(buf, "%*u:%02u:%02d", max_width - 6, hours, mins, seconds % 60); } } @@ -876,14 +876,14 @@ static int print_list_item(struct ls_data *d, struct ls_options *opts, para_printf(b, "%s " /* attributes */ "%*u " /* amp */ - "%*d " /* image_id */ - "%*d " /* lyrics_id */ - "%*d " /* bitrate */ + "%*u " /* image_id */ + "%*u " /* lyrics_id */ + "%*u " /* bitrate */ "%*s " /* audio format */ - "%*d " /* frequency */ - "%d " /* channels */ + "%*u " /* frequency */ + "%u " /* channels */ "%s " /* duration */ - "%*d " /* num_played */ + "%*u " /* num_played */ "%s " /* last_played */ "%s\n", /* path */ att_buf, @@ -930,7 +930,7 @@ static int print_list_item(struct ls_data *d, struct ls_options *opts, WRITE_STATUS_ITEM(b, SI_SECONDS_TOTAL, "%" PRIu32 "\n", afhi->seconds_total); WRITE_STATUS_ITEM(b, SI_LAST_PLAYED, "%s\n", last_played_time); - WRITE_STATUS_ITEM(b, SI_NUM_PLAYED, "%d\n", afsi->num_played); + WRITE_STATUS_ITEM(b, SI_NUM_PLAYED, "%u\n", afsi->num_played); WRITE_STATUS_ITEM(b, SI_AMPLIFICATION, "%u\n", afsi->amp); WRITE_STATUS_ITEM(b, SI_CHUNK_TIME, "%lu\n", tv2ms(&afhi->chunk_tv)); WRITE_STATUS_ITEM(b, SI_NUM_CHUNKS, "%" PRIu32 "\n", @@ -2625,7 +2625,7 @@ static int aft_open(const char *dir) if (ret >= 0) { unsigned num; osl_get_num_rows(audio_file_table, &num); - PARA_INFO_LOG("audio file table contains %d files\n", num); + PARA_INFO_LOG("audio file table contains %u files\n", num); return ret; } PARA_NOTICE_LOG("failed to open audio file table\n"); diff --git a/alsa_mix.c b/alsa_mix.c index cad58af0..3adee929 100644 --- a/alsa_mix.c +++ b/alsa_mix.c @@ -142,7 +142,7 @@ static int alsa_mix_set_channel(struct mixer_handle *h, snd_mixer_selem_id_set_name(sid, mixer_channel); h->elem = snd_mixer_find_selem(h->mixer, sid); if (!h->elem) { - PARA_NOTICE_LOG("unable to find simple control '%s',%i\n", + PARA_NOTICE_LOG("unable to find simple control '%s',%u\n", snd_mixer_selem_id_get_name(sid), snd_mixer_selem_id_get_index(sid)); ret = -E_BAD_CHANNEL; diff --git a/alsa_write.c b/alsa_write.c index 63a7055b..fd3b404c 100644 --- a/alsa_write.c +++ b/alsa_write.c @@ -303,7 +303,7 @@ again: get_btr_sample_format(btrn, &val); pad->sample_format = get_alsa_pcm_format(val); - PARA_INFO_LOG("%d channel(s), %dHz\n", pad->channels, + PARA_INFO_LOG("%u channel(s), %uHz\n", pad->channels, pad->sample_rate); ret = alsa_init(pad, wn->conf); if (ret < 0) { diff --git a/audiod.c b/audiod.c index 285d2762..bd97f15e 100644 --- a/audiod.c +++ b/audiod.c @@ -764,7 +764,7 @@ static void compute_time_diff(const struct timeval *status_time) if (count > 5) { int s = tv_diff(&diff, &stat_task->sa_time_diff, &tmp); if (tv_diff(&max_deviation, &tmp, NULL) < 0) - PARA_WARNING_LOG("time diff jump: %lims\n", + PARA_WARNING_LOG("time diff jump: %lums\n", s * tv2ms(&tmp)); } count++; @@ -1378,7 +1378,7 @@ static int status_post_select(struct sched *s, void *context) if (st->clock_diff_count) { /* get status only one time */ char *argv[] = {"audiod", "--", "stat", "-p", "-n=1", NULL}; int argc = 5; - PARA_INFO_LOG("clock diff count: %d\n", st->clock_diff_count); + PARA_INFO_LOG("clock diff count: %u\n", st->clock_diff_count); st->clock_diff_count--; client_open(argc, argv, &st->ct, NULL, NULL, st->btrn, s); set_stat_task_restart_barrier(2); diff --git a/blob.c b/blob.c index ca39de0d..7a7ae756 100644 --- a/blob.c +++ b/blob.c @@ -262,7 +262,7 @@ static int com_rmblob_callback(struct osl_table *table, if (pmd.num_matches == 0) ret = -E_NO_MATCH; else { - para_printf(&aca->pbout, "removed %d blob(s)\n", + para_printf(&aca->pbout, "removed %u blob(s)\n", pmd.num_matches); ret = afs_event(BLOB_REMOVE, NULL, table); } diff --git a/check_wav.c b/check_wav.c index d1d27872..1a47f946 100644 --- a/check_wav.c +++ b/check_wav.c @@ -177,7 +177,7 @@ int check_wav_post_select(struct check_wav_context *cwc) else cwc->sample_format = (a[3] == 'F')? SF_S16_LE : SF_S16_BE; - PARA_NOTICE_LOG("%dHz, %s, %s\n", cwc->sample_rate, + PARA_NOTICE_LOG("%uHz, %s, %s\n", cwc->sample_rate, cwc->channels == 1? "mono" : "stereo", sample_formats[cwc->sample_format]); btr_consume(btrn, WAV_HEADER_LEN); diff --git a/command.c b/command.c index 0eb4efc2..fe4b9232 100644 --- a/command.c +++ b/command.c @@ -473,7 +473,7 @@ static unsigned empty_status_items(int parser_friendly, char **result) #define ITEM(x) "0004 %02x:\n" EMPTY_STATUS_ITEMS #undef ITEM - #define ITEM(x) , SI_ ## x + #define ITEM(x) , (unsigned) SI_ ## x EMPTY_STATUS_ITEMS #undef ITEM ); @@ -767,7 +767,7 @@ static int com_jmp(struct command_context *cc) i = 100; PARA_INFO_LOG("jumping to %lu%%\n", i); mmd->repos_request = (mmd->afd.afhi.chunks_total * i + 50) / 100; - PARA_INFO_LOG("sent: %lu, offset before jmp: %lu\n", + PARA_INFO_LOG("sent: %lu, offset before jmp: %li\n", mmd->chunks_sent, mmd->offset); mmd->new_vss_status_flags |= VSS_REPOS; mmd->new_vss_status_flags &= ~VSS_NEXT; @@ -964,7 +964,7 @@ __noreturn void handle_connect(int fd, const char *peername) numbytes = 256; get_random_bytes_or_die((unsigned char *)buf, numbytes); } - PARA_DEBUG_LOG("sending %u byte challenge + session key (%zu bytes)\n", + PARA_DEBUG_LOG("sending %d byte challenge + session key (%zu bytes)\n", CHALLENGE_SIZE, numbytes); ret = send_sb(&cc->scc, buf, numbytes, SBD_CHALLENGE, false); buf = NULL; diff --git a/crypt_common.c b/crypt_common.c index b39ee5e4..a05572df 100644 --- a/crypt_common.c +++ b/crypt_common.c @@ -96,7 +96,7 @@ int check_ssh_key_header(const unsigned char *blob, int blen) return -E_SSH_KEY_HEADER; if (rlen < strlen(KEY_TYPE_TXT)) return -E_SSH_KEY_HEADER; - PARA_DEBUG_LOG("type: %s, rlen: %d\n", p, rlen); + PARA_DEBUG_LOG("type: %s, rlen: %u\n", p, rlen); if (strncmp((char *)p, KEY_TYPE_TXT, strlen(KEY_TYPE_TXT))) return -E_SSH_KEY_HEADER; return 4 + rlen; diff --git a/fade.c b/fade.c index 95bb1d59..2a001eba 100644 --- a/fade.c +++ b/fade.c @@ -67,7 +67,7 @@ static int fade(struct mixer *m, struct mixer_handle *h, int new_vol, int fade_t if (ret < 0) goto out; vol = ret; - PARA_NOTICE_LOG("fading %s from %d to %d in %d seconds\n", + PARA_NOTICE_LOG("fading %s from %d to %d in %u seconds\n", conf.mixer_channel_arg, vol, new_vol, secs); diff = new_vol - vol; if (!diff) { @@ -203,7 +203,7 @@ static int sweet_dreams(struct mixer *m, struct mixer_handle *h) tm = localtime(&t1); } wake_time_epoch = mktime(tm); - PARA_INFO_LOG("waketime: %u:%02u\n", tm->tm_hour, tm->tm_min); + PARA_INFO_LOG("waketime: %d:%02d\n", tm->tm_hour, tm->tm_min); client_cmd("stop"); sleep(1); if (fot) { diff --git a/fecdec_filter.c b/fecdec_filter.c index 26ea24a6..1c3a3784 100644 --- a/fecdec_filter.c +++ b/fecdec_filter.c @@ -171,7 +171,7 @@ static struct fecdec_group *free_oldest_group(struct private_fecdec_data *pfd) oldest = fg; } if (!group_complete(oldest) && !group_empty(oldest)) - PARA_WARNING_LOG("Clearing incomplete group %d " + PARA_WARNING_LOG("Clearing incomplete group %u " "(contains %d slices)\n", oldest->h.group_num, oldest->num_received_slices); if (oldest == pfd->first_complete_group) @@ -224,7 +224,7 @@ static int add_slice(char *buf, struct fecdec_group *fg) uint8_t slice_num = fg->h.slice_num; if (group_complete(fg)) { - PARA_DEBUG_LOG("group %d complete, ignoring slice %d\n", + PARA_DEBUG_LOG("group %u complete, ignoring slice %d\n", fg->h.group_num, slice_num); return 0; } @@ -236,7 +236,7 @@ static int add_slice(char *buf, struct fecdec_group *fg) r = fg->num_received_slices; /* Check if we already have this slice. */ if (test_and_set_slice_bit(fg, slice_num)) { - PARA_INFO_LOG("ignoring duplicate slice %d:%d\n", fg->h.group_num, + PARA_INFO_LOG("ignoring duplicate slice %u:%d\n", fg->h.group_num, slice_num); return 0; } @@ -293,10 +293,10 @@ static int decode_group(struct fecdec_group *fg, struct filter_node *fn) char *buf = NULL; if (u == FEC_GROUP_UNUSABLE) { - PARA_INFO_LOG("dropping unusable group %d\n", fg->h.group_num); + PARA_INFO_LOG("dropping unusable group %u\n", fg->h.group_num); return 0; } - PARA_DEBUG_LOG("decoding group %d (%d slices)\n", fg->h.group_num, + PARA_DEBUG_LOG("decoding group %u (%d slices)\n", fg->h.group_num, fg->h.data_slices_per_group); ret = fec_decode(pfd->fec, fg->data, fg->idx, sb); if (ret < 0) @@ -307,7 +307,7 @@ static int decode_group(struct fecdec_group *fg, struct filter_node *fn) i = DIV_ROUND_UP(fg->h.audio_header_size, fg->h.slice_bytes); PARA_DEBUG_LOG("skipping %d header slices\n", i); } - PARA_DEBUG_LOG("writing group %d (%d/%d decoded data bytes)\n", + PARA_DEBUG_LOG("writing group %u (%u/%d decoded data bytes)\n", fg->h.group_num, fg->h.group_bytes, fg->h.data_slices_per_group * sb); need = (fg->h.data_slices_per_group - i) * sb; diff --git a/file_write.c b/file_write.c index ef25b0f5..5e66607e 100644 --- a/file_write.c +++ b/file_write.c @@ -39,7 +39,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/%08lu", home, + result = make_message("%s/.paraslash/%08ld", home, para_random(99999999)); free(home); return result; diff --git a/filter_common.c b/filter_common.c index 84863b39..e9b97e54 100644 --- a/filter_common.c +++ b/filter_common.c @@ -204,7 +204,7 @@ int decoder_execute(const char *cmd, unsigned sample_rate, unsigned channels, return 1; } if (!strcmp(cmd, "sample_format")) { - *result = make_message("%u", DECODER_SAMPLE_FORMAT); + *result = make_message("%d", DECODER_SAMPLE_FORMAT); return 1; } return -ERRNO_TO_PARA_ERROR(ENOTSUP); diff --git a/flac_afh.c b/flac_afh.c index 2e2842b1..385d4f0c 100644 --- a/flac_afh.c +++ b/flac_afh.c @@ -468,7 +468,7 @@ static int flac_write_chain(FLAC__Metadata_Chain *chain, if (!ok) { FLAC__Metadata_ChainStatus st; st = FLAC__metadata_chain_status(chain); - PARA_ERROR_LOG("chain status: %d\n", st); + PARA_ERROR_LOG("chain status: %u\n", st); if (st == FLAC__METADATA_CHAIN_STATUS_READ_ERROR) PARA_ERROR_LOG("read error\n"); return -E_FLAC_WRITE_CHAIN; diff --git a/gcrypt.c b/gcrypt.c index 289748e8..7c19aeb0 100644 --- a/gcrypt.c +++ b/gcrypt.c @@ -388,7 +388,7 @@ static int read_bignum(unsigned char *start, unsigned char *end, gcry_mpi_t *bn, for (i = 0; i < num_bytes; i++, cp++) bn_size = (bn_size << 8) + *cp; } - PARA_DEBUG_LOG("bn_size %d (0x%x)\n", bn_size, bn_size); + PARA_DEBUG_LOG("bn_size %d (0x%x)\n", bn_size, (unsigned)bn_size); gret = gcry_mpi_scan(bn, GCRYMPI_FMT_STD, cp, bn_size, NULL); if (gret) { PARA_ERROR_LOG("%s while scanning n\n", @@ -586,7 +586,7 @@ static int get_asn_public_key(const char *key_file, struct asymmetric_key **resu key->num_bytes = n_size; *result = key; ret = n_size; - PARA_INFO_LOG("successfully read %u bit asn public key\n", n_size * 8); + PARA_INFO_LOG("successfully read %d bit asn public key\n", n_size * 8); release_e: gcry_mpi_release(e); @@ -648,7 +648,7 @@ static int get_ssh_public_key(unsigned char *data, int size, gcry_sexp_t *result goto release_n; } ret = nr_scanned / 32 * 32; - PARA_INFO_LOG("successfully read %u bit ssh public key\n", ret * 8); + PARA_INFO_LOG("successfully read %d bit ssh public key\n", ret * 8); release_n: gcry_mpi_release(n); release_e: diff --git a/gui.c b/gui.c index b0eae64a..3e01340a 100644 --- a/gui.c +++ b/gui.c @@ -1160,7 +1160,7 @@ static void print_scroll_msg(void) unsigned lines_total, filled = ringbuffer_filled(bot_win_rb); int first_rbe = first_visible_rbe(&lines_total); - print_in_bar(COLOR_MSG, "scrolled view: %d-%d/%d\n", filled - first_rbe, + print_in_bar(COLOR_MSG, "scrolled view: %u-%u/%u\n", filled - first_rbe, filled - scroll_position, ringbuffer_filled(bot_win_rb)); } diff --git a/mood.c b/mood.c index 940d72a1..79f47e5a 100644 --- a/mood.c +++ b/mood.c @@ -747,7 +747,7 @@ static int mood_update_audio_file(const struct osl_row *aft_row, percent = 100; else if (percent < 0) percent = 0; - PARA_DEBUG_LOG("moving from rank %u to %lu%%\n", rank, percent); + PARA_DEBUG_LOG("moving from rank %u to %li%%\n", rank, percent); return score_update(aft_row, percent); } diff --git a/mp3_afh.c b/mp3_afh.c index 70f2ec9f..2115f71c 100644 --- a/mp3_afh.c +++ b/mp3_afh.c @@ -238,7 +238,7 @@ static int replace_tag(char const *id, const char *val, struct id3_tag *id3_t, if (!val || !*val) return 0; fr = id3_frame_new(id); - PARA_DEBUG_LOG("frame desc: %s, %d fields\n", fr->description, fr->nfields); + PARA_DEBUG_LOG("frame desc: %s, %u fields\n", fr->description, fr->nfields); /* Frame 0 contains the encoding. We always use UTF-8. */ field = id3_frame_field(fr, 0); diff --git a/net.c b/net.c index 13694989..fa7cd4b8 100644 --- a/net.c +++ b/net.c @@ -376,7 +376,7 @@ int lookup_address(unsigned l4type, bool passive, const char *host, struct addrinfo *addr = NULL, hints; *result = NULL; - sprintf(port, "%u", port_number & 0xffff); + sprintf(port, "%d", port_number & 0xffff); /* Set up address hint structure */ memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; diff --git a/ogg_afh.c b/ogg_afh.c index 29f08965..2ddf0ee3 100644 --- a/ogg_afh.c +++ b/ogg_afh.c @@ -95,7 +95,7 @@ static void add_ogg_page(ogg_page *og, struct vorbis_get_header_data *vghd) memcpy(p + og->header_len, og->body, og->body_len); vghd->buf = buf; vghd->len = new_len; - PARA_DEBUG_LOG("header/body/old/new: %lu/%lu/%zu/%zu\n", + PARA_DEBUG_LOG("header/body/old/new: %li/%li/%zu/%zu\n", og->header_len, og->body_len, old_len, new_len); } diff --git a/ogg_afh_common.c b/ogg_afh_common.c index e49b803b..adab7f48 100644 --- a/ogg_afh_common.c +++ b/ogg_afh_common.c @@ -193,7 +193,7 @@ static int write_ogg_page(int fd, const ogg_page *op) { int ret; - PARA_DEBUG_LOG("header/body: %lu/%lu\n", op->header_len, op->body_len); + PARA_DEBUG_LOG("header/body: %li/%li\n", op->header_len, op->body_len); ret = xwrite(fd, (const char *)op->header, op->header_len); if (ret < 0) return ret; @@ -288,7 +288,7 @@ int ogg_rewrite_tags(const char *map, size_t map_sz, int fd, goto out; continue; } - PARA_DEBUG_LOG("packet: bytes: %d, granule: %d, packetno: %u\n", + PARA_DEBUG_LOG("packet: bytes: %d, granule: %d, packetno: %d\n", (int)packet.bytes, (int)packet.granulepos, (int)packet.packetno); /* ignore meta data packet which we replaced */ @@ -309,7 +309,7 @@ int ogg_rewrite_tags(const char *map, size_t map_sz, int fd, #endif if (ret <= 0) break; - PARA_DEBUG_LOG("writing page (%lu bytes)\n", + PARA_DEBUG_LOG("writing page (%li bytes)\n", op.header_len + op.body_len); ret = write_ogg_page(fd, &op); if (ret < 0) diff --git a/oggdec_filter.c b/oggdec_filter.c index 4b801356..04be7020 100644 --- a/oggdec_filter.c +++ b/oggdec_filter.c @@ -162,7 +162,7 @@ open: goto out; pod->channels = ov_info(vf, 0)->channels; pod->sample_rate = ov_info(vf, 0)->rate; - PARA_NOTICE_LOG("%d channels, %d Hz\n", pod->channels, + PARA_NOTICE_LOG("%u channels, %u Hz\n", pod->channels, pod->sample_rate); ret = 1; out: diff --git a/opus_afh.c b/opus_afh.c index b1469b47..64eeb03c 100644 --- a/opus_afh.c +++ b/opus_afh.c @@ -55,7 +55,7 @@ static int opus_get_comments(char *comments, int length, p += 4; if (p + ntags * 4 > end) return -E_OPUS_COMMENT; - PARA_INFO_LOG("found %d tag(s)\n", ntags); + PARA_INFO_LOG("found %u tag(s)\n", ntags); for (i = 0; i < ntags; i++, p += val) { char *tag; diff --git a/oss_write.c b/oss_write.c index 12cf8b69..20186667 100644 --- a/oss_write.c +++ b/oss_write.c @@ -165,7 +165,7 @@ static int oss_init(struct writer_node *wn, unsigned sample_rate, ret = -E_BAD_SAMPLERATE; if (100 * max > 110 * min) /* more than 10% deviation */ goto err; - PARA_NOTICE_LOG("using %dHz rather than %dHz\n", rate, + PARA_NOTICE_LOG("using %uHz rather than %uHz\n", rate, sample_rate); } wn->min_iqs = powd->bytes_per_frame; diff --git a/play.c b/play.c index 108db598..46e8ff7d 100644 --- a/play.c +++ b/play.c @@ -788,7 +788,7 @@ static void list_file(struct play_task *pt, int num) char *buf; size_t sz; - sz = xasprintf(&buf, "%s %4u %s\n", num == pt->current_file? + sz = xasprintf(&buf, "%s %4d %s\n", num == pt->current_file? "*" : " ", num, conf.inputs[num]); btr_add_output(buf, sz, pt->btrn); } diff --git a/server.c b/server.c index ca71c4d8..1f931944 100644 --- a/server.c +++ b/server.c @@ -537,7 +537,7 @@ out: prev_uptime = uptime; prev_events = mmd->events; mmd->vss_status_flags = mmd->new_vss_status_flags; - PARA_DEBUG_LOG("%d events, forcing status update\n", mmd->events); + PARA_DEBUG_LOG("%u events, forcing status update\n", mmd->events); killpg(0, SIGUSR1); } diff --git a/spx_afh.c b/spx_afh.c index b780635b..4e318af1 100644 --- a/spx_afh.c +++ b/spx_afh.c @@ -88,7 +88,7 @@ static int spx_get_comments(unsigned char *comments, int length, if (c + 4 > end) return -E_SPX_COMMENT; nb_fields = read_u32(c); - PARA_DEBUG_LOG("%d comment(s)\n", nb_fields); + PARA_DEBUG_LOG("%u comment(s)\n", nb_fields); c += 4; for (i = 0; i < nb_fields; i++, c += len) { char *tag; diff --git a/string.h b/string.h index aa8292fd..52f98941 100644 --- a/string.h +++ b/string.h @@ -63,7 +63,7 @@ int for_each_line(unsigned flags, char *buf, size_t size, #define WRITE_STATUS_ITEM(b, n, f, ...) (\ { \ if ((b)->flags & PBF_SIZE_PREFIX) { \ - para_printf((b), "%02x:" f, n, ## __VA_ARGS__); \ + para_printf((b), "%02x:" f, (unsigned)n, ## __VA_ARGS__); \ } else { \ para_printf((b), "%s: " f, status_item_list[(n)], \ ## __VA_ARGS__); \ diff --git a/vss.c b/vss.c index 2acff1cb..5484db9d 100644 --- a/vss.c +++ b/vss.c @@ -611,7 +611,7 @@ static int setup_next_fec_group(struct fec_client *fc, struct vss_task *vsst) for (; i < k; i++) fc->src_data[i] = (const unsigned char *)buf; } - PARA_DEBUG_LOG("FEC group %d: %d chunks (%d - %d), %d bytes\n", + PARA_DEBUG_LOG("FEC group %u: %u chunks (%u - %u), %u bytes\n", g->num, g->num_chunks, g->first_chunk, g->first_chunk + g->num_chunks - 1, g->bytes ); @@ -1027,7 +1027,7 @@ static void vss_send(struct vss_task *vsst) } if (compute_next_fec_slice(fc, vsst) <= 0) continue; - PARA_DEBUG_LOG("sending %d:%d (%u bytes)\n", fc->group.num, + PARA_DEBUG_LOG("sending %u:%u (%u bytes)\n", fc->group.num, fc->current_slice_num, fc->group.slice_bytes); fc->fcp->send_fec(fc->sc, (char *)fc->enc_buf, fc->group.slice_bytes + FEC_HEADER_SIZE); diff --git a/wav_filter.c b/wav_filter.c index 07423a14..88047adb 100644 --- a/wav_filter.c +++ b/wav_filter.c @@ -31,7 +31,7 @@ static void make_wav_header(unsigned int channels, unsigned int sample_rate, int bytespersec = channels * sample_rate * BITS / 8; int align = channels * BITS / 8; - PARA_DEBUG_LOG("writing wave header: %d channels, %d KHz\n", channels, sample_rate); + PARA_DEBUG_LOG("writing wave header: %u channels, %u KHz\n", channels, sample_rate); memset(headbuf, 0, WAV_HEADER_LEN); memcpy(headbuf, "RIFF", 4); write_u32(headbuf + 4, size - 8); diff --git a/wma_common.c b/wma_common.c index 27cb51d0..6d57c00b 100644 --- a/wma_common.c +++ b/wma_common.c @@ -49,7 +49,7 @@ static int find_file_properties(const char *buf, int len) if (!p) return -E_WMA_NO_GUID; - PARA_DEBUG_LOG("found file property guid@%0x\n", (int)(p - buf)); + PARA_DEBUG_LOG("found file property guid@%0x\n", (unsigned)(p - buf)); return p - buf + 16; } @@ -63,7 +63,7 @@ static int find_audio_stream_info(const char *buf, int len) if (!p) return -E_WMA_NO_GUID; - PARA_DEBUG_LOG("found audio stream guid@%0x\n", (int)(p - buf)); + PARA_DEBUG_LOG("found audio stream guid@%0x\n", (unsigned)(p - buf)); return p - buf + 16; } @@ -111,14 +111,14 @@ int read_asf_header(const char *buf, int loaded, struct asf_header_info *ahi) ahi->sample_rate); ahi->bit_rate = 8 * read_u16(start + 46); - PARA_INFO_LOG("bit rate: %d\n", ahi->bit_rate); + PARA_INFO_LOG("bit rate: %u\n", ahi->bit_rate); ahi->block_align = read_u16(start + 50); PARA_INFO_LOG("block_align: %d\n", ahi->block_align); ahi->flags1 = read_u32(start + 56); ahi->flags2 = read_u16(start + 60); - PARA_INFO_LOG("read_asf_header: flags1: %d, flags2: %d\n", + PARA_INFO_LOG("read_asf_header: flags1: %u, flags2: %u\n", ahi->flags1, ahi->flags2); ahi->use_exp_vlc = ahi->flags2 & 0x0001; ahi->use_bit_reservoir = ahi->flags2 & 0x0002; diff --git a/wmadec_filter.c b/wmadec_filter.c index 31a13c50..4c7c047a 100644 --- a/wmadec_filter.c +++ b/wmadec_filter.c @@ -371,8 +371,8 @@ static int wma_init(struct private_wmadec_data *pwd) else high_freq = high_freq * 0.5; } - PARA_INFO_LOG("channels=%d sample_rate=%d " - "bitrate=%d block_align=%d\n", + PARA_INFO_LOG("channels=%u sample_rate=%u " + "bitrate=%u block_align=%d\n", ahi->channels, ahi->sample_rate, ahi->bit_rate, ahi->block_align); PARA_INFO_LOG("frame_len=%d, bps=%f bps1=%f "