Skip to content

Commit

Permalink
Some more static code analysis nits when ran with enable=all
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Sep 28, 2015
1 parent 1eb80f6 commit 4ca5d31
Show file tree
Hide file tree
Showing 23 changed files with 89 additions and 81 deletions.
4 changes: 2 additions & 2 deletions audio/audio_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
6 changes: 4 additions & 2 deletions audio/drivers/ctr_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
21 changes: 10 additions & 11 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -1834,19 +1835,19 @@ 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;

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. */
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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';

Expand All @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion core_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions cores/ffmpeg_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
6 changes: 2 additions & 4 deletions gfx/d3d/d3d_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand All @@ -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;
Expand Down
1 change: 0 additions & 1 deletion gfx/drivers/dispmanx_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion gfx/drivers/gl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
34 changes: 16 additions & 18 deletions gfx/drivers/sunxi_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
}

Expand Down
9 changes: 6 additions & 3 deletions gfx/drivers/vita2d_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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){
Expand All @@ -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
Expand Down
8 changes: 5 additions & 3 deletions gfx/video_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion gfx/video_viewport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
3 changes: 2 additions & 1 deletion input/drivers/android_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion input/drivers/qnx_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions input/drivers/sdl_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
3 changes: 1 addition & 2 deletions libretro-common/file/file_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion libretro-common/file/retro_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion libretro-common/formats/tga/rtga.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 4ca5d31

Please sign in to comment.