From 0497095f9747e473cc54344a38cee043de82d392 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Wed, 6 Dec 2017 16:42:45 -0800 Subject: [PATCH] Fix a number of GCC warnings --- deps/jansson/src/dump.c | 3 ++- libobs/graphics/image-file.c | 8 ++++-- libobs/util/platform.c | 3 ++- .../obs-ffmpeg/obs-ffmpeg-audio-encoders.c | 5 ++-- plugins/obs-ffmpeg/obs-ffmpeg-source.c | 3 --- plugins/obs-filters/compressor-filter.c | 2 ++ plugins/obs-outputs/ftl-stream.c | 27 +++++++------------ plugins/rtmp-services/twitch.c | 2 +- 8 files changed, 25 insertions(+), 28 deletions(-) diff --git a/deps/jansson/src/dump.c b/deps/jansson/src/dump.c index 91d1a2f75..da6ca17a6 100644 --- a/deps/jansson/src/dump.c +++ b/deps/jansson/src/dump.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "jansson.h" @@ -187,7 +188,7 @@ static int do_dump(const json_t *json, size_t flags, int depth, int size; size = snprintf(buffer, MAX_INTEGER_STR_LENGTH, - "%" JSON_INTEGER_FORMAT, + "%" PRId64, json_integer_value(json)); if(size < 0 || size >= MAX_INTEGER_STR_LENGTH) return -1; diff --git a/libobs/graphics/image-file.c b/libobs/graphics/image-file.c index b68539daa..4262c0b11 100644 --- a/libobs/graphics/image-file.c +++ b/libobs/graphics/image-file.c @@ -64,7 +64,7 @@ static bool init_animated_gif(gs_image_file_t *image, const char *path) bool is_animated_gif = true; gif_result result; uint64_t max_size; - size_t size; + size_t size, size_read; FILE *file; image->bitmap_callbacks.bitmap_create = bi_def_bitmap_create; @@ -87,7 +87,11 @@ static bool init_animated_gif(gs_image_file_t *image, const char *path) fseek(file, 0, SEEK_SET); image->gif_data = bmalloc(size); - fread(image->gif_data, 1, size, file); + size_read = fread(image->gif_data, 1, size, file); + if (size_read != size) { + blog(LOG_WARNING, "Failed to fully read gif file '%s'.", path); + goto fail; + } do { result = gif_initialise(&image->gif, size, image->gif_data); diff --git a/libobs/util/platform.c b/libobs/util/platform.c index 008cbbb07..6826ea4ef 100644 --- a/libobs/util/platform.c +++ b/libobs/util/platform.c @@ -183,7 +183,8 @@ size_t os_fread_utf8(FILE *file, char **pstr) /* remove the ghastly BOM if present */ fseek(file, 0, SEEK_SET); - fread(bom, 1, 3, file); + size_t size_read = fread(bom, 1, 3, file); + (void)size_read; offset = (astrcmp_n(bom, "\xEF\xBB\xBF", 3) == 0) ? 3 : 0; diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-audio-encoders.c b/plugins/obs-ffmpeg/obs-ffmpeg-audio-encoders.c index 2d19e85f3..f6d69dbd8 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-audio-encoders.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-audio-encoders.c @@ -249,8 +249,9 @@ static void *enc_create(obs_data_t *settings, obs_encoder_t *encoder, } info("bitrate: %" PRId64 ", channels: %d, channel_layout: %x\n", - enc->context->bit_rate / 1000, enc->context->channels, - enc->context->channel_layout); + (int64_t)enc->context->bit_rate / 1000, + (int)enc->context->channels, + (unsigned int)enc->context->channel_layout); init_sizes(enc, audio); diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-source.c b/plugins/obs-ffmpeg/obs-ffmpeg-source.c index 7c89ae3a5..da2a99288 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-source.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-source.c @@ -31,9 +31,6 @@ #define FF_BLOG(level, format, ...) \ FF_LOG_S(s->source, level, format, ##__VA_ARGS__) -static bool video_frame(struct ff_frame *frame, void *opaque); -static bool video_format(AVCodecContext *codec_context, void *opaque); - struct ffmpeg_source { mp_media_t media; bool media_valid; diff --git a/plugins/obs-filters/compressor-filter.c b/plugins/obs-filters/compressor-filter.c index 7004d3116..234c80b13 100644 --- a/plugins/obs-filters/compressor-filter.c +++ b/plugins/obs-filters/compressor-filter.c @@ -145,6 +145,8 @@ static void sidechain_capture(void *param, obs_source_t *source, { struct compressor_data *cd = param; + UNUSED_PARAMETER(source); + pthread_mutex_lock(&cd->sidechain_mutex); if (cd->max_sidechain_frames < audio_data->frames) diff --git a/plugins/obs-outputs/ftl-stream.c b/plugins/obs-outputs/ftl-stream.c index 260de9173..eeb98ed80 100644 --- a/plugins/obs-outputs/ftl-stream.c +++ b/plugins/obs-outputs/ftl-stream.c @@ -122,6 +122,7 @@ static const char *ftl_stream_getname(void *unused) static void log_ftl(int level, const char *format, va_list args) { blogva(LOG_INFO, format, args); + UNUSED_PARAMETER(level); } static inline size_t num_buffered_packets(struct ftl_stream *stream); @@ -289,7 +290,7 @@ static inline bool get_next_packet(struct ftl_stream *stream, } static int avc_get_video_frame(struct ftl_stream *stream, - struct encoder_packet *packet, bool is_header, size_t idx) + struct encoder_packet *packet, bool is_header) { int consumed = 0; int len = (int)packet->size; @@ -333,7 +334,8 @@ static int avc_get_video_frame(struct ftl_stream *stream, if ((size_t)len > (packet->size - (size_t)consumed)) { warn("ERROR: got len of %d but packet only " "has %d left", - len, packet->size - consumed); + len, + (int)(packet->size - consumed)); } consumed += 4; @@ -345,9 +347,6 @@ static int avc_get_video_frame(struct ftl_stream *stream, uint8_t nalu_type = video_stream[0] & 0x1F; uint8_t nri = (video_stream[0] >> 5) & 0x3; - int send_marker_bit = - ((size_t)consumed >= packet->size) && !is_header; - if ((nalu_type != 12 && nalu_type != 6 && nalu_type != 9) || nri) { nalu->data = video_stream; @@ -368,15 +367,14 @@ static int avc_get_video_frame(struct ftl_stream *stream, } static int send_packet(struct ftl_stream *stream, - struct encoder_packet *packet, bool is_header, size_t idx) + struct encoder_packet *packet, bool is_header) { int bytes_sent = 0; - int recv_size = 0; int ret = 0; if (packet->type == OBS_ENCODER_VIDEO) { stream->coded_pic_buffer.total = 0; - avc_get_video_frame(stream, packet, is_header, idx); + avc_get_video_frame(stream, packet, is_header); int i; for (i = 0; i < stream->coded_pic_buffer.total; i++) { @@ -512,7 +510,7 @@ static void *send_thread(void *data) } } - if (send_packet(stream, &packet, false, packet.track_idx) < 0) { + if (send_packet(stream, &packet, false) < 0) { os_atomic_set_bool(&stream->disconnected, true); break; } @@ -561,7 +559,7 @@ static bool send_video_header(struct ftl_stream *stream, int64_t dts_usec) obs_encoder_get_extra_data(vencoder, &header, &size); packet.size = obs_parse_avc_header(&packet.data, header, size); - return send_packet(stream, &packet, true, 0) >= 0; + return send_packet(stream, &packet, true) >= 0; } static inline bool send_headers(struct ftl_stream *stream, int64_t dts_usec) @@ -937,7 +935,7 @@ static void *status_thread(void *data) blog(log_level, "Avg packet send per second %3.1f, " "total nack requests %d", (float)p->sent * 1000.f / p->period, - p->nack_reqs); + (int)p->nack_reqs); } else if (status.type == FTL_STATUS_VIDEO_PACKETS_INSTANT) { ftl_packet_stats_instant_msg_t *p = @@ -1049,13 +1047,6 @@ static int init_connect(struct ftl_stream *stream) dstr_copy(&stream->path, obs_service_get_url(service)); key = obs_service_get_key(service); - struct obs_video_info ovi; - int fps_num = 30, fps_den = 1; - if (obs_get_video_info(&ovi)) { - fps_num = ovi.fps_num; - fps_den = ovi.fps_den; - } - int target_bitrate = (int)obs_data_get_int(video_settings, "bitrate"); int peak_bitrate = (int)((float)target_bitrate * 1.1f); diff --git a/plugins/rtmp-services/twitch.c b/plugins/rtmp-services/twitch.c index 6e26cd5f1..31fdd1f6e 100644 --- a/plugins/rtmp-services/twitch.c +++ b/plugins/rtmp-services/twitch.c @@ -110,7 +110,7 @@ static bool twitch_ingest_update(void *param, struct file_download_data *data) bool success; pthread_mutex_lock(&mutex); - success = load_ingests(data->buffer.array, true); + success = load_ingests((const char *)data->buffer.array, true); pthread_mutex_unlock(&mutex); if (success) {