Static code analysis fixes

This commit is contained in:
twinaphex 2015-09-28 16:20:26 +02:00
parent b6d31fd1a2
commit a79b571d7b
12 changed files with 49 additions and 28 deletions

View File

@ -818,17 +818,17 @@ void audio_driver_frame_is_reverse(void)
void audio_monitor_adjust_system_rates(void)
{
float timing_skew;
settings_t *settings = config_get_ptr();
struct retro_system_av_info *av_info =
video_viewport_get_system_av_info();
const struct retro_system_timing *info =
av_info ? (const struct retro_system_timing*)&av_info->timing : NULL;
settings_t *settings = config_get_ptr();
const struct retro_system_timing *info = NULL;
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
if (av_info)
info = (const struct retro_system_timing*)&av_info->timing;
if (info->sample_rate <= 0.0)
if (!info || info->sample_rate <= 0.0)
return;
timing_skew = fabs(1.0f - info->fps /
settings->video.refresh_rate);
timing_skew = fabs(1.0f - info->fps / settings->video.refresh_rate);
audio_data.in_rate = info->sample_rate;
if (timing_skew <= settings->audio.max_timing_skew)

View File

@ -158,7 +158,7 @@ static const rarch_resampler_t *find_resampler_driver(const char *ident)
#ifndef RARCH_INTERNAL
#ifdef __cplusplus
extern "C"
extern "C" {
#endif
retro_get_cpu_features_t perf_get_cpu_features_cb;

View File

@ -761,7 +761,7 @@ static bool codec_id_is_ttf(enum AVCodecID id)
switch (id)
{
#ifdef OLD_FFMPEG_API
case CODEC_ID_TTF;
case CODEC_ID_TTF:
#else
case AV_CODEC_ID_TTF:
#endif

View File

@ -1219,6 +1219,9 @@ bool rarch_environment_cb(unsigned cmd, void *data)
struct retro_game_geometry *geom = av_info ?
(struct retro_game_geometry*)&av_info->geometry : NULL;
if (!geom)
return false;
RARCH_LOG("Environ SET_GEOMETRY.\n");
/* Can potentially be called every frame,

View File

@ -527,6 +527,7 @@ HRESULT PackedResource::Create(const char *strFilename,
HRESULT PackedResource::Create(const char *strFilename)
#endif
{
unsigned i;
HANDLE hFile;
DWORD dwNumBytesRead;
XPR_HEADER xprh;
@ -617,12 +618,13 @@ HRESULT PackedResource::Create(const char *strFilename)
{
#endif
// Extract resource table from the header data
/* Extract resource table from the header data */
m_dwNumResourceTags = *(DWORD*)(m_pSysMemData + 0);
m_pResourceTags = (XBRESOURCE*)(m_pSysMemData + 4);
m_pResourceTags = (XBRESOURCE*)(m_pSysMemData + 4);
// Patch up the resources
for(DWORD i = 0; i < m_dwNumResourceTags; i++)
/* Patch up the resources */
for(i = 0; i < m_dwNumResourceTags; i++)
{
m_pResourceTags[i].strName = (char*)(m_pSysMemData + (DWORD)m_pResourceTags[i].strName);
#ifdef _XBOX360
@ -639,7 +641,7 @@ HRESULT PackedResource::Create(const char *strFilename)
#endif
#ifdef _XBOX1
// Use user-supplied number of resources and the resource tags
/* Use user-supplied number of resources and the resource tags */
if(dwNumResourceTags != 0 || pResourceTags != NULL)
{
m_pResourceTags = pResourceTags;

View File

@ -136,6 +136,9 @@ static void renderchain_set_vertices(void *data, unsigned pass,
video_driver_get_size(&width, &height);
if (!chain)
return;
if (chain->last_width != vert_width || chain->last_height != vert_height)
{
unsigned i;

View File

@ -429,6 +429,10 @@ static int omapfb_alloc_mem(omapfb_data_t *pdata)
if (av_info)
geom = &av_info->geometry;
if (!geom)
goto error;
mem_size = geom->max_width * geom->max_height *
pdata->bpp * pdata->num_pages;

View File

@ -146,7 +146,7 @@ static void *gl_raster_font_init_font(void *data,
if (!font_renderer_create_default(&font->font_driver,
&font->font_data, font_path, font_size))
{
RARCH_WARN("Couldn't init font renderer.\n");
RARCH_WARN("Couldn't initialize font renderer.\n");
free(font);
return NULL;
}
@ -158,20 +158,22 @@ static void *gl_raster_font_init_font(void *data,
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
atlas = font->font_driver->get_atlas(font->font_data);
atlas = font->font_driver->get_atlas(font->font_data);
font->tex_width = next_pow2(atlas->width);;
font->tex_height = next_pow2(atlas->height);;
if (!gl_raster_font_upload_atlas(font, atlas, font->tex_width, font->tex_height))
{
gl_raster_font_free_font(font);
font = NULL;
}
goto error;
glBindTexture(GL_TEXTURE_2D, font->gl->texture[font->gl->tex_index]);
return font;
error:
gl_raster_font_free_font(font);
font = NULL;
return NULL;
}
static void gl_raster_font_free_font(void *data)

View File

@ -307,7 +307,7 @@ bool video_driver_set_shader(enum rarch_shader_type type,
driver_t *driver = driver_get_ptr();
const video_driver_t *video = video_driver_ctx_get_ptr(driver);
if (video->set_shader)
if (video && video->set_shader)
return video->set_shader(driver->video_data, type, path);
return false;
}
@ -343,6 +343,10 @@ static void init_video_filter(enum retro_pixel_format colfmt)
}
geom = av_info ? (struct retro_game_geometry*)&av_info->geometry : NULL;
if (!geom)
return;
width = geom->max_width;
height = geom->max_height;

View File

@ -336,7 +336,10 @@ static void iohidmanager_hid_device_add(void *data, IOReturn result,
ret = IOHIDDeviceOpen(device, kIOHIDOptionsTypeNone);
if (ret != kIOReturnSuccess)
{
free(adapter);
return;
}
/* Move the device's run loop to this thread. */
IOHIDDeviceScheduleWithRunLoop(device, CFRunLoopGetCurrent(),

View File

@ -129,7 +129,7 @@ static void handle_plugged_pad(void)
while ((rc = read(g_notify, event_buf, event_size)) >= 0)
{
struct inotify_event *event = NULL;
struct inotify_event *event = (struct inotify_event*)&event_buf[0];
/* Can read multiple events in one read() call. */

View File

@ -1187,12 +1187,12 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl,
for (; i < end; i++)
{
const float half_size = xmb->icon.size / 2.0f;
char name[PATH_MAX_LENGTH];
char value[PATH_MAX_LENGTH];
menu_entry_t entry;
float icon_x, icon_y;
const float half_size = xmb->icon.size / 2.0f;
menu_entry_t entry = {{0}};
GRuint texture_switch = 0;
GRuint icon = 0;
xmb_node_t * node = (xmb_node_t*)menu_list_get_userdata_at_offset(list, i);
@ -1200,8 +1200,8 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl,
uint32_t hash_value = 0;
bool do_draw_text = false;
*entry.path = *entry.label = *entry.value = 0;
entry.idx = entry.spacing = entry.type = 0;
*entry.path = *entry.label = *entry.value = 0;
entry.idx = entry.spacing = entry.type = 0;
if (!node)
continue;