From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Tue, 30 Dec 2025 16:56:30 +0000 (+0000) Subject: More fixes due to tightening the checks on debug/die/inform/warn varadic arguments. X-Git-Tag: 5.0-post-dev~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=691d71f3565d28714f9b729b371ca7bf8c17fcba;p=thirdparty%2Fshairport-sync.git More fixes due to tightening the checks on debug/die/inform/warn varadic arguments. --- diff --git a/ap2_buffered_audio_processor.c b/ap2_buffered_audio_processor.c index fd3df1d6..2e577331 100644 --- a/ap2_buffered_audio_processor.c +++ b/ap2_buffered_audio_processor.c @@ -148,7 +148,7 @@ void *rtp_buffered_audio_processor(void *arg) { buffered_audio->buffer_max_size = conn->ap2_audio_buffer_size; buffered_audio->buffer = malloc(conn->ap2_audio_buffer_size); if (buffered_audio->buffer == NULL) - debug(1, "cannot allocate an audio buffer of %u bytes!", buffered_audio->buffer_max_size); + debug(1, "cannot allocate an audio buffer of %lu bytes!", buffered_audio->buffer_max_size); pthread_cleanup_push(malloc_cleanup, &buffered_audio->buffer); // pthread_mutex_lock(&conn->buffered_audio_mutex); @@ -488,7 +488,7 @@ void *rtp_buffered_audio_processor(void *arg) { nonce, conn->session_key); // *k if (response != 0) - debug(1, "Error decrypting audio packet %u -- packet length %d.", seq_no, + debug(1, "Error decrypting audio packet %u -- packet length %ld.", seq_no, nread); } else { debug(2, "No session key, so the audio packet can not be deciphered -- skipped."); @@ -581,7 +581,7 @@ void *rtp_buffered_audio_processor(void *arg) { skip_this_block = 1; debug(2, "skipping block %u because it is too old. Timestamp " - "difference: %d, length of block: %u.", + "difference: %d, length of block: %lu.", seq_no, timestamp_difference, get_ssrc_block_length(payload_ssrc)); } } @@ -606,7 +606,7 @@ void *rtp_buffered_audio_processor(void *arg) { uint64_t currentAnchorLocalTime = 0; if (get_ptp_anchor_local_time_info(conn, ¤tAnchorRTP, ¤tAnchorLocalTime) == clock_ok) { - debug(3, "anchorRTP: %u, anchorLocalTime: % " PRIu64 ".", currentAnchorRTP, + debug(3, "anchorRTP: %u, anchorLocalTime: %" PRIu64 ".", currentAnchorRTP, currentAnchorLocalTime); } else { debug(3, "Clock not okay"); diff --git a/audio_pa.c b/audio_pa.c index 022af6dd..8ea1d273 100644 --- a/audio_pa.c +++ b/audio_pa.c @@ -209,7 +209,7 @@ static int configure(int32_t requested_encoded_format, char **resulting_channel_ CHANNELS_FROM_ENCODED_FORMAT(current_encoded_output_format) * 1; // one seconds audio_lmb = malloc(audio_size); if (audio_lmb == NULL) - die("Can't allocate %d bytes for pulseaudio buffer.", audio_size); + die("Can't allocate %ld bytes for pulseaudio buffer.", audio_size); audio_toq = audio_eoq = audio_lmb; audio_umb = audio_lmb + audio_size; audio_occupancy = 0; diff --git a/audio_pw.c b/audio_pw.c index 0893053a..74f3cb64 100644 --- a/audio_pw.c +++ b/audio_pw.c @@ -335,7 +335,7 @@ static int configure(int32_t requested_encoded_format, char **resulting_channel_ // allocate space for the audio buffer audio_lmb = malloc(audio_size); if (audio_lmb == NULL) - die("Can't allocate %d bytes for PipeWire buffer.", audio_size); + die("Can't allocate %ld bytes for PipeWire buffer.", audio_size); audio_toq = audio_eoq = audio_lmb; audio_umb = audio_lmb + audio_size; audio_occupancy = 0; diff --git a/common.c b/common.c index 0a289899..fde58abb 100644 --- a/common.c +++ b/common.c @@ -670,7 +670,7 @@ uint8_t *base64_dec(char *input, int *outlen) { // input,strlen(input),inbuf,inbufsize); int rc = mbedtls_base64_decode(NULL, 0, &dlen, (unsigned char *)inbuf, inbufsize); if (rc && (rc != MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL)) - debug(1, "Error %d getting decode length, result is %d.", rc, dlen); + debug(1, "Error %d getting decode length, result is %ld.", rc, dlen); else { // debug(1,"Decode size is %d.",dlen); buf = malloc(dlen); diff --git a/dacp.c b/dacp.c index a7574f9b..09de5fc4 100644 --- a/dacp.c +++ b/dacp.c @@ -88,7 +88,7 @@ void *response_realloc(__attribute__((unused)) void *opaque, void *ptr, int size t = realloc(ptr, size); } if (t == NULL) - debug(1, "response_realloc of size %d to ptr %" PRIxPTR " failed!", size, ptr); + debug(1, "response_realloc of size %d to ptr %" PRIxPTR " failed!", size, (uintptr_t) ptr); } return t; } @@ -1302,7 +1302,7 @@ int dacp_set_volume(int32_t vo) { int32_t active_speakers = 0; for (i = 0; i < speaker_count; i++) { if (speaker_info[i].speaker_number == machine_number) { - debug(2, "Our speaker number found: %ld with relative volume.", machine_number, + debug(2, "Our speaker number found: %ld with relative volume %" PRId32 ".", machine_number, speaker_info[i].volume); } if (speaker_info[i].active == 1) { diff --git a/player.c b/player.c index 5da767ba..2f065db8 100644 --- a/player.c +++ b/player.c @@ -1273,7 +1273,7 @@ AVFrame *block_to_avframe(rtsp_conn_info *conn, uint8_t *incoming_data, if (ret < 0) { av_frame_free(&decoded_frame); decoded_frame = NULL; - debug(1, "error %d during decoding. Data size: %d", ret, incoming_data_length); + debug(1, "error %d during decoding. Data size: %ld", ret, incoming_data_length); /* char *obf = malloc(incoming_data_length * 3); char *obfp = obf; @@ -1293,7 +1293,7 @@ AVFrame *block_to_avframe(rtsp_conn_info *conn, uint8_t *incoming_data, } } } else { - debug(1, "error %d during decoding. Gross data size: %d", ret, incoming_data_length); + debug(1, "error %d during decoding. Gross data size: %ld", ret, incoming_data_length); /* char obf[128]; char *obfp = obf; @@ -1584,7 +1584,7 @@ uint32_t player_put_packet(uint32_t ssrc, seq_t seqno, uint32_t actual_timestamp // } else { if (len <= 8) { debug(1, - "Using the FFMPEG ALAC_44100_S16_2 decoder, a short audio packet %u, rtptime %u, of length %u has been decoded but not discarded. Contents follow:", seqno, + "Using the FFMPEG ALAC_44100_S16_2 decoder, a short audio packet %u, rtptime %u, of length %lu has been decoded but not discarded. Contents follow:", seqno, actual_timestamp, len); debug_print_buffer(1, data, len); // abuf->length = conn->frames_per_packet; @@ -1636,7 +1636,7 @@ uint32_t player_put_packet(uint32_t ssrc, seq_t seqno, uint32_t actual_timestamp //} else { if (len <= 8) { debug(1, - "Using an FFMPEG decoder, a short audio packet %u, rtptime %u, of length %u has been decoded but not discarded. Contents follow:", seqno, + "Using an FFMPEG decoder, a short audio packet %u, rtptime %u, of length %lu has been decoded but not discarded. Contents follow:", seqno, actual_timestamp, len); debug_print_buffer(1, data, len); // abuf->length = 0; @@ -2589,9 +2589,9 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn, int resync_requested) { #ifdef CONFIG_METADATA if (conn->ab_buffering == 0) { if ((curframe) && (curframe->ready) && (curframe->timestamp)) - debug(3, "Current frame at \"resume\" is %u.", curframe->timestamp); + debug(3, "Current frame timestamp at \"resume\" is %u.", curframe->timestamp); else - debug(1, "Current frame at \"resume\" is not known.", curframe->timestamp); + debug(1, "Current frame at \"resume\" is not known."); send_ssnc_metadata('prsm', NULL, 0, 0); // "resume", but don't wait if the queue is locked diff --git a/ptp-utilities.c b/ptp-utilities.c index 94e7a556..696c3ec6 100644 --- a/ptp-utilities.c +++ b/ptp-utilities.c @@ -162,7 +162,7 @@ int ptp_get_clock_info(uint64_t *actual_clock_id, uint64_t *time_of_sample, uint int ptp_shm_interface_open() { int response = 0; - debug(3, "ptp_shm_interface_open with mapped_addr = %" PRIuPTR "", mapped_addr); + debug(3, "ptp_shm_interface_open with mapped_addr = %" PRIuPTR "", (uintptr_t)mapped_addr); if ((mapped_addr == NULL) || (mapped_addr == MAP_FAILED)) { response = -1; if (mapped_addr == NULL) diff --git a/rtp.c b/rtp.c index 5b9d268d..335079ed 100644 --- a/rtp.c +++ b/rtp.c @@ -1761,7 +1761,7 @@ void *rtp_ap2_control_receiver(void *arg) { char *packet_in_hex_cstring = debug_malloc_hex_cstring(packet, nread); // remember to free this afterwards debug(1, - "AP2 Control Receiver Packet of first byte 0x%02X, type 0x%02X length %d " + "AP2 Control Receiver Packet of first byte 0x%02X, type 0x%02X length %ld " "received: " "\"%s\".", packet[0], packet[1], nread, packet_in_hex_cstring); @@ -1789,7 +1789,7 @@ void *rtp_ap2_control_receiver(void *arg) { conn->connection_number, errno); } } else { - debug(2, "Connection %d: AP2 Control Receiver -- malformed packet, %d bytes long.", + debug(2, "Connection %d: AP2 Control Receiver -- malformed packet, %ld bytes long.", conn->connection_number, nread); } } @@ -1804,7 +1804,7 @@ void rtp_realtime_audio_cleanup_handler(__attribute__((unused)) void *arg) { debug(2, "Realtime Audio Receiver Cleanup Start."); rtsp_conn_info *conn = (rtsp_conn_info *)arg; close(conn->realtime_audio_socket); - debug(2, "Connection %d: closing realtime audio port %u", conn->local_realtime_audio_port); + debug(2, "Connection %d: closing realtime audio port %u", conn->connection_number, conn->local_realtime_audio_port); conn->realtime_audio_socket = 0; debug(2, "Realtime Audio Receiver Cleanup Done."); } diff --git a/rtsp.c b/rtsp.c index 9c7070cf..722fced2 100644 --- a/rtsp.c +++ b/rtsp.c @@ -939,7 +939,7 @@ ssize_t read_encrypted(int fd, pair_cipher_bundle *ctx, void *buf, size_t count) ssize_t consumed = pair_decrypt(&plain, &plain_len, ctx->encrypted_read_buffer.data, ctx->encrypted_read_buffer.length, ctx->cipher_ctx); if (consumed < 0) { - debug(1, "read_encrypted: abnormal exit from pair_decrypt: %d.", consumed); + debug(1, "read_encrypted: abnormal exit from pair_decrypt: %ld.", consumed); response = -1; } else { buf_drain(&ctx->encrypted_read_buffer, consumed); @@ -1561,7 +1561,7 @@ plist_t generateInfoPlist(rtsp_conn_info *conn) { } plist_dict_set_item(supported_formats_plist, "bufferStream", plist_new_uint(bufferStreamFormats)); - debug(3, "bufferedStream formats: 0x% " PRIX64 ".", bufferStreamFormats); + debug(3, "bufferedStream formats: 0x%" PRIX64 ".", bufferStreamFormats); plist_dict_set_item(response_plist, "supportedFormats", supported_formats_plist); } } @@ -1750,7 +1750,7 @@ void handle_flushbuffered(rtsp_conn_info *conn, rtsp_message *req, rtsp_message conn->ap2_immediate_flush_until_sequence_number = flushUntilSeq & 0x7fffff; conn->ap2_immediate_flush_until_rtp_timestamp = flushUntilTS; debug(2, - "Connection %d: immediate flush request created: flushUntilTS: %u, flushUntilSeq: %u.", + "Connection %d: immediate flush request created: flushUntilTS: %" PRIu64 ", flushUntilSeq: %" PRIu64 ".", conn->connection_number, flushUntilTS, flushUntilSeq & 0x7fffff); conn->ap2_play_enabled = 0; // stop trying to play audio ptp_send_control_message_string( @@ -1774,7 +1774,7 @@ void handle_flushbuffered(rtsp_conn_info *conn, rtsp_message *req, rtsp_message conn->ap2_deferred_flush_requests[i].flushUntilSeq = flushUntilSeq & 0x7fffff; conn->ap2_deferred_flush_requests[i].flushUntilTS = flushUntilTS; debug(2, - "Connection %d: deferred flush request created: flushFromSeq: %u, flushUntilSeq: %u.", + "Connection %d: deferred flush request created: flushFromSeq: %" PRIu64 ", flushUntilSeq: %" PRIu64 ".", conn->connection_number, flushFromSeq, flushUntilSeq); } else { debug(1, "Connection %d: no more room for deferred flush request records", @@ -2930,7 +2930,7 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) } } else if (conn->airplay_stream_category == ntp_stream) { debug(1, "SETUP on Connection %d: ntp stream handling is not implemented!", - conn->connection_number, req); + conn->connection_number); warn("Shairport Sync can not handle NTP streams."); } else if (conn->airplay_stream_category == remote_control_stream) { @@ -4128,17 +4128,17 @@ int send_metadata_to_queue(pc_queue *queue, const uint32_t type, const uint32_t if (pack.carrier) { if (rc == EWOULDBLOCK) debug(2, - "metadata queue \"%s\" full, dropping message item: type %x, code %x, data %x, " + "metadata queue \"%s\" full, dropping message item: type %x, code %x, data %" PRIxPTR ", " "length %u, message %d.", - queue->name, pack.type, pack.code, pack.data, pack.length, + queue->name, pack.type, pack.code, (uintptr_t)pack.data, pack.length, pack.carrier->index_number); msg_free(&pack.carrier); } else { if (rc == EWOULDBLOCK) debug( 2, - "metadata queue \"%s\" full, dropping data item: type %x, code %x, data %x, length %u.", - queue->name, pack.type, pack.code, pack.data, pack.length); + "metadata queue \"%s\" full, dropping data item: type %x, code %x, data %" PRIxPTR ", length %u.", + queue->name, pack.type, pack.code, (uintptr_t)pack.data, pack.length); if (pack.data) free(pack.data); } diff --git a/shairport.c b/shairport.c index e196d416..5779d65f 100644 --- a/shairport.c +++ b/shairport.c @@ -1626,7 +1626,7 @@ int parse_options(int argc, char **argv) { // Produces a UUID string at uuid consisting of lower-case letters uuid_unparse_lower(result, psi_uuid); config.airplay_psi = psi_uuid; - debug(3, "size of pk is %u.", sizeof(config.airplay_pk)); + debug(3, "size of pk is %lu.", sizeof(config.airplay_pk)); pair_public_key_get(PAIR_SERVER_HOMEKIT, config.airplay_pk, config.airplay_device_id); char buf[128]; @@ -2806,11 +2806,11 @@ int main(int argc, char **argv) { (config_lookup_non_empty_string(config.cfg, "general.mixdown", &str))) { if ((strcasecmp(str, "off") == 0) || (strcasecmp(str, "no") == 0)) { config.mixdown_enable = 0; // 0 on initialisation - debug(1, "mixdown disabled.", str); + debug(1, "mixdown disabled."); } else if (strcasecmp(str, "auto") == 0) { config.mixdown_enable = 1; config.mixdown_channel_layout = 0; // 0 means auto - debug(1, "mixdown target: auto.", str); + debug(1, "mixdown target: auto."); } else { AVChannelLayout channel_layout; if (av_channel_layout_from_string(&channel_layout, str) == 0) { @@ -3116,7 +3116,7 @@ int main(int argc, char **argv) { debug(option_print_level, "metadata pipename is \"%s\".", config.metadata_pipename); debug(option_print_level, "metadata socket address is \"%s\" port %d.", config.metadata_sockaddr, config.metadata_sockport); - debug(option_print_level, "metadata socket packet size is \"%d\".", + debug(option_print_level, "metadata socket packet size is \"%ld\".", config.metadata_sockmsglength); debug(option_print_level, "get-coverart is %d.", config.get_coverart); #endif diff --git a/utilities/buffered_read.c b/utilities/buffered_read.c index 97853676..82baa2d3 100644 --- a/utilities/buffered_read.c +++ b/utilities/buffered_read.c @@ -42,7 +42,7 @@ ssize_t buffered_read(buffered_tcp_desc *descriptor, void *buf, size_t count, descriptor->closed = 0; if (descriptor->buffer_occupancy == 0) { - debug(2, "buffered_read: buffer empty -- waiting for %u bytes.", count); + debug(2, "buffered_read: buffer empty -- waiting for %lu bytes.", count); } while ((descriptor->buffer_occupancy == 0) && (descriptor->error_code == 0) && @@ -50,7 +50,7 @@ ssize_t buffered_read(buffered_tcp_desc *descriptor, void *buf, size_t count, if (pthread_cond_wait(&descriptor->not_empty_cv, &descriptor->mutex)) debug(1, "Error waiting for buffered read"); else - debug(2, "buffered_read: signalled with %u bytes after waiting.", + debug(2, "buffered_read: signalled with %lu bytes after waiting.", descriptor->buffer_occupancy); } @@ -144,7 +144,7 @@ void *buffered_tcp_reader(void *arg) { // do the read if (descriptor->buffer_occupancy == 0) - debug(2, "recv of up to %d bytes with an buffer empty.", bytes_to_request); + debug(2, "recv of up to %ld bytes with an buffer empty.", bytes_to_request); nread = recv(fd, descriptor->eoq, bytes_to_request, 0); // debug(1, "Received %d bytes for a buffer size of %d bytes.",nread, // descriptor->buffer_occupancy + nread);