Fix static code analysis warnings

This commit is contained in:
twinaphex 2020-06-29 21:24:32 +02:00
parent a2f2a882cb
commit 968922e151
6 changed files with 48 additions and 37 deletions

View File

@ -707,15 +707,17 @@ void CORE_PREFIX(retro_run)(void)
if (!decode_thread_dead) if (!decode_thread_dead)
{ {
unsigned y; unsigned y;
const uint8_t *src;
int stride, width; int stride, width;
uint32_t *data = video_frame_temp_buffer; const uint8_t *src = NULL;
video_decoder_context_t *ctx = NULL; video_decoder_context_t *ctx = NULL;
uint32_t *data = NULL;
video_buffer_get_finished_slot(video_buffer, &ctx); video_buffer_get_finished_slot(video_buffer, &ctx);
pts = ctx->pts; pts = ctx->pts;
#ifndef HAVE_OPENGLES #ifdef HAVE_OPENGLES
data = video_frame_temp_buffer;
#else
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, frames[1].pbo); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, frames[1].pbo);
#ifdef __MACH__ #ifdef __MACH__
data = (uint32_t*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY); data = (uint32_t*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);

14
deps/7zip/7zIn.c vendored
View File

@ -724,9 +724,9 @@ static SRes SzReadSubStreamsInfo(
uint32_t **digests, uint32_t **digests,
ISzAlloc *allocTemp) ISzAlloc *allocTemp)
{ {
uint64_t type = 0;
uint32_t i; uint32_t i;
uint32_t si = 0; uint64_t type = 0;
uint32_t si = 0;
uint32_t numDigests = 0; uint32_t numDigests = 0;
for (i = 0; i < numFolders; i++) for (i = 0; i < numFolders; i++)
@ -757,9 +757,9 @@ static SRes SzReadSubStreamsInfo(
if (*numUnpackStreams == 0) if (*numUnpackStreams == 0)
{ {
*unpackSizes = 0; *unpackSizes = 0;
*digestsDefined = 0; *digestsDefined = 0;
*digests = 0; *digests = 0;
} }
else else
{ {
@ -1168,9 +1168,9 @@ static SRes SzReadAndDecodePackedStreams2(
ISzAlloc *allocTemp) ISzAlloc *allocTemp)
{ {
SRes res; SRes res;
uint64_t dataStartPos; CSzFolder *folder = NULL;
CSzFolder *folder; uint64_t dataStartPos = 0;
uint64_t unpackSize; uint64_t unpackSize = 0;
uint32_t numUnpackStreams = 0; uint32_t numUnpackStreams = 0;
RINOK(SzReadStreamsInfo(sd, &dataStartPos, p, RINOK(SzReadStreamsInfo(sd, &dataStartPos, p,

View File

@ -319,6 +319,8 @@ int mbedtls_net_accept( mbedtls_net_context *bind_ctx,
int type_len = (int) sizeof( type ); int type_len = (int) sizeof( type );
#endif #endif
client_addr.ss_family = 0;
/* Is this a TCP or UDP socket? */ /* Is this a TCP or UDP socket? */
if( getsockopt( bind_ctx->fd, SOL_SOCKET, SO_TYPE, if( getsockopt( bind_ctx->fd, SOL_SOCKET, SO_TYPE,
(void *) &type, &type_len ) != 0 || (void *) &type, &type_len ) != 0 ||
@ -363,16 +365,18 @@ int mbedtls_net_accept( mbedtls_net_context *bind_ctx,
* then bind a new socket to accept new connections */ * then bind a new socket to accept new connections */
if( type != SOCK_STREAM ) if( type != SOCK_STREAM )
{ {
struct sockaddr_storage local_addr;
int one = 1; int one = 1;
struct sockaddr_storage local_addr;
local_addr.ss_family = 0;
if( connect( bind_ctx->fd, (struct sockaddr *) &client_addr, n ) != 0 ) if( connect( bind_ctx->fd, (struct sockaddr *) &client_addr, n ) != 0 )
return( MBEDTLS_ERR_NET_ACCEPT_FAILED ); return( MBEDTLS_ERR_NET_ACCEPT_FAILED );
client_ctx->fd = bind_ctx->fd; client_ctx->fd = bind_ctx->fd;
bind_ctx->fd = -1; /* In case we exit early */ bind_ctx->fd = -1; /* In case we exit early */
n = sizeof( struct sockaddr_storage ); n = sizeof( struct sockaddr_storage );
if( getsockname( client_ctx->fd, if( getsockname( client_ctx->fd,
(struct sockaddr *) &local_addr, &n ) != 0 || (struct sockaddr *) &local_addr, &n ) != 0 ||
( bind_ctx->fd = (int) socket( local_addr.ss_family, ( bind_ctx->fd = (int) socket( local_addr.ss_family,

View File

@ -2064,6 +2064,7 @@ static bool gl2_shader_init(gl_t *gl, const gfx_ctx_driver_t *ctx_driver,
init_data.gl.core_context_enabled = gl->core_context_in_use; init_data.gl.core_context_enabled = gl->core_context_in_use;
init_data.shader_type = type; init_data.shader_type = type;
init_data.shader = NULL; init_data.shader = NULL;
init_data.shader_data = NULL;
init_data.data = gl; init_data.data = gl;
init_data.path = shader_path; init_data.path = shader_path;
@ -2076,13 +2077,14 @@ static bool gl2_shader_init(gl_t *gl, const gfx_ctx_driver_t *ctx_driver,
RARCH_ERR("[GL]: Failed to initialize shader, falling back to stock.\n"); RARCH_ERR("[GL]: Failed to initialize shader, falling back to stock.\n");
init_data.shader = NULL; init_data.shader = NULL;
init_data.path = NULL; init_data.shader_data = NULL;
init_data.path = NULL;
ret = gl_shader_driver_init(&init_data); ret = gl_shader_driver_init(&init_data);
gl->shader = init_data.shader; gl->shader = init_data.shader;
gl->shader_data = init_data.shader_data; gl->shader_data = init_data.shader_data;
return ret; return ret;
} }

View File

@ -357,18 +357,21 @@ static uint8_t *rtga_tga_load(rtga_context *s,
/* do I need to invert the image? */ /* do I need to invert the image? */
if (tga_inverted) if (tga_inverted)
{ {
for (j = 0; j*2 < tga_height; ++j) if (tga_data)
{ {
int index1 = j * tga_width * tga_comp; for (j = 0; j*2 < tga_height; ++j)
int index2 = (tga_height - 1 - j) * tga_width * tga_comp;
for (i = tga_width * tga_comp; i > 0; --i)
{ {
unsigned char temp = tga_data[index1]; int index1 = j * tga_width * tga_comp;
tga_data[index1] = tga_data[index2]; int index2 = (tga_height - 1 - j) * tga_width * tga_comp;
tga_data[index2] = temp;
++index1; for (i = tga_width * tga_comp; i > 0; --i)
++index2; {
unsigned char temp = tga_data[index1];
tga_data[index1] = tga_data[index2];
tga_data[index2] = temp;
++index1;
++index2;
}
} }
} }
} }
@ -431,7 +434,7 @@ int rtga_process_image(rtga_t *rtga, void **buf_data,
size_tex = (*width) * (*height); size_tex = (*width) * (*height);
/* Convert RGBA to ARGB */ /* Convert RGBA to ARGB */
while(size_tex--) while (size_tex--)
{ {
unsigned int texel = rtga->output_image[size_tex]; unsigned int texel = rtga->output_image[size_tex];
unsigned int A = texel & 0xFF000000; unsigned int A = texel & 0xFF000000;

View File

@ -1548,15 +1548,15 @@ static bool ffmpeg_push_audio_thread(ffmpeg_t *handle,
size_t write_frames = write_left > can_write ? can_write : write_left; size_t write_frames = write_left > can_write ? can_write : write_left;
size_t write_size = write_frames * size_t write_size = write_frames *
handle->params.channels * handle->audio.sample_size; handle->params.channels * handle->audio.sample_size;
size_t bytes_in_buffer = handle->audio.frames_in_buffer * size_t bytes_in_buffer = handle->audio.frames_in_buffer *
handle->params.channels * handle->audio.sample_size; handle->params.channels * handle->audio.sample_size;
size_t written_bytes = written_frames * size_t written_bytes = written_frames *
handle->params.channels * handle->audio.sample_size; handle->params.channels * handle->audio.sample_size;
memcpy(handle->audio.buffer + bytes_in_buffer, if (handle->audio.buffer)
(const uint8_t*)aud->data + written_bytes, memcpy(handle->audio.buffer + bytes_in_buffer,
write_size); (const uint8_t*)aud->data + written_bytes,
write_size);
written_frames += write_frames; written_frames += write_frames;
handle->audio.frames_in_buffer += write_frames; handle->audio.frames_in_buffer += write_frames;
@ -1630,7 +1630,7 @@ static void ffmpeg_flush_buffers(ffmpeg_t *handle)
fifo_read(handle->audio_fifo, audio_buf, audio_buf_size); fifo_read(handle->audio_fifo, audio_buf, audio_buf_size);
aud.frames = handle->audio.codec->frame_size; aud.frames = handle->audio.codec->frame_size;
aud.data = audio_buf; aud.data = audio_buf;
ffmpeg_push_audio_thread(handle, &aud, true); ffmpeg_push_audio_thread(handle, &aud, true);
did_work = true; did_work = true;
@ -1751,7 +1751,7 @@ static void ffmpeg_thread(void *data)
scond_signal(ff->cond); scond_signal(ff->cond);
aud.frames = ff->audio.codec->frame_size; aud.frames = ff->audio.codec->frame_size;
aud.data = audio_buf; aud.data = audio_buf;
ffmpeg_push_audio_thread(ff, &aud, true); ffmpeg_push_audio_thread(ff, &aud, true);
} }