Some more static code analysis nits when ran with enable=all

This commit is contained in:
twinaphex 2015-09-28 18:12:02 +02:00
parent 1eb80f6c93
commit 4ca5d31f9b
23 changed files with 89 additions and 81 deletions

View file

@ -427,9 +427,9 @@ void audio_convert_init_simd(void)
(void)cpu;
#if defined(__ARM_NEON__) && !defined(VITA)
audio_convert_s16_to_float_arm = cpu & RETRO_SIMD_NEON ?
audio_convert_s16_to_float_arm = (cpu & RETRO_SIMD_NEON) ?
audio_convert_s16_to_float_neon : audio_convert_s16_to_float_C;
audio_convert_float_to_s16_arm = cpu & RETRO_SIMD_NEON ?
audio_convert_float_to_s16_arm = (cpu & RETRO_SIMD_NEON) ?
audio_convert_float_to_s16_neon : audio_convert_float_to_s16_C;
#endif
}

View file

@ -157,14 +157,16 @@ static void ctr_audio_free(void *data)
static ssize_t ctr_audio_write(void *data, const void *buf, size_t size)
{
int i;
uint32_t samples_played;
uint64_t current_tick;
uint32_t samples_played = 0;
uint64_t current_tick = 0;
static struct retro_perf_counter ctraudio_f = {0};
const uint16_t *src = buf;
ctr_audio_t *ctr = (ctr_audio_t*)data;
(void)data;
(void)buf;
(void)samples_played;
(void)current_tick;
rarch_perf_init(&ctraudio_f, "ctraudio_f");
retro_perf_start(&ctraudio_f);

View file

@ -1215,9 +1215,10 @@ static bool config_load_file(const char *path, bool set_defaults)
while (extra_path)
{
bool ret = false;
bool ret = config_append_file(conf, extra_path);
RARCH_LOG("Config: appending config \"%s\"\n", extra_path);
ret = config_append_file(conf, extra_path);
if (!ret)
RARCH_ERR("Config: failed to append config \"%s\"\n", extra_path);
extra_path = strtok_r(NULL, "|", &save);
@ -1834,6 +1835,12 @@ bool config_load_override(void)
settings_t *settings = config_get_ptr();
rarch_system_info_t *info = rarch_system_info_get_ptr();
if (!global || !settings )
{
RARCH_ERR("Could not obtain global pointer or configuration file pointer to retrieve path of retroarch.cfg.\n");
return false;
}
/* Early return in case a library isn't loaded */
if (!info->info.library_name || !strcmp(info->info.library_name,"No Core"))
return false;
@ -1841,12 +1848,6 @@ bool config_load_override(void)
RARCH_LOG("Overrides: core name: %s\n", info->info.library_name);
RARCH_LOG("Overrides: game name: %s\n", global->name.base);
if (!global || !settings )
{
RARCH_ERR("Could not obtain global pointer or configuration file pointer to retrieve path of retroarch.cfg.\n");
return false;
}
/* Config directory: config_directory.
* Try config directory setting first,
* fallback to the location of the current configuration file. */
@ -2065,8 +2066,6 @@ bool config_load_remap(void)
input_remapping_set_defaults();
}
new_conf = NULL;
/* Create a new config file from core_path */
new_conf = config_file_new(core_path);
@ -2200,7 +2199,6 @@ static void save_keybind_axis(config_file_t *conf, const char *prefix,
const char *base, const struct retro_keybind *bind, bool save_empty)
{
char key[64] = {0};
char config[16] = {0};
unsigned axis = 0;
char dir = '\0';
@ -2225,6 +2223,7 @@ static void save_keybind_axis(config_file_t *conf, const char *prefix,
if (dir)
{
char config[16];
snprintf(config, sizeof(config), "%c%u", dir, axis);
config_set_string(conf, key, config);
}

View file

@ -92,7 +92,6 @@ void core_option_get(core_option_manager_t *opt, struct retro_variable *var)
static bool parse_variable(core_option_manager_t *opt, size_t idx,
const struct retro_variable *var)
{
size_t i;
const char *val_start = NULL;
char *value = NULL;
char *desc_end = NULL;
@ -126,6 +125,8 @@ static bool parse_variable(core_option_manager_t *opt, size_t idx,
if (config_get_string(opt->conf, option->key, &config_val))
{
size_t i;
for (i = 0; i < option->vals->size; i++)
{
if (!strcmp(option->vals->elems[i].data, config_val))

View file

@ -310,6 +310,7 @@ static void check_variables(void)
(void)var;
(void)fft_var;
(void)fft_ms_var;
#ifdef HAVE_OPENGL
var.key = "ffmpeg_temporal_interp";

View file

@ -333,10 +333,6 @@ void d3d_texture_blit(unsigned pixel_size,
LPDIRECT3DTEXTURE tex, D3DLOCKED_RECT *lr, const void *frame,
unsigned width, unsigned height, unsigned pitch)
{
unsigned y;
(void)y;
#ifdef _XBOX
D3DTexture_LockRect(tex, 0, lr, NULL, D3DLOCK_NOSYSLOCK);
#if defined(_XBOX360)
@ -345,6 +341,7 @@ void d3d_texture_blit(unsigned pixel_size,
XGCopySurface(lr->pBits, lr->Pitch, width, height, desc.Format, NULL,
frame, pitch, desc.Format, NULL, 0, 0);
#elif defined(_XBOX1)
unsigned y;
for (y = 0; y < height; y++)
{
const uint8_t *in = (const uint8_t*)frame + y * pitch;
@ -356,6 +353,7 @@ void d3d_texture_blit(unsigned pixel_size,
#else
if (SUCCEEDED(tex->LockRect(0, lr, NULL, D3DLOCK_NOSYSLOCK)))
{
unsigned y;
for (y = 0; y < height; y++)
{
const uint8_t *in = (const uint8_t*)frame + y * pitch;

View file

@ -621,7 +621,6 @@ static void dispmanx_gfx_get_poke_interface(void *data,
static void dispmanx_gfx_free(void *data)
{
struct dispmanx_video *_dispvars = data;
int i;
dispmanx_surface_free(_dispvars, &_dispvars->main_surface);
dispmanx_surface_free(_dispvars, &_dispvars->back_surface);
if (_dispvars->menu_surface != NULL)

View file

@ -865,7 +865,6 @@ static void gl_set_viewport(void *data, unsigned viewport_width,
}
else if (gl->keep_aspect && !force_full)
{
float delta;
float desired_aspect = video_driver_get_aspect_ratio();
#if defined(HAVE_MENU)
@ -882,6 +881,8 @@ static void gl_set_viewport(void *data, unsigned viewport_width,
else
#endif
{
float delta;
if (fabsf(device_aspect - desired_aspect) < 0.0001f)
{
/* If the aspect ratios of screen and desired aspect

View file

@ -724,7 +724,6 @@ static void sunxi_setup_scale (void *data,
unsigned width, unsigned height, unsigned pitch)
{
int i;
float aspect;
unsigned int xpos, visible_width;
struct sunxi_video *_dispvars = (struct sunxi_video*)data;
settings_t *settings = config_get_ptr();
@ -879,12 +878,11 @@ static void sunxi_set_texture_frame(void *data, const void *frame, bool rgb32,
unsigned width, unsigned height, float alpha)
{
struct sunxi_video *_dispvars = (struct sunxi_video*)data;
if (_dispvars->menu_active) {
uint16_t src_pix;
uint32_t R, G, B, dst_pix;
if (_dispvars->menu_active)
{
unsigned int i, j;
/* We have to go on a pixel format conversion adventure for now, until we can
* convince RGUI to output in an 8888 format. */
unsigned int src_pitch = width * 2;
@ -898,22 +896,22 @@ static void sunxi_set_texture_frame(void *data, const void *frame, bool rgb32,
for (i = 0; i < height; i++)
{
for (j = 0; j < src_pitch / 2; j++)
{
src_pix = *((uint16_t*)frame + (src_pitch / 2 * i) + j);
/* The hex AND is for keeping only the part we need for each component. */
R = (src_pix << 8) & 0x00FF0000;
G = (src_pix << 4) & 0x0000FF00;
B = (src_pix << 0) & 0x000000FF;
line[j] = (0 | R | G | B);
}
memcpy(dst_base_addr + (dst_pitch * i), (char*)line, dst_pitch);
for (j = 0; j < src_pitch / 2; j++)
{
uint16_t src_pix = *((uint16_t*)frame + (src_pitch / 2 * i) + j);
/* The hex AND is for keeping only the part we need for each component. */
uint32_t R = (src_pix << 8) & 0x00FF0000;
uint32_t G = (src_pix << 4) & 0x0000FF00;
uint32_t B = (src_pix << 0) & 0x000000FF;
line[j] = (0 | R | G | B);
}
memcpy(dst_base_addr + (dst_pitch * i), (char*)line, dst_pitch);
}
/* Issue pageflip. Will flip on next vsync. */
sunxi_layer_set_rgb_input_buffer(_dispvars->sunxi_disp,
_dispvars->sunxi_disp->bits_per_pixel,
_dispvars->pages[0].offset, width, height, _dispvars->sunxi_disp->xres);
_dispvars->sunxi_disp->bits_per_pixel,
_dispvars->pages[0].offset, width, height, _dispvars->sunxi_disp->xres);
}
}

View file

@ -117,9 +117,8 @@ static bool vita2d_gfx_frame(void *data, const void *frame,
unsigned width, unsigned height, uint64_t frame_count,
unsigned pitch, const char *msg)
{
int i, j;
int i;
void *tex_p;
unsigned int stride;
vita_video_t *vita = (vita_video_t *)data;
(void)frame;
@ -130,6 +129,9 @@ static bool vita2d_gfx_frame(void *data, const void *frame,
if (frame)
{
unsigned j;
unsigned int stride;
if ((width != vita->width || height != vita->height) && vita->texture)
{
vita2d_free_texture(vita->texture);
@ -316,7 +318,6 @@ static void vita2d_gfx_update_viewport(vita_video_t* vita)
}
else if (vita->keep_aspect)
{
float delta;
float desired_aspect = video_driver_get_aspect_ratio();
if (vita->rotation == ORIENTATION_VERTICAL ||
vita->rotation == ORIENTATION_FLIPPED_ROTATED){
@ -340,6 +341,8 @@ static void vita2d_gfx_update_viewport(vita_video_t* vita)
else
#endif
{
float delta;
if ((fabsf(device_aspect - desired_aspect) < 0.0001f))
{
/* If the aspect ratios of screen and desired aspect

View file

@ -931,8 +931,10 @@ void video_monitor_adjust_system_rates(void)
settings_t *settings = config_get_ptr();
rarch_system_info_t *system = rarch_system_info_get_ptr();
if (system)
system->force_nonblock = false;
if (!system)
return;
system->force_nonblock = false;
if (av_info)
info = (const struct retro_system_timing*)&av_info->timing;
@ -1093,7 +1095,6 @@ bool video_monitor_fps_statistics(double *refresh_rate,
bool video_monitor_get_fps(char *buf, size_t size,
char *buf_fps, size_t size_fps)
{
static float last_fps;
retro_time_t new_time;
static retro_time_t curr_time;
static retro_time_t fps_time;
@ -1105,6 +1106,7 @@ bool video_monitor_get_fps(char *buf, size_t size,
if (video_frame_count)
{
static float last_fps;
bool ret = false;
unsigned write_index = video_state.frame_time_samples_count++ &
(MEASURE_FRAME_TIME_SAMPLES_COUNT - 1);

View file

@ -120,7 +120,10 @@ void video_viewport_set_config(void)
{
struct retro_game_geometry *geom = &av_info->geometry;
if (geom && geom->aspect_ratio > 0.0f && settings->video.aspect_ratio_auto)
if (!geom)
return;
if (geom->aspect_ratio > 0.0f && settings->video.aspect_ratio_auto)
aspectratio_lut[ASPECT_RATIO_CONFIG].value = geom->aspect_ratio;
else
{

View file

@ -738,7 +738,7 @@ static void handle_hotplug(android_input_t *android,
if (settings->input.autodetect_enable)
{
bool autoconfigured = false;
bool autoconfigured;
autoconfig_params_t params = {{0}};
RARCH_LOG("Port %d: %s VID/PID: %d/%d\n", *port, name_buf, params.vid, params.pid);
@ -752,6 +752,7 @@ static void handle_hotplug(android_input_t *android,
strlcpy(params.driver, android_joypad.ident, sizeof(params.driver));
autoconfigured = input_config_autoconfigure_joypad(&params);
if (autoconfigured)
{
if (settings->input.autoconf_binds[*port][RARCH_MENU_TOGGLE].joykey != 0)

View file

@ -149,7 +149,7 @@ static void qnx_process_gamepad_event(
*state_cur = 0;
for (i = 0; i < 20; i++)
*state_cur |= (controller->buttons & (1 << i) ? (1 << i) : 0);
*state_cur |= ((controller->buttons & (1 << i)) ? (1 << i) : 0);
if (controller->analogCount > 0)
screen_get_event_property_iv(screen_event,

View file

@ -491,12 +491,12 @@ static void sdl_poll_mouse(sdl_input_t *sdl)
SDL_GetMouseState(&sdl->mouse_abs_x, &sdl->mouse_abs_y);
sdl->mouse_l = SDL_BUTTON(SDL_BUTTON_LEFT) & btn ? 1 : 0;
sdl->mouse_r = SDL_BUTTON(SDL_BUTTON_RIGHT) & btn ? 1 : 0;
sdl->mouse_m = SDL_BUTTON(SDL_BUTTON_MIDDLE) & btn ? 1 : 0;
sdl->mouse_l = (SDL_BUTTON(SDL_BUTTON_LEFT) & btn) ? 1 : 0;
sdl->mouse_r = (SDL_BUTTON(SDL_BUTTON_RIGHT) & btn) ? 1 : 0;
sdl->mouse_m = (SDL_BUTTON(SDL_BUTTON_MIDDLE) & btn) ? 1 : 0;
#ifndef HAVE_SDL2
sdl->mouse_wu = SDL_BUTTON(SDL_BUTTON_WHEELUP) & btn ? 1 : 0;
sdl->mouse_wd = SDL_BUTTON(SDL_BUTTON_WHEELDOWN) & btn ? 1 : 0;
sdl->mouse_wu = (SDL_BUTTON(SDL_BUTTON_WHEELUP) & btn) ? 1 : 0;
sdl->mouse_wd = (SDL_BUTTON(SDL_BUTTON_WHEELDOWN) & btn) ? 1 : 0;
#endif
}

View file

@ -131,8 +131,7 @@ void file_list_free(file_list_t *list)
if (list->list)
free(list->list);
list->list = NULL;
if (list)
free(list);
free(list);
}
void file_list_clear(file_list_t *list)

View file

@ -238,7 +238,7 @@ void retro_frewind(RFILE *stream)
ssize_t retro_fread(RFILE *stream, void *s, size_t len)
{
if (!stream)
if (!stream || !s)
return -1;
#if defined(VITA) || defined(PSP)
return sceIoRead(stream->fd, s, len);

View file

@ -33,7 +33,7 @@ bool rtga_image_load_shift(uint8_t *buf,
const uint8_t *tmp = NULL;
struct texture_image *out_img = (struct texture_image*)data;
if (buf[2] != 2)
if (!buf || buf[2] != 2)
{
fprintf(stderr, "TGA image is not uncompressed RGB.\n");
goto error;

View file

@ -41,7 +41,7 @@ void conv_rgb565_0rgb1555(void *output_, const void *input_,
int width, int height,
int out_stride, int in_stride)
{
int h, w;
int h;
const uint16_t *input = (const uint16_t*)input_;
uint16_t *output = (uint16_t*)output_;
@ -55,7 +55,7 @@ void conv_rgb565_0rgb1555(void *output_, const void *input_,
for (h = 0; h < height;
h++, output += out_stride >> 1, input += in_stride >> 1)
{
w = 0;
unsigned w = 0;
#if defined(__SSE2_)
for (; w < max_width; w += 8)
{
@ -80,7 +80,7 @@ void conv_0rgb1555_rgb565(void *output_, const void *input_,
int width, int height,
int out_stride, int in_stride)
{
int h, w;
int h;
const uint16_t *input = (const uint16_t*)input_;
uint16_t *output = (uint16_t*)output_;
@ -96,7 +96,7 @@ void conv_0rgb1555_rgb565(void *output_, const void *input_,
for (h = 0; h < height;
h++, output += out_stride >> 1, input += in_stride >> 1)
{
w = 0;
unsigned w = 0;
#if defined(__SSE2__)
for (; w < max_width; w += 8)
{
@ -124,7 +124,7 @@ void conv_0rgb1555_argb8888(void *output_, const void *input_,
int width, int height,
int out_stride, int in_stride)
{
int h, w;
int h;
const uint16_t *input = (const uint16_t*)input_;
uint32_t *output = (uint32_t*)output_;
@ -141,7 +141,7 @@ void conv_0rgb1555_argb8888(void *output_, const void *input_,
for (h = 0; h < height;
h++, output += out_stride >> 2, input += in_stride >> 1)
{
w = 0;
unsigned w = 0;
#ifdef __SSE2__
for (; w < max_width; w += 8)
{
@ -191,7 +191,7 @@ void conv_rgb565_argb8888(void *output_, const void *input_,
int width, int height,
int out_stride, int in_stride)
{
int h, w;
int h;
const uint16_t *input = (const uint16_t*)input_;
uint32_t *output = (uint32_t*)output_;
@ -210,7 +210,7 @@ void conv_rgb565_argb8888(void *output_, const void *input_,
for (h = 0; h < height;
h++, output += out_stride >> 2, input += in_stride >> 1)
{
w = 0;
unsigned w = 0;
#if defined(__SSE2__)
for (; w < max_width; w += 8)
{
@ -385,7 +385,7 @@ void conv_0rgb1555_bgr24(void *output_, const void *input_,
int width, int height,
int out_stride, int in_stride)
{
int h, w;
int h;
const uint16_t *input = (const uint16_t*)input_;
uint8_t *output = (uint8_t*)output_;
@ -403,8 +403,8 @@ void conv_0rgb1555_bgr24(void *output_, const void *input_,
h++, output += out_stride, input += in_stride >> 1)
{
uint8_t *out = output;
unsigned w = 0;
w = 0;
#if defined(__SSE2__)
for (; w < max_width; w += 16, out += 48)
{
@ -471,7 +471,7 @@ void conv_rgb565_bgr24(void *output_, const void *input_,
int width, int height,
int out_stride, int in_stride)
{
int h, w;
int h;
const uint16_t *input = (const uint16_t*)input_;
uint8_t *output = (uint8_t*)output_;
@ -490,8 +490,7 @@ void conv_rgb565_bgr24(void *output_, const void *input_,
for (h = 0; h < height; h++, output += out_stride, input += in_stride >> 1)
{
uint8_t *out = output;
w = 0;
unsigned w = 0;
#if defined(__SSE2__)
for (; w < max_width; w += 16, out += 48)
{
@ -601,7 +600,7 @@ void conv_argb8888_bgr24(void *output_, const void *input_,
int width, int height,
int out_stride, int in_stride)
{
int h, w;
int h;
const uint32_t *input = (const uint32_t*)input_;
uint8_t *output = (uint8_t*)output_;
@ -613,8 +612,7 @@ void conv_argb8888_bgr24(void *output_, const void *input_,
h++, output += out_stride, input += in_stride >> 2)
{
uint8_t *out = output;
w = 0;
unsigned w = 0;
#if defined(__SSE2__)
for (; w < max_width; w += 16, out += 48)
{
@ -668,7 +666,7 @@ void conv_yuyv_argb8888(void *output_, const void *input_,
int width, int height,
int out_stride, int in_stride)
{
int h, w;
int h;
const uint8_t *input = (const uint8_t*)input_;
uint32_t *output = (uint32_t*)output_;
@ -692,8 +690,7 @@ void conv_yuyv_argb8888(void *output_, const void *input_,
{
const uint8_t *src = input;
uint32_t *dst = output;
w = 0;
unsigned w = 0;
#if defined(__SSE2__)
/* Each loop processes 16 pixels. */

View file

@ -321,11 +321,12 @@ void state_manager_raw_decompress(const void *patch,
for (;;)
{
uint16_t i;
uint16_t numchanged = *(patch16++);
if (numchanged)
{
uint16_t i;
out16 += *patch16++;
/* We could do memcpy, but it seems that memcpy has a

View file

@ -1038,7 +1038,9 @@ int rarch_main_iterate(unsigned *sleep_ms)
unlock_autosave();
#endif
#ifdef HAVE_MENU
end:
#endif
if (!settings->fastforward_ratio)
return 0;

View file

@ -56,12 +56,12 @@
static bool screenshot_dump(const char *folder, const void *frame,
unsigned width, unsigned height, int pitch, bool bgr24)
{
bool ret;
char filename[PATH_MAX_LENGTH] = {0};
char shotname[PATH_MAX_LENGTH] = {0};
struct scaler_ctx scaler = {0};
RFILE *file = NULL;
uint8_t *out_buffer = NULL;
bool ret = false;
driver_t *driver = driver_get_ptr();
(void)file;

View file

@ -598,13 +598,14 @@ static int rarch_main_data_nbio_iterate_parse_free(nbio_handle_t *nbio)
static int rarch_main_data_nbio_iterate_parse(nbio_handle_t *nbio)
{
int len = 0;
if (!nbio)
return -1;
if (nbio->cb)
{
int len = 0;
nbio->cb(nbio, len);
}
return 0;
}