Fix a number of GCC warnings

This commit is contained in:
jp9000 2017-12-06 16:42:45 -08:00
parent 4704723759
commit 0497095f97
8 changed files with 25 additions and 28 deletions

View File

@ -12,6 +12,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <inttypes.h>
#include <assert.h> #include <assert.h>
#include "jansson.h" #include "jansson.h"
@ -187,7 +188,7 @@ static int do_dump(const json_t *json, size_t flags, int depth,
int size; int size;
size = snprintf(buffer, MAX_INTEGER_STR_LENGTH, size = snprintf(buffer, MAX_INTEGER_STR_LENGTH,
"%" JSON_INTEGER_FORMAT, "%" PRId64,
json_integer_value(json)); json_integer_value(json));
if(size < 0 || size >= MAX_INTEGER_STR_LENGTH) if(size < 0 || size >= MAX_INTEGER_STR_LENGTH)
return -1; return -1;

View File

@ -64,7 +64,7 @@ static bool init_animated_gif(gs_image_file_t *image, const char *path)
bool is_animated_gif = true; bool is_animated_gif = true;
gif_result result; gif_result result;
uint64_t max_size; uint64_t max_size;
size_t size; size_t size, size_read;
FILE *file; FILE *file;
image->bitmap_callbacks.bitmap_create = bi_def_bitmap_create; 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); fseek(file, 0, SEEK_SET);
image->gif_data = bmalloc(size); 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 { do {
result = gif_initialise(&image->gif, size, image->gif_data); result = gif_initialise(&image->gif, size, image->gif_data);

View File

@ -183,7 +183,8 @@ size_t os_fread_utf8(FILE *file, char **pstr)
/* remove the ghastly BOM if present */ /* remove the ghastly BOM if present */
fseek(file, 0, SEEK_SET); 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; offset = (astrcmp_n(bom, "\xEF\xBB\xBF", 3) == 0) ? 3 : 0;

View File

@ -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", info("bitrate: %" PRId64 ", channels: %d, channel_layout: %x\n",
enc->context->bit_rate / 1000, enc->context->channels, (int64_t)enc->context->bit_rate / 1000,
enc->context->channel_layout); (int)enc->context->channels,
(unsigned int)enc->context->channel_layout);
init_sizes(enc, audio); init_sizes(enc, audio);

View File

@ -31,9 +31,6 @@
#define FF_BLOG(level, format, ...) \ #define FF_BLOG(level, format, ...) \
FF_LOG_S(s->source, level, format, ##__VA_ARGS__) 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 { struct ffmpeg_source {
mp_media_t media; mp_media_t media;
bool media_valid; bool media_valid;

View File

@ -145,6 +145,8 @@ static void sidechain_capture(void *param, obs_source_t *source,
{ {
struct compressor_data *cd = param; struct compressor_data *cd = param;
UNUSED_PARAMETER(source);
pthread_mutex_lock(&cd->sidechain_mutex); pthread_mutex_lock(&cd->sidechain_mutex);
if (cd->max_sidechain_frames < audio_data->frames) if (cd->max_sidechain_frames < audio_data->frames)

View File

@ -122,6 +122,7 @@ static const char *ftl_stream_getname(void *unused)
static void log_ftl(int level, const char *format, va_list args) static void log_ftl(int level, const char *format, va_list args)
{ {
blogva(LOG_INFO, format, args); blogva(LOG_INFO, format, args);
UNUSED_PARAMETER(level);
} }
static inline size_t num_buffered_packets(struct ftl_stream *stream); 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, 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 consumed = 0;
int len = (int)packet->size; 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)) { if ((size_t)len > (packet->size - (size_t)consumed)) {
warn("ERROR: got len of %d but packet only " warn("ERROR: got len of %d but packet only "
"has %d left", "has %d left",
len, packet->size - consumed); len,
(int)(packet->size - consumed));
} }
consumed += 4; 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 nalu_type = video_stream[0] & 0x1F;
uint8_t nri = (video_stream[0] >> 5) & 0x3; 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) || if ((nalu_type != 12 && nalu_type != 6 && nalu_type != 9) ||
nri) { nri) {
nalu->data = video_stream; 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, 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 bytes_sent = 0;
int recv_size = 0;
int ret = 0; int ret = 0;
if (packet->type == OBS_ENCODER_VIDEO) { if (packet->type == OBS_ENCODER_VIDEO) {
stream->coded_pic_buffer.total = 0; 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; int i;
for (i = 0; i < stream->coded_pic_buffer.total; 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); os_atomic_set_bool(&stream->disconnected, true);
break; 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); obs_encoder_get_extra_data(vencoder, &header, &size);
packet.size = obs_parse_avc_header(&packet.data, 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) 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, " blog(log_level, "Avg packet send per second %3.1f, "
"total nack requests %d", "total nack requests %d",
(float)p->sent * 1000.f / p->period, (float)p->sent * 1000.f / p->period,
p->nack_reqs); (int)p->nack_reqs);
} else if (status.type == FTL_STATUS_VIDEO_PACKETS_INSTANT) { } else if (status.type == FTL_STATUS_VIDEO_PACKETS_INSTANT) {
ftl_packet_stats_instant_msg_t *p = 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)); dstr_copy(&stream->path, obs_service_get_url(service));
key = obs_service_get_key(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 target_bitrate = (int)obs_data_get_int(video_settings, "bitrate");
int peak_bitrate = (int)((float)target_bitrate * 1.1f); int peak_bitrate = (int)((float)target_bitrate * 1.1f);

View File

@ -110,7 +110,7 @@ static bool twitch_ingest_update(void *param, struct file_download_data *data)
bool success; bool success;
pthread_mutex_lock(&mutex); pthread_mutex_lock(&mutex);
success = load_ingests(data->buffer.array, true); success = load_ingests((const char *)data->buffer.array, true);
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
if (success) { if (success) {