Convert most C99-style for loop initial declarations to C89-compliant

ones
This commit is contained in:
twinaphex 2013-10-22 15:08:17 +02:00
parent fc105c919b
commit d2c87e3039
40 changed files with 462 additions and 274 deletions

View File

@ -47,7 +47,7 @@ ifeq ($(PERF_TEST), 1)
LOCAL_CFLAGS += -DPERF_TEST
endif
LOCAL_CFLAGS += -Wall -pthread -Wno-unused-function -O3 -fno-stack-protector -funroll-loops -DNDEBUG -DRARCH_MOBILE -DHAVE_GRIFFIN -DANDROID -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_FBO -DHAVE_OVERLAY -DHAVE_OPENGLES -DHAVE_VID_CONTEXT -DHAVE_OPENGLES2 -DGLSL_DEBUG -DHAVE_GLSL -DHAVE_RGUI -DHAVE_SCREENSHOTS -DWANT_MINIZ -DHAVE_ZLIB -DINLINE=inline -DLSB_FIRST -DHAVE_THREADS -D__LIBRETRO__ -std=gnu99 -I../../../deps/miniz
LOCAL_CFLAGS += -Wall -pthread -Wno-unused-function -O3 -fno-stack-protector -funroll-loops -DNDEBUG -DRARCH_MOBILE -DHAVE_GRIFFIN -DANDROID -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_FBO -DHAVE_OVERLAY -DHAVE_OPENGLES -DHAVE_VID_CONTEXT -DHAVE_OPENGLES2 -DGLSL_DEBUG -DHAVE_GLSL -DHAVE_RGUI -DHAVE_SCREENSHOTS -DWANT_MINIZ -DHAVE_ZLIB -DINLINE=inline -DLSB_FIRST -DHAVE_THREADS -D__LIBRETRO__ -I../../../deps/miniz
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -landroid -lEGL -lGLESv2 $(LOGGER_LDLIBS) -ldl

View File

@ -1703,7 +1703,8 @@ static void android_input_poll(void *data)
state_id = 0; // touch overlay is always player 1
else
{
for (unsigned i = 0; i < pads_connected; i++)
unsigned i;
for (i = 0; i < pads_connected; i++)
if (state_device_ids[i] == id)
state_id = i;
}

View File

@ -98,6 +98,7 @@ static void sl_free(void *data)
static void *sl_init(const char *device, unsigned rate, unsigned latency)
{
unsigned i;
(void)device;
SLDataFormat_PCM fmt_pcm = {0};
@ -140,7 +141,7 @@ static void *sl_init(const char *device, unsigned rate, unsigned latency)
if (!sl->buffer_chunk)
goto error;
for (unsigned i = 0; i < sl->buf_count; i++)
for (i = 0; i < sl->buf_count; i++)
sl->buffer[i] = sl->buffer_chunk + i * sl->buf_size;
RARCH_LOG("[SLES]: Setting audio latency: Block size = %u, Blocks = %u, Total = %u ...\n",
@ -181,7 +182,7 @@ static void *sl_init(const char *device, unsigned rate, unsigned latency)
// Enqueue a bit to get stuff rolling.
sl->buffered_blocks = sl->buf_count;
sl->buffer_index = 0;
for (unsigned i = 0; i < sl->buf_count; i++)
for (i = 0; i < sl->buf_count; i++)
(*sl->buffer_queue)->Enqueue(sl->buffer_queue, sl->buffer[i], sl->buf_size);
GOTO_IF_FAIL(SLObjectItf_GetInterface(sl->buffer_queue_object, SL_IID_PLAY, &sl->player));

View File

@ -138,7 +138,8 @@ void autosave_free(autosave_t *handle)
void lock_autosave(void)
{
for (unsigned i = 0; i < sizeof(g_extern.autosave)/sizeof(g_extern.autosave[0]); i++)
unsigned i;
for (i = 0; i < sizeof(g_extern.autosave)/sizeof(g_extern.autosave[0]); i++)
{
if (g_extern.autosave[i])
autosave_lock(g_extern.autosave[i]);
@ -147,7 +148,8 @@ void lock_autosave(void)
void unlock_autosave(void)
{
for (unsigned i = 0; i < sizeof(g_extern.autosave)/sizeof(g_extern.autosave[0]); i++)
unsigned i;
for (i = 0; i < sizeof(g_extern.autosave)/sizeof(g_extern.autosave[0]); i++)
{
if (g_extern.autosave[i])
autosave_unlock(g_extern.autosave[i]);

View File

@ -143,9 +143,10 @@ static bool xml_grab_cheats(cheat_manager_t *handle, xmlNodePtr ptr)
static void cheat_manager_apply_cheats(cheat_manager_t *handle)
{
unsigned index = 0;
unsigned i, index;
index = 0;
pretro_cheat_reset();
for (unsigned i = 0; i < handle->size; i++)
for (i = 0; i < handle->size; i++)
{
if (handle->cheats[i].state)
pretro_cheat_set(index++, true, handle->cheats[i].code);
@ -200,10 +201,11 @@ static void cheat_manager_save_config(cheat_manager_t *handle, const char *path,
return;
}
unsigned i;
char conf_str[512] = {0};
char tmp[32] = {0};
for (unsigned i = 0; i < handle->size; i++)
for (i = 0; i < handle->size; i++)
{
if (handle->cheats[i].state)
{
@ -328,13 +330,14 @@ error:
void cheat_manager_free(cheat_manager_t *handle)
{
unsigned i;
if (!handle)
return;
if (handle->cheats)
{
cheat_manager_save_config(handle, g_settings.cheat_settings_path, g_extern.sha256);
for (unsigned i = 0; i < handle->size; i++)
for (i = 0; i < handle->size; i++)
{
xmlFree(handle->cheats[i].desc);
free(handle->cheats[i].code);

View File

@ -43,7 +43,8 @@ static bool is_long_option(const char *str)
static int find_short_index(char * const *argv)
{
for (int index = 0; argv[index]; index++)
int index;
for (index = 0; argv[index]; index++)
{
if (is_short_option(argv[index]))
return index;
@ -54,7 +55,8 @@ static int find_short_index(char * const *argv)
static int find_long_index(char * const *argv)
{
for (int index = 0; argv[index]; index++)
int index;
for (index = 0; argv[index]; index++)
{
if (is_long_option(argv[index]))
return index;
@ -109,8 +111,9 @@ static int parse_short(const char *optstring, char * const *argv)
static int parse_long(const struct option *longopts, char * const *argv)
{
size_t indice;
const struct option *opt = NULL;
for (size_t indice = 0; longopts[indice].name; indice++)
for (indice = 0; longopts[indice].name; indice++)
{
if (strcmp(longopts[indice].name, &argv[0][2]) == 0)
{

View File

@ -39,22 +39,24 @@ struct rxml_node *rxml_root_node(rxml_document_t *doc)
static void rxml_free_node(struct rxml_node *node)
{
for (struct rxml_node *head = node->children; head; )
struct rxml_node *head;
for (head = node->children; head; )
{
struct rxml_node *next_node = head->next;
rxml_free_node(head);
head = next_node;
}
for (struct rxml_attrib_node *head = node->attrib; head; )
struct rxml_attrib_node *attrib_node_head;
for (attrib_node_head = node->attrib; attrib_node_head; )
{
struct rxml_attrib_node *next_attrib = head->next;
struct rxml_attrib_node *next_attrib = attrib_node_head->next;
free(head->attrib);
free(head->value);
free(head);
free(attrib_node_head->attrib);
free(attrib_node_head->value);
free(attrib_node_head);
head = next_attrib;
attrib_node_head = next_attrib;
}
free(node->name);
@ -431,7 +433,8 @@ void rxml_free_document(rxml_document_t *doc)
char *rxml_node_attrib(struct rxml_node *node, const char *attrib)
{
for (struct rxml_attrib_node *attribs = node->attrib; attribs; attribs = attribs->next)
struct rxml_attrib_node *attribs;
for (attribs = node->attrib; attribs; attribs = attribs->next)
{
if (!strcmp(attrib, attribs->attrib))
return attribs->value;

View File

@ -27,7 +27,7 @@
core_info_list_t *core_info_list_new(const char *modules_path)
{
struct string_list *contents = dir_list_new(modules_path, EXT_EXECUTABLES, false);
size_t all_ext_len;
size_t all_ext_len, i;
core_info_t *core_info = NULL;
core_info_list_t *core_info_list = NULL;
@ -46,7 +46,7 @@ core_info_list_t *core_info_list_new(const char *modules_path)
core_info_list->list = core_info;
core_info_list->count = contents->size;
for (size_t i = 0; i < contents->size; i++)
for (i = 0; i < contents->size; i++)
{
char info_path_base[PATH_MAX], info_path[PATH_MAX];
core_info[i].path = strdup(contents->elems[i].data);
@ -95,7 +95,7 @@ core_info_list_t *core_info_list_new(const char *modules_path)
}
all_ext_len = 0;
for (size_t i = 0; i < core_info_list->count; i++)
for (i = 0; i < core_info_list->count; i++)
{
all_ext_len += core_info_list->list[i].supported_extensions ?
(strlen(core_info_list->list[i].supported_extensions) + 2) : 0;
@ -109,7 +109,7 @@ core_info_list_t *core_info_list_new(const char *modules_path)
if (core_info_list->all_ext)
{
for (size_t i = 0; i < core_info_list->count; i++)
for (i = 0; i < core_info_list->count; i++)
{
if (core_info_list->list[i].supported_extensions)
{
@ -132,10 +132,11 @@ error:
void core_info_list_free(core_info_list_t *core_info_list)
{
size_t i;
if (!core_info_list)
return;
for (size_t i = 0; i < core_info_list->count; i++)
for (i = 0; i < core_info_list->count; i++)
{
free(core_info_list->list[i].path);
free(core_info_list->list[i].display_name);
@ -151,15 +152,17 @@ void core_info_list_free(core_info_list_t *core_info_list)
size_t core_info_list_num_info_files(core_info_list_t *core_info_list)
{
size_t num = 0;
for (size_t i = 0; i < core_info_list->count; i++)
size_t i, num;
num = 0;
for (i = 0; i < core_info_list->count; i++)
num += !!core_info_list->list[i].data;
return num;
}
bool core_info_list_get_display_name(core_info_list_t *core_info_list, const char *path, char *buf, size_t size)
{
for (size_t i = 0; i < core_info_list->count; i++)
size_t i;
for (i = 0; i < core_info_list->count; i++)
{
const core_info_t *info = &core_info_list->list[i];
if (!strcmp(info->path, path) && info->display_name)
@ -174,10 +177,11 @@ bool core_info_list_get_display_name(core_info_list_t *core_info_list, const cha
bool core_info_does_support_any_file(const core_info_t *core, const struct string_list *list)
{
size_t i;
if (!list || !core || !core->supported_extensions_list)
return false;
for (size_t i = 0; i < list->size; i++)
for (i = 0; i < list->size; i++)
if (string_list_find_elem_prefix(core->supported_extensions_list, ".", path_get_extension(list->elems[i].data)))
return true;
return false;
@ -231,8 +235,9 @@ void core_info_list_get_supported_cores(core_info_list_t *core_info_list, const
// Let supported core come first in list so we can return a pointer to them.
qsort(core_info_list->list, core_info_list->count, sizeof(core_info_t), core_info_qsort_cmp);
size_t supported = 0;
for (size_t i = 0; i < core_info_list->count; i++, supported++)
size_t supported, i;
supported = 0;
for (i = 0; i < core_info_list->count; i++, supported++)
{
const core_info_t *core = &core_info_list->list[i];
if (!core_info_does_support_file(core, path)

View File

@ -38,10 +38,11 @@ struct core_option_manager
void core_option_free(core_option_manager_t *opt)
{
size_t i;
if (!opt)
return;
for (size_t i = 0; i < opt->size; i++)
for (i = 0; i < opt->size; i++)
{
free(opt->opts[i].desc);
free(opt->opts[i].key);
@ -56,8 +57,9 @@ void core_option_free(core_option_manager_t *opt)
void core_option_get(core_option_manager_t *opt, struct retro_variable *var)
{
size_t i;
opt->updated = false;
for (size_t i = 0; i < opt->size; i++)
for (i = 0; i < opt->size; i++)
{
if (strcmp(opt->opts[i].key, var->key) == 0)
{
@ -71,6 +73,7 @@ void core_option_get(core_option_manager_t *opt, struct retro_variable *var)
static bool parse_variable(core_option_manager_t *opt, size_t index, const struct retro_variable *var)
{
size_t i;
struct core_option *option = &opt->opts[index];
option->key = strdup(var->key);
@ -98,7 +101,7 @@ static bool parse_variable(core_option_manager_t *opt, size_t index, const struc
char *config_val = NULL;
if (config_get_string(opt->conf, option->key, &config_val))
{
for (size_t i = 0; i < option->vals->size; i++)
for (i = 0; i < option->vals->size; i++)
{
if (strcmp(option->vals->elems[i].data, config_val) == 0)
{
@ -117,7 +120,7 @@ static bool parse_variable(core_option_manager_t *opt, size_t index, const struc
RARCH_LOG("\tKey: %s\n", option->key);
RARCH_LOG("\tCurrent value: %s\n", core_option_get_val(opt, index));
RARCH_LOG("\tPossible values:\n");
for (size_t i = 0; i < option->vals->size; i++)
for (i = 0; i < option->vals->size; i++)
RARCH_LOG("\t\t%s\n", option->vals->elems[i].data);
return true;
@ -125,6 +128,7 @@ static bool parse_variable(core_option_manager_t *opt, size_t index, const struc
core_option_manager_t *core_option_new(const char *conf_path, const struct retro_variable *vars)
{
const struct retro_variable *var;
core_option_manager_t *opt = (core_option_manager_t*)calloc(1, sizeof(*opt));
if (!opt)
return NULL;
@ -141,7 +145,7 @@ core_option_manager_t *core_option_new(const char *conf_path, const struct retro
if (!opt->conf)
goto error;
for (const struct retro_variable *var = vars; var->key && var->value; var++)
for (var = vars; var->key && var->value; var++)
size++;
opt->opts = (struct core_option*)calloc(size, sizeof(*opt->opts));
@ -151,7 +155,7 @@ core_option_manager_t *core_option_new(const char *conf_path, const struct retro
opt->size = size;
size = 0;
for (const struct retro_variable *var = vars; var->key && var->value; size++, var++)
for (var = vars; var->key && var->value; size++, var++)
{
if (!parse_variable(opt, size, var))
goto error;
@ -171,7 +175,8 @@ bool core_option_updated(core_option_manager_t *opt)
void core_option_flush(core_option_manager_t *opt)
{
for (size_t i = 0; i < opt->size; i++)
size_t i;
for (i = 0; i < opt->size; i++)
{
struct core_option *option = &opt->opts[i];
config_set_string(opt->conf, option->key, core_option_get_val(opt, i));

View File

@ -178,7 +178,8 @@ static const input_driver_t *input_drivers[] = {
static void find_audio_driver(void)
{
for (unsigned i = 0; i < ARRAY_SIZE(audio_drivers); i++)
unsigned i;
for (i = 0; i < ARRAY_SIZE(audio_drivers); i++)
{
if (strcasecmp(g_settings.audio.driver, audio_drivers[i]->ident) == 0)
{
@ -188,7 +189,7 @@ static void find_audio_driver(void)
}
RARCH_ERR("Couldn't find any audio driver named \"%s\"\n", g_settings.audio.driver);
RARCH_LOG_OUTPUT("Available audio drivers are:\n");
for (size_t i = 0; i < ARRAY_SIZE(audio_drivers); i++)
for (i = 0; i < ARRAY_SIZE(audio_drivers); i++)
RARCH_LOG_OUTPUT("\t%s\n", audio_drivers[i]->ident);
rarch_fail(1, "find_audio_driver()");
@ -196,6 +197,7 @@ static void find_audio_driver(void)
static void find_video_driver(void)
{
unsigned i;
#if defined(HAVE_OPENGL) && defined(HAVE_FBO)
if (g_extern.system.hw_render_callback.context_type)
{
@ -205,7 +207,7 @@ static void find_video_driver(void)
}
#endif
for (unsigned i = 0; i < ARRAY_SIZE(video_drivers); i++)
for (i = 0; i < ARRAY_SIZE(video_drivers); i++)
{
if (strcasecmp(g_settings.video.driver, video_drivers[i]->ident) == 0)
{
@ -215,7 +217,7 @@ static void find_video_driver(void)
}
RARCH_ERR("Couldn't find any video driver named \"%s\"\n", g_settings.video.driver);
RARCH_LOG_OUTPUT("Available video drivers are:\n");
for (size_t i = 0; i < ARRAY_SIZE(video_drivers); i++)
for (i = 0; i < ARRAY_SIZE(video_drivers); i++)
RARCH_LOG_OUTPUT("\t%s\n", video_drivers[i]->ident);
rarch_fail(1, "find_video_driver()");
@ -223,7 +225,8 @@ static void find_video_driver(void)
static void find_input_driver(void)
{
for (unsigned i = 0; i < ARRAY_SIZE(input_drivers); i++)
unsigned i;
for (i = 0; i < ARRAY_SIZE(input_drivers); i++)
{
if (strcasecmp(g_settings.input.driver, input_drivers[i]->ident) == 0)
{
@ -233,7 +236,7 @@ static void find_input_driver(void)
}
RARCH_ERR("Couldn't find any input driver named \"%s\"\n", g_settings.input.driver);
RARCH_LOG_OUTPUT("Available input drivers are:\n");
for (size_t i = 0; i < ARRAY_SIZE(input_drivers); i++)
for (i = 0; i < ARRAY_SIZE(input_drivers); i++)
RARCH_LOG_OUTPUT("\t%s\n", input_drivers[i]->ident);
rarch_fail(1, "find_input_driver()");
@ -356,13 +359,14 @@ retro_proc_address_t driver_get_proc_address(const char *sym)
void global_init_drivers(void)
{
unsigned i;
init_drivers_pre(); // Set driver.* function callbacks.
#if defined(HAVE_RGUI) || defined(HAVE_RMENU) || defined(HAVE_RMENU_XUI)
driver.video->start(); // Statically starts video driver. Sets driver.video_data.
#endif
driver.input_data = driver.input->init();
for(unsigned i = 0; i < MAX_PLAYERS; i++)
for(i = 0; i < MAX_PLAYERS; i++)
if (driver.input->set_keybinds)
driver.input->set_keybinds(driver.input_data, g_settings.input.device[i], i, 0,
(1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));
@ -615,18 +619,19 @@ void init_audio(void)
static void compute_audio_buffer_statistics(void)
{
unsigned samples = min(g_extern.measure_data.buffer_free_samples_count, AUDIO_BUFFER_FREE_SAMPLES_COUNT);
unsigned i, samples;
samples = min(g_extern.measure_data.buffer_free_samples_count, AUDIO_BUFFER_FREE_SAMPLES_COUNT);
if (samples < 3)
return;
uint64_t accum = 0;
for (unsigned i = 1; i < samples; i++)
for (i = 1; i < samples; i++)
accum += g_extern.measure_data.buffer_free_samples[i];
int avg = accum / (samples - 1);
uint64_t accum_var = 0;
for (unsigned i = 1; i < samples; i++)
for (i = 1; i < samples; i++)
{
int diff = avg - g_extern.measure_data.buffer_free_samples[i];
accum_var += diff * diff;
@ -642,7 +647,7 @@ static void compute_audio_buffer_statistics(void)
unsigned low_water_count = 0;
unsigned high_water_count = 0;
for (unsigned i = 1; i < samples; i++)
for (i = 1; i < samples; i++)
{
if (g_extern.measure_data.buffer_free_samples[i] >= low_water_size)
low_water_count++;
@ -659,6 +664,7 @@ static void compute_audio_buffer_statistics(void)
bool driver_monitor_fps_statistics(double *refresh_rate, double *deviation, unsigned *sample_points)
{
unsigned i;
if (g_settings.video.threaded)
return false;
@ -668,11 +674,11 @@ bool driver_monitor_fps_statistics(double *refresh_rate, double *deviation, unsi
// Measure statistics on frame time (microsecs), *not* FPS.
rarch_time_t accum = 0;
for (unsigned i = 0; i < samples; i++)
for (i = 0; i < samples; i++)
accum += g_extern.measure_data.frame_time_samples[i];
#if 0
for (unsigned i = 0; i < samples; i++)
for (i = 0; i < samples; i++)
RARCH_LOG("Interval #%u: %d usec / frame.\n",
i, (int)g_extern.measure_data.frame_time_samples[i]);
#endif
@ -681,7 +687,7 @@ bool driver_monitor_fps_statistics(double *refresh_rate, double *deviation, unsi
rarch_time_t accum_var = 0;
// Drop first measurement. It is likely to be bad.
for (unsigned i = 0; i < samples; i++)
for (i = 0; i < samples; i++)
{
rarch_time_t diff = g_extern.measure_data.frame_time_samples[i] - avg;
accum_var += diff * diff;
@ -774,6 +780,7 @@ static void deinit_filter(void)
static void init_filter(bool rgb32)
{
unsigned i;
if (g_extern.filter.active)
return;
if (!*g_settings.video.filter_path)
@ -833,7 +840,7 @@ static void init_filter(bool rgb32)
goto error;
// Set up conversion map from 16-bit XRGB1555 to 32-bit ARGB.
for (unsigned i = 0; i < 0x10000; i++)
for (i = 0; i < 0x10000; i++)
{
unsigned r = (i >> 10) & 0x1f;
unsigned g = (i >> 5) & 0x1f;
@ -874,6 +881,7 @@ static void deinit_shader_dir(void)
static void init_shader_dir(void)
{
unsigned i;
if (!*g_settings.video.shader_dir)
return;
@ -887,7 +895,7 @@ static void init_shader_dir(void)
g_extern.shader_dir.ptr = 0;
dir_list_sort(g_extern.shader_dir.list, false);
for (unsigned i = 0; i < g_extern.shader_dir.list->size; i++)
for (i = 0; i < g_extern.shader_dir.list->size; i++)
RARCH_LOG("Found shader \"%s\"\n", g_extern.shader_dir.list->elems[i].data);
}

View File

@ -186,6 +186,7 @@ void libretro_free_system_info(struct retro_system_info *info)
static bool find_first_libretro(char *path, size_t size,
const char *dir, const char *rom_path)
{
size_t i;
bool ret = false;
const char *ext = path_get_extension(rom_path);
if (!ext || !*ext)
@ -203,7 +204,7 @@ static bool find_first_libretro(char *path, size_t size,
return false;
}
for (size_t i = 0; i < list->size && !ret; i++)
for (i = 0; i < list->size && !ret; i++)
{
RARCH_LOG("Checking library: \"%s\".\n", list->elems[i].data);
@ -340,6 +341,7 @@ static void load_symbols(bool is_dummy)
void libretro_get_current_core_pathname(char *name, size_t size)
{
size_t i;
if (size == 0)
return;
@ -355,7 +357,7 @@ void libretro_get_current_core_pathname(char *name, size_t size)
name[strlen(id)] = '\0';
for (size_t i = 0; id[i] != '\0'; i++)
for (i = 0; id[i] != '\0'; i++)
{
char c = id[i];
if (isspace(c) || isblank(c))
@ -471,6 +473,7 @@ void dylib_close(dylib_t lib)
bool rarch_environment_cb(unsigned cmd, void *data)
{
unsigned p, id;
switch (cmd)
{
case RETRO_ENVIRONMENT_GET_OVERSCAN:
@ -622,9 +625,9 @@ bool rarch_environment_cb(unsigned cmd, void *data)
};
RARCH_LOG("Environ SET_INPUT_DESCRIPTORS:\n");
for (unsigned p = 0; p < MAX_PLAYERS; p++)
for (p = 0; p < MAX_PLAYERS; p++)
{
for (unsigned id = 0; id < RARCH_FIRST_CUSTOM_BIND; id++)
for (id = 0; id < RARCH_FIRST_CUSTOM_BIND; id++)
{
const char *desc = g_extern.system.input_desc_btn[p][id];
if (desc)

View File

@ -112,8 +112,9 @@ void libretro_dummy_retro_reset(void)
void libretro_dummy_retro_run(void)
{
unsigned i;
dummy_input_poll_cb();
for (unsigned i = 0; i < 320 * 240; i++)
for (i = 0; i < 320 * 240; i++)
frame_buf[i] = 4 << 5;
dummy_video_cb(frame_buf, 320, 240, 640);
}

View File

@ -153,10 +153,11 @@ error:
void string_list_free(struct string_list *list)
{
size_t i;
if (!list)
return;
for (size_t i = 0; i < list->size; i++)
for (i = 0; i < list->size; i++)
free(list->elems[i].data);
free(list->elems);
free(list);
@ -244,10 +245,11 @@ error:
bool string_list_find_elem(const struct string_list *list, const char *elem)
{
size_t i;
if (!list)
return false;
for (size_t i = 0; i < list->size; i++)
for (i = 0; i < list->size; i++)
{
if (strcasecmp(list->elems[i].data, elem) == 0)
return true;
@ -258,13 +260,14 @@ bool string_list_find_elem(const struct string_list *list, const char *elem)
bool string_list_find_elem_prefix(const struct string_list *list, const char *prefix, const char *elem)
{
size_t i;
if (!list)
return false;
char prefixed[PATH_MAX];
snprintf(prefixed, sizeof(prefixed), "%s%s", prefix, elem);
for (size_t i = 0; i < list->size; i++)
for (i = 0; i < list->size; i++)
{
if (strcasecmp(list->elems[i].data, elem) == 0 ||
strcasecmp(list->elems[i].data, prefixed) == 0)
@ -740,6 +743,7 @@ void fill_pathname_join(char *out_path, const char *dir, const char *path, size_
#ifndef RARCH_CONSOLE
void fill_pathname_application_path(char *buf, size_t size)
{
size_t i;
if (!size)
return;
@ -752,7 +756,7 @@ void fill_pathname_application_path(char *buf, size_t size)
pid_t pid = getpid();
char link_path[PATH_MAX];
static const char *exts[] = { "exe", "file", "path/a.out" }; // Linux, BSD and Solaris paths. Not standardized.
for (unsigned i = 0; i < ARRAY_SIZE(exts); i++)
for (i = 0; i < ARRAY_SIZE(exts); i++)
{
snprintf(link_path, sizeof(link_path), "/proc/%u/%s", (unsigned)pid, exts[i]);
ssize_t ret = readlink(link_path, buf, size - 1);

View File

@ -41,7 +41,8 @@ static const frontend_ctx_driver_t *frontend_ctx_drivers[] = {
const frontend_ctx_driver_t *frontend_ctx_find_driver(const char *ident)
{
for (unsigned i = 0; frontend_ctx_drivers[i]; i++)
unsigned i;
for (i = 0; frontend_ctx_drivers[i]; i++)
{
if (strcmp(frontend_ctx_drivers[i]->ident, ident) == 0)
return frontend_ctx_drivers[i];
@ -52,7 +53,8 @@ const frontend_ctx_driver_t *frontend_ctx_find_driver(const char *ident)
const frontend_ctx_driver_t *frontend_ctx_init_first(void)
{
for (unsigned i = 0; frontend_ctx_drivers[i]; i++)
unsigned i;
for (i = 0; frontend_ctx_drivers[i]; i++)
return frontend_ctx_drivers[i];
return NULL;

View File

@ -59,7 +59,8 @@ void rgui_list_pop(rgui_list_t *list, size_t *directory_ptr)
void rgui_list_free(rgui_list_t *list)
{
for (size_t i = 0; i < list->size; i++)
size_t i;
for (i = 0; i < list->size; i++)
free(list->list[i].path);
free(list->list);
free(list);
@ -67,7 +68,8 @@ void rgui_list_free(rgui_list_t *list)
void rgui_list_clear(rgui_list_t *list)
{
for (size_t i = 0; i < list->size; i++)
size_t i;
for (i = 0; i < list->size; i++)
{
free(list->list[i].path);
free(list->list[i].alt);

View File

@ -62,7 +62,8 @@ void rom_history_push(rom_history_t *hist,
const char *path, const char *core_path,
const char *core_name)
{
for (size_t i = 0; i < hist->size; i++)
size_t i;
for (i = 0; i < hist->size; i++)
{
bool equal_path = (!path && !hist->entries[i].path) ||
(path && hist->entries[i].path && !strcmp(path, hist->entries[i].path));
@ -100,11 +101,12 @@ void rom_history_push(rom_history_t *hist,
static void rom_history_write_file(rom_history_t *hist)
{
size_t i;
FILE *file = fopen(hist->conf_path, "w");
if (!file)
return;
for (size_t i = 0; i < hist->size; i++)
for (i = 0; i < hist->size; i++)
{
fprintf(file, "%s\n%s\n%s\n",
hist->entries[i].path ? hist->entries[i].path : "",
@ -117,6 +119,7 @@ static void rom_history_write_file(rom_history_t *hist)
void rom_history_free(rom_history_t *hist)
{
size_t i;
if (!hist)
return;
@ -124,7 +127,7 @@ void rom_history_free(rom_history_t *hist)
rom_history_write_file(hist);
free(hist->conf_path);
for (size_t i = 0; i < hist->cap; i++)
for (i = 0; i < hist->cap; i++)
rom_history_free_entry(&hist->entries[i]);
free(hist->entries);
@ -145,10 +148,11 @@ static bool rom_history_read_file(rom_history_t *hist, const char *path)
char buf[3][PATH_MAX];
struct rom_history_entry *entry = NULL;
char *last = NULL;
unsigned i;
for (hist->size = 0; hist->size < hist->cap; hist->size++)
{
for (unsigned i = 0; i < 3; i++)
for (i = 0; i < 3; i++)
{
*buf[i] = '\0';
if (!fgets(buf[i], sizeof(buf[i]), file))

View File

@ -475,11 +475,12 @@ void menu_ticker_line(char *buf, size_t len, unsigned index, const char *str, bo
#if defined(HAVE_RMENU) || defined(HAVE_RGUI) || defined(HAVE_RMENU_XUI)
static uint64_t rgui_input(void)
{
unsigned i;
uint64_t input_state = 0;
static const struct retro_keybind *binds[] = { g_settings.input.binds[0] };
for (unsigned i = 0; i < RETRO_DEVICE_ID_JOYPAD_R2; i++)
for (i = 0; i < RETRO_DEVICE_ID_JOYPAD_R2; i++)
{
input_state |= input_input_state_func(binds,
0, RETRO_DEVICE_JOYPAD, 0, i) ? (1ULL << i) : 0;
@ -662,8 +663,9 @@ bool menu_save_new_config(void)
char config_path[PATH_MAX];
if (*g_settings.libretro && !path_is_directory(g_settings.libretro) && path_file_exists(g_settings.libretro)) // Infer file name based on libretro core.
{
unsigned i;
// In case of collision, find an alternative name.
for (unsigned i = 0; i < 16; i++)
for (i = 0; i < 16; i++)
{
fill_pathname_base(config_name, g_settings.libretro, sizeof(config_name));
path_remove_extension(config_name);
@ -717,6 +719,7 @@ bool menu_save_new_config(void)
void menu_poll_bind_state(struct rgui_bind_state *state)
{
unsigned p, b, a, h;
memset(state->state, 0, sizeof(state->state));
state->skip = input_input_state_func(NULL, 0, RETRO_DEVICE_KEYBOARD, 0, RETROK_RETURN);
@ -731,13 +734,13 @@ void menu_poll_bind_state(struct rgui_bind_state *state)
}
input_joypad_poll(joypad);
for (unsigned p = 0; p < MAX_PLAYERS; p++)
for (p = 0; p < MAX_PLAYERS; p++)
{
for (unsigned b = 0; b < RGUI_MAX_BUTTONS; b++)
for (b = 0; b < RGUI_MAX_BUTTONS; b++)
state->state[p].buttons[b] = input_joypad_button_raw(joypad, p, b);
for (unsigned a = 0; a < RGUI_MAX_AXES; a++)
for (a = 0; a < RGUI_MAX_AXES; a++)
state->state[p].axes[a] = input_joypad_axis_raw(joypad, p, a);
for (unsigned h = 0; h < RGUI_MAX_HATS; h++)
for (h = 0; h < RGUI_MAX_HATS; h++)
{
state->state[p].hats[h] |= input_joypad_hat_raw(joypad, p, HAT_UP_MASK, h) ? HAT_UP_MASK : 0;
state->state[p].hats[h] |= input_joypad_hat_raw(joypad, p, HAT_DOWN_MASK, h) ? HAT_DOWN_MASK : 0;
@ -749,6 +752,7 @@ void menu_poll_bind_state(struct rgui_bind_state *state)
void menu_poll_bind_get_rested_axes(struct rgui_bind_state *state)
{
unsigned p, a;
const rarch_joypad_driver_t *joypad = NULL;
if (driver.input && driver.input_data && driver.input->get_joypad_driver)
joypad = driver.input->get_joypad_driver(driver.input_data);
@ -759,17 +763,18 @@ void menu_poll_bind_get_rested_axes(struct rgui_bind_state *state)
return;
}
for (unsigned p = 0; p < MAX_PLAYERS; p++)
for (unsigned a = 0; a < RGUI_MAX_AXES; a++)
for (p = 0; p < MAX_PLAYERS; p++)
for (a = 0; a < RGUI_MAX_AXES; a++)
state->axis_state[p].rested_axes[a] = input_joypad_axis_raw(joypad, p, a);
}
static bool menu_poll_find_trigger_pad(struct rgui_bind_state *state, struct rgui_bind_state *new_state, unsigned p)
{
unsigned a, b, h;
const struct rgui_bind_state_port *n = &new_state->state[p];
const struct rgui_bind_state_port *o = &state->state[p];
for (unsigned b = 0; b < RGUI_MAX_BUTTONS; b++)
for (b = 0; b < RGUI_MAX_BUTTONS; b++)
{
if (n->buttons[b] && !o->buttons[b])
{
@ -780,7 +785,7 @@ static bool menu_poll_find_trigger_pad(struct rgui_bind_state *state, struct rgu
}
// Axes are a bit tricky ...
for (unsigned a = 0; a < RGUI_MAX_AXES; a++)
for (a = 0; a < RGUI_MAX_AXES; a++)
{
int locked_distance = abs(n->axes[a] - new_state->axis_state[p].locked_axes[a]);
int rested_distance = abs(n->axes[a] - new_state->axis_state[p].rested_axes[a]);
@ -801,7 +806,7 @@ static bool menu_poll_find_trigger_pad(struct rgui_bind_state *state, struct rgu
new_state->axis_state[p].locked_axes[a] = 0;
}
for (unsigned h = 0; h < RGUI_MAX_HATS; h++)
for (h = 0; h < RGUI_MAX_HATS; h++)
{
uint16_t trigged = n->hats[h] & (~o->hats[h]);
uint16_t sane_trigger = 0;
@ -827,7 +832,8 @@ static bool menu_poll_find_trigger_pad(struct rgui_bind_state *state, struct rgu
bool menu_poll_find_trigger(struct rgui_bind_state *state, struct rgui_bind_state *new_state)
{
for (unsigned p = 0; p < MAX_PLAYERS; p++)
unsigned p;
for (p = 0; p < MAX_PLAYERS; p++)
{
if (menu_poll_find_trigger_pad(state, new_state, p))
{
@ -849,7 +855,9 @@ void menu_key_event(bool down, unsigned keycode, uint32_t character, uint16_t ke
void menu_resolve_libretro_names(rgui_list_t *list, const char *dir)
{
for (size_t i = 0; i < list->size; i++)
size_t i;
for (i = 0; i < list->size; i++)
{
const char *path;
unsigned type = 0;
@ -872,10 +880,12 @@ void menu_resolve_libretro_names(rgui_list_t *list, const char *dir)
void menu_resolve_supported_cores(rgui_handle_t *rgui)
{
size_t i;
const core_info_t *info = NULL;
size_t cores = 0;
core_info_list_get_supported_cores(rgui->core_info, rgui->deferred_path, &info, &cores);
for (size_t i = 0; i < cores; i++)
for (i = 0; i < cores; i++)
{
rgui_list_push(rgui->selection_buf, info[i].path, RGUI_FILE_PLAIN, 0);
rgui_list_set_alt_at_offset(rgui->selection_buf, i, info[i].display_name);

View File

@ -35,7 +35,8 @@ static const menu_ctx_driver_t *menu_ctx_drivers[] = {
const menu_ctx_driver_t *menu_ctx_find_driver(const char *ident)
{
for (unsigned i = 0; menu_ctx_drivers[i]; i++)
unsigned i;
for (i = 0; menu_ctx_drivers[i]; i++)
{
if (strcmp(menu_ctx_drivers[i]->ident, ident) == 0)
return menu_ctx_drivers[i];
@ -46,10 +47,11 @@ const menu_ctx_driver_t *menu_ctx_find_driver(const char *ident)
bool menu_ctx_init_first(const menu_ctx_driver_t **driver, rgui_handle_t **handle)
{
unsigned i;
if (!menu_ctx_drivers[0])
return false;
for (unsigned i = 0; menu_ctx_drivers[i]; i++)
for (i = 0; menu_ctx_drivers[i]; i++)
{
void *h = menu_ctx_drivers[i]->init();
if (h)

View File

@ -61,10 +61,11 @@ static unsigned rgui_current_gx_resolution = GX_RESOLUTIONS_640_480;
#ifdef HAVE_SHADER_MANAGER
static enum rarch_shader_type shader_manager_get_type(const struct gfx_shader *shader)
{
unsigned i;
// All shader types must be the same, or we cannot use it.
enum rarch_shader_type type = RARCH_SHADER_NONE;
for (unsigned i = 0; i < shader->passes; i++)
for (i = 0; i < shader->passes; i++)
{
enum rarch_shader_type pass_type = gfx_shader_parse_type(shader->pass[i].source.cg,
RARCH_SHADER_NONE);
@ -418,9 +419,10 @@ int menu_set_settings(unsigned setting, unsigned action)
RETRO_DEVICE_LIGHTGUN_JUSTIFIERS,
};
unsigned current_device = g_settings.input.libretro_device[port];
unsigned current_index = 0;
for (unsigned i = 0; i < ARRAY_SIZE(device_types); i++)
unsigned current_device, current_index, i;
current_device = g_settings.input.libretro_device[port];
current_index = 0;
for (i = 0; i < ARRAY_SIZE(device_types); i++)
{
if (current_device == device_types[i])
{
@ -471,10 +473,11 @@ int menu_set_settings(unsigned setting, unsigned action)
case RGUI_SETTINGS_CUSTOM_BIND_DEFAULT_ALL:
if (action == RGUI_ACTION_OK)
{
unsigned i;
struct retro_keybind *target = &g_settings.input.binds[port][0];
rgui->binds.begin = RGUI_SETTINGS_BIND_BEGIN;
rgui->binds.last = RGUI_SETTINGS_BIND_LAST;
for (unsigned i = RGUI_SETTINGS_BIND_BEGIN; i <= RGUI_SETTINGS_BIND_LAST; i++, target++)
for (i = RGUI_SETTINGS_BIND_BEGIN; i <= RGUI_SETTINGS_BIND_LAST; i++, target++)
{
target->joykey = NO_BTN;
target->joyaxis = AXIS_NONE;
@ -997,7 +1000,8 @@ int menu_set_settings(unsigned setting, unsigned action)
gfx_shader_write_conf_cgp(conf, &rgui->shader);
bool ret = false;
for (unsigned d = 0; d < ARRAY_SIZE(dirs); d++)
unsigned d;
for (d = 0; d < ARRAY_SIZE(dirs); d++)
{
if (!*dirs[d])
continue;

View File

@ -301,8 +301,10 @@ static void rgui_settings_core_options_populate_entries(rgui_handle_t *rgui)
if (g_extern.system.core_options)
{
size_t opts = core_option_size(g_extern.system.core_options);
for (size_t i = 0; i < opts; i++)
size_t i, opts;
opts = core_option_size(g_extern.system.core_options);
for (i = 0; i < opts; i++)
rgui_list_push(rgui->selection_buf,
core_option_get_desc(g_extern.system.core_options, i), RGUI_SETTINGS_CORE_OPTION_START + i, 0);
}
@ -352,6 +354,7 @@ static void rgui_settings_video_options_populate_entries(rgui_handle_t *rgui)
#ifdef HAVE_SHADER_MANAGER
static void rgui_settings_shader_manager_populate_entries(rgui_handle_t *rgui)
{
unsigned i;
rgui_list_clear(rgui->selection_buf);
rgui_list_push(rgui->selection_buf, "Apply Shader Changes",
RGUI_SETTINGS_SHADER_APPLY, 0);
@ -361,7 +364,7 @@ static void rgui_settings_shader_manager_populate_entries(rgui_handle_t *rgui)
rgui_list_push(rgui->selection_buf, "Shader Passes",
RGUI_SETTINGS_SHADER_PASSES, 0);
for (unsigned i = 0; i < rgui->shader.passes; i++)
for (i = 0; i < rgui->shader.passes; i++)
{
char buf[64];
@ -509,6 +512,8 @@ static void rgui_settings_path_populate_entries(rgui_handle_t *rgui)
static void rgui_settings_controller_populate_entries(rgui_handle_t *rgui)
{
unsigned i, last;
rgui_list_clear(rgui->selection_buf);
#ifdef HAVE_OVERLAY
rgui_list_push(rgui->selection_buf, "Overlay Preset", RGUI_SETTINGS_OVERLAY_PRESET, 0);
@ -524,8 +529,9 @@ static void rgui_settings_controller_populate_entries(rgui_handle_t *rgui)
if (rgui->current_pad == 0)
rgui_list_push(rgui->selection_buf, "RGUI Menu Toggle", RGUI_SETTINGS_BIND_MENU_TOGGLE, 0);
unsigned last = (driver.input && driver.input->set_keybinds) ? RGUI_SETTINGS_BIND_R3 : RGUI_SETTINGS_BIND_LAST;
for (unsigned i = RGUI_SETTINGS_BIND_BEGIN; i <= last; i++)
last = (driver.input && driver.input->set_keybinds) ? RGUI_SETTINGS_BIND_R3 : RGUI_SETTINGS_BIND_LAST;
for (i = RGUI_SETTINGS_BIND_BEGIN; i <= last; i++)
rgui_list_push(rgui->selection_buf, input_config_bind_map[i - RGUI_SETTINGS_BIND_BEGIN].desc, i, 0);
}
@ -563,6 +569,7 @@ static int rgui_custom_bind_iterate(rgui_handle_t *rgui, rgui_action_t action)
static int rgui_start_screen_iterate(rgui_handle_t *rgui, rgui_action_t action)
{
render_text(rgui);
unsigned i;
char msg[1024];
char desc[6][64];
@ -575,7 +582,7 @@ static int rgui_start_screen_iterate(rgui_handle_t *rgui, rgui_action_t action)
RARCH_QUIT_KEY,
};
for (unsigned i = 0; i < ARRAY_SIZE(binds); i++)
for (i = 0; i < ARRAY_SIZE(binds); i++)
{
if (driver.input && driver.input->set_keybinds)
{
@ -959,8 +966,9 @@ static int rgui_settings_iterate(rgui_handle_t *rgui, rgui_action_t action)
static void history_parse(rgui_handle_t *rgui)
{
size_t history_size = rom_history_size(rgui->history);
for (size_t i = 0; i < history_size; i++)
size_t i, history_size;
history_size = rom_history_size(rgui->history);
for (i = 0; i < history_size; i++)
{
const char *path = NULL;
const char *core_path = NULL;
@ -1010,18 +1018,26 @@ static inline int rgui_list_get_first_char(rgui_list_t *buf, unsigned offset)
static void rgui_build_scroll_indices(rgui_handle_t *rgui, rgui_list_t *buf)
{
size_t i;
int current;
bool current_is_dir;
rgui->scroll_indices_size = 0;
if (!buf->size)
return;
rgui->scroll_indices[rgui->scroll_indices_size++] = 0;
int current = rgui_list_get_first_char(buf, 0);
bool current_is_dir = rgui_list_elem_is_dir(buf, 0);
for (size_t i = 1; i < buf->size; i++)
current = rgui_list_get_first_char(buf, 0);
current_is_dir = rgui_list_elem_is_dir(buf, 0);
for (i = 1; i < buf->size; i++)
{
int first = rgui_list_get_first_char(buf, i);
bool is_dir = rgui_list_elem_is_dir(buf, i);
int first;
bool is_dir;
first = rgui_list_get_first_char(buf, i);
is_dir = rgui_list_elem_is_dir(buf, i);
if ((current_is_dir && !is_dir) || (first > current))
rgui->scroll_indices[rgui->scroll_indices_size++] = i;
@ -1061,6 +1077,8 @@ static inline void rgui_ascend_alphabet(rgui_handle_t *rgui, size_t *ptr_out)
static bool rgui_directory_parse(rgui_handle_t *rgui, const char *directory, unsigned menu_type, void *ctx)
{
size_t i;
if (!*directory)
{
#if defined(GEKKO)
@ -1079,7 +1097,7 @@ static bool rgui_directory_parse(rgui_handle_t *rgui, const char *directory, uns
#elif defined(_WIN32)
unsigned drives = GetLogicalDrives();
char drive[] = " :\\";
for (unsigned i = 0; i < 32; i++)
for (i = 0; i < 32; i++)
{
drive[0] = 'A' + i;
if (drives & (1 << i))
@ -1146,7 +1164,7 @@ static bool rgui_directory_parse(rgui_handle_t *rgui, const char *directory, uns
if (menu_type_is_directory_browser(menu_type))
rgui_list_push(ctx, "<Use this directory>", RGUI_FILE_USE_DIRECTORY, 0);
for (size_t i = 0; i < list->size; i++)
for (i = 0; i < list->size; i++)
{
bool is_dir = list->elems[i].attr.b;

View File

@ -7,9 +7,10 @@
static void rgui_copy_glyph(uint8_t *glyph, const uint8_t *buf)
{
for (int y = 0; y < FONT_HEIGHT; y++)
int y, x;
for (y = 0; y < FONT_HEIGHT; y++)
{
for (int x = 0; x < FONT_WIDTH; x++)
for (x = 0; x < FONT_WIDTH; x++)
{
uint32_t col =
((uint32_t)buf[3 * (-y * 256 + x) + 0] << 0) |
@ -54,19 +55,21 @@ static void fill_rect(uint16_t *buf, unsigned pitch,
unsigned width, unsigned height,
uint16_t (*col)(unsigned x, unsigned y))
{
for (unsigned j = y; j < y + height; j++)
for (unsigned i = x; i < x + width; i++)
unsigned j, i;
for (j = y; j < y + height; j++)
for (i = x; i < x + width; i++)
buf[j * (pitch >> 1) + i] = col(i, j);
}
static void blit_line(rgui_handle_t *rgui,
int x, int y, const char *message, bool green)
{
int j, i;
while (*message)
{
for (int j = 0; j < FONT_HEIGHT; j++)
for (j = 0; j < FONT_HEIGHT; j++)
{
for (int i = 0; i < FONT_WIDTH; i++)
for (i = 0; i < FONT_WIDTH; i++)
{
uint8_t rem = 1 << ((i + j * FONT_WIDTH) & 7);
int offset = (i + j * FONT_WIDTH) >> 3;
@ -91,9 +94,10 @@ static void blit_line(rgui_handle_t *rgui,
static void init_font(rgui_handle_t *rgui, const uint8_t *font_bmp_buf)
{
unsigned i;
uint8_t *font = (uint8_t *) calloc(1, FONT_OFFSET(256));
rgui->alloc_font = true;
for (unsigned i = 0; i < 256; i++)
for (i = 0; i < 256; i++)
{
unsigned y = i / 16;
unsigned x = i % 16;
@ -142,6 +146,8 @@ static void render_background(rgui_handle_t *rgui)
static void render_messagebox(rgui_handle_t *rgui, const char *message)
{
size_t i;
if (!message || !*message)
return;
@ -156,7 +162,7 @@ static void render_messagebox(rgui_handle_t *rgui, const char *message)
unsigned width = 0;
unsigned glyphs_width = 0;
for (size_t i = 0; i < list->size; i++)
for (i = 0; i < list->size; i++)
{
char *msg = list->elems[i].data;
unsigned msglen = strlen(msg);
@ -193,7 +199,7 @@ static void render_messagebox(rgui_handle_t *rgui, const char *message)
fill_rect(rgui->frame_buf, rgui->frame_buf_pitch,
x, y + 5, 5, height - 5, green_filler);
for (size_t i = 0; i < list->size; i++)
for (i = 0; i < list->size; i++)
{
const char *msg = list->elems[i].data;
int offset_x = FONT_WIDTH_STRIDE * (glyphs_width - strlen(msg)) / 2;
@ -329,10 +335,13 @@ static void render_text(void *data)
snprintf(title_msg, sizeof(title_msg), "%s - %s %s", PACKAGE_VERSION, core_name, core_version);
blit_line(rgui, TERM_START_X + 15, (TERM_HEIGHT * FONT_HEIGHT_STRIDE) + TERM_START_Y + 2, title_msg, true);
unsigned x = TERM_START_X;
unsigned y = TERM_START_Y;
unsigned x, y;
size_t i;
for (size_t i = begin; i < end; i++, y += FONT_HEIGHT_STRIDE)
x = TERM_START_X;
y = TERM_START_Y;
for (i = begin; i < end; i++, y += FONT_HEIGHT_STRIDE)
{
const char *path = 0;
unsigned type = 0;

View File

@ -30,17 +30,18 @@ struct font_renderer
static void char_to_texture(font_renderer_t *handle, uint8_t letter)
{
unsigned y, x, xo, yo;
handle->bitmap_chars[letter] = &handle->bitmap_alloc[letter * FONT_WIDTH * FONT_HEIGHT * handle->scale_factor * handle->scale_factor];
for (unsigned y = 0; y < FONT_HEIGHT; y++)
for (y = 0; y < FONT_HEIGHT; y++)
{
for (unsigned x = 0; x < FONT_WIDTH; x++)
for (x = 0; x < FONT_WIDTH; x++)
{
uint8_t rem = 1 << ((x + y * FONT_WIDTH) & 7);
unsigned offset = (x + y * FONT_WIDTH) >> 3;
uint8_t col = (bitmap_bin[FONT_OFFSET(letter) + offset] & rem) ? 0xFF : 0;
for (unsigned xo = 0; xo < handle->scale_factor; xo++)
for (unsigned yo = 0; yo < handle->scale_factor; yo++)
for (xo = 0; xo < handle->scale_factor; xo++)
for (yo = 0; yo < handle->scale_factor; yo++)
handle->bitmap_chars[letter][x * handle->scale_factor + xo + (y * handle->scale_factor + yo) * FONT_WIDTH * handle->scale_factor] = col;
}
}
@ -49,6 +50,7 @@ static void char_to_texture(font_renderer_t *handle, uint8_t letter)
static void *font_renderer_init(const char *font_path, float font_size)
{
unsigned i;
font_renderer_t *handle = (font_renderer_t*)calloc(1, sizeof(*handle));
if (!handle)
return NULL;
@ -65,7 +67,7 @@ static void *font_renderer_init(const char *font_path, float font_size)
return NULL;
}
for (unsigned i = 0; i < 256; i++)
for (i = 0; i < 256; i++)
char_to_texture(handle, i);
return handle;
@ -73,6 +75,7 @@ static void *font_renderer_init(const char *font_path, float font_size)
static void font_renderer_msg(void *data, const char *msg, struct font_output_list *output)
{
size_t i;
font_renderer_t *handle = (font_renderer_t*)data;
output->head = NULL;
@ -80,7 +83,7 @@ static void font_renderer_msg(void *data, const char *msg, struct font_output_li
size_t len = strlen(msg);
int off_x = 0;
for (size_t i = 0; i < len; i++)
for (i = 0; i < len; i++)
{
struct font_output *tmp = (struct font_output*)calloc(1, sizeof(*tmp));
if (!tmp)

View File

@ -29,7 +29,8 @@ static const font_renderer_driver_t *font_backends[] = {
bool font_renderer_create_default(const font_renderer_driver_t **driver, void **handle)
{
for (unsigned i = 0; i < ARRAY_SIZE(font_backends); i++)
unsigned i;
for (i = 0; i < ARRAY_SIZE(font_backends); i++)
{
const char *font_path = *g_settings.video.font_path ? g_settings.video.font_path : NULL;
if (!font_path)

View File

@ -27,7 +27,8 @@ static const gl_font_renderer_t *gl_font_backends[] = {
const gl_font_renderer_t *gl_font_init_first(void *data, const char *font_path, float font_size)
{
for (unsigned i = 0; i < ARRAY_SIZE(gl_font_backends); i++)
size_t i;
for (i = 0; i < ARRAY_SIZE(gl_font_backends); i++)
{
if (gl_font_backends[i]->init(data, font_path, font_size))
return gl_font_backends[i];

View File

@ -20,6 +20,7 @@
static bool gl_init_font(void *data, const char *font_path, float font_size)
{
size_t i, j;
if (!g_settings.video.font_enable)
return false;
@ -43,7 +44,7 @@ static bool gl_init_font(void *data, const char *font_path, float font_size)
return false;
}
for (unsigned i = 0; i < 4; i++)
for (i = 0; i < 4; i++)
{
gl->font_color[4 * i + 0] = g_settings.video.msg_color_r;
gl->font_color[4 * i + 1] = g_settings.video.msg_color_g;
@ -51,9 +52,9 @@ static bool gl_init_font(void *data, const char *font_path, float font_size)
gl->font_color[4 * i + 3] = 1.0;
}
for (unsigned i = 0; i < 4; i++)
for (i = 0; i < 4; i++)
{
for (unsigned j = 0; j < 3; j++)
for (j = 0; j < 3; j++)
gl->font_color_dark[4 * i + j] = 0.3 * gl->font_color[4 * i + j];
gl->font_color_dark[4 * i + 3] = 1.0;
}
@ -145,6 +146,7 @@ static void adjust_power_of_two(gl_t *gl, struct font_rect *geom)
static void copy_glyph(const struct font_output *head, const struct font_rect *geom, uint32_t *buffer, unsigned width, unsigned height)
{
int h, w;
// head has top-left oriented coords.
int x = head->off_x - geom->x;
int y = head->off_y - geom->y;
@ -173,10 +175,10 @@ static void copy_glyph(const struct font_output *head, const struct font_rect *g
font_height = height - y;
uint32_t *dst = buffer + y * width + x;
for (int h = 0; h < font_height; h++, dst += width, src += head->pitch)
for (h = 0; h < font_height; h++, dst += width, src += head->pitch)
{
uint8_t *d = (uint8_t*)dst;
for (int w = 0; w < font_width; w++)
for (w = 0; w < font_width; w++)
{
*d++ = 0xff;
*d++ = 0xff;
@ -207,6 +209,7 @@ static void blit_fonts(gl_t *gl, const struct font_output *head, const struct fo
static void calculate_font_coords(gl_t *gl,
GLfloat font_vertex[8], GLfloat font_vertex_dark[8], GLfloat font_tex_coords[8], GLfloat scale, GLfloat pos_x, GLfloat pos_y)
{
unsigned i;
GLfloat scale_factor = scale;
GLfloat lx = pos_x;
@ -225,7 +228,7 @@ static void calculate_font_coords(gl_t *gl,
GLfloat shift_x = 2.0f / gl->vp.width;
GLfloat shift_y = 2.0f / gl->vp.height;
for (unsigned i = 0; i < 4; i++)
for (i = 0; i < 4; i++)
{
font_vertex_dark[2 * i + 0] = font_vertex[2 * i + 0] - shift_x;
font_vertex_dark[2 * i + 1] = font_vertex[2 * i + 1] - shift_y;

View File

@ -208,12 +208,13 @@ char rotation_lut[4][32] =
void gfx_set_square_pixel_viewport(unsigned width, unsigned height)
{
unsigned len, highest, i;
if (width == 0 || height == 0)
return;
unsigned len = min(width, height);
unsigned highest = 1;
for (unsigned i = 1; i < len; i++)
len = min(width, height);
highest = 1;
for (i = 1; i < len; i++)
{
if ((width % i) == 0 && (height % i) == 0)
highest = i;

View File

@ -60,7 +60,8 @@ static const gfx_ctx_driver_t *gfx_ctx_drivers[] = {
const gfx_ctx_driver_t *gfx_ctx_find_driver(const char *ident)
{
for (unsigned i = 0; i < ARRAY_SIZE(gfx_ctx_drivers); i++)
unsigned i;
for (i = 0; i < ARRAY_SIZE(gfx_ctx_drivers); i++)
{
if (strcmp(gfx_ctx_drivers[i]->ident, ident) == 0)
return gfx_ctx_drivers[i];
@ -71,7 +72,8 @@ const gfx_ctx_driver_t *gfx_ctx_find_driver(const char *ident)
const gfx_ctx_driver_t *gfx_ctx_init_first(enum gfx_ctx_api api, unsigned major, unsigned minor)
{
for (unsigned i = 0; i < ARRAY_SIZE(gfx_ctx_drivers); i++)
unsigned i;
for (i = 0; i < ARRAY_SIZE(gfx_ctx_drivers); i++)
{
if (gfx_ctx_drivers[i]->bind_api(api, major, minor))
{

View File

@ -93,9 +93,10 @@ static inline bool gl_query_extension(gl_t *gl, const char *ext)
if (gl->core_context)
{
#ifdef GL_NUM_EXTENSIONS
GLint exts = 0;
GLint i, exts;
exts = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &exts);
for (GLint i = 0; i < exts; i++)
for (i = 0; i < exts; i++)
{
const char *str = (const char*)glGetStringi(GL_EXTENSIONS, i);
if (str && strstr(str, ext))
@ -372,18 +373,19 @@ static void gl_shader_scale(void *data, unsigned index, struct gfx_fbo_scale *sc
static void gl_compute_fbo_geometry(void *data, unsigned width, unsigned height,
unsigned vp_width, unsigned vp_height)
{
unsigned i, last_width, last_height, last_max_width, last_max_height;
gl_t *gl = (gl_t*)data;
unsigned last_width = width;
unsigned last_height = height;
unsigned last_max_width = gl->tex_w;
unsigned last_max_height = gl->tex_h;
last_width = width;
last_height = height;
last_max_width = gl->tex_w;
last_max_height = gl->tex_h;
GLint max_size = 0;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_size);
bool size_modified = false;
// Calculate viewports for FBOs.
for (int i = 0; i < gl->fbo_pass; i++)
for (i = 0; i < gl->fbo_pass; i++)
{
switch (gl->fbo_scale[i].type_x)
{
@ -466,12 +468,13 @@ static void gl_compute_fbo_geometry(void *data, unsigned width, unsigned height,
static void gl_create_fbo_textures(void *data)
{
int i;
gl_t *gl = (gl_t*)data;
glGenTextures(gl->fbo_pass, gl->fbo_texture);
GLuint base_filt = g_settings.video.smooth ? GL_LINEAR : GL_NEAREST;
for (int i = 0; i < gl->fbo_pass; i++)
for (i = 0; i < gl->fbo_pass; i++)
{
glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[i]);
@ -535,11 +538,12 @@ static void gl_create_fbo_textures(void *data)
static bool gl_create_fbo_targets(void *data)
{
int i;
gl_t *gl = (gl_t*)data;
glBindTexture(GL_TEXTURE_2D, 0);
glGenFramebuffers(gl->fbo_pass, gl->fbo);
for (int i = 0; i < gl->fbo_pass; i++)
for (i = 0; i < gl->fbo_pass; i++)
{
glBindFramebuffer(GL_FRAMEBUFFER, gl->fbo[i]);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gl->fbo_texture[i], 0);
@ -574,6 +578,7 @@ void gl_deinit_fbo(void *data)
void gl_init_fbo(void *data, unsigned width, unsigned height)
{
int i;
gl_t *gl = (gl_t*)data;
if (gl_shader_num(gl) == 0)
@ -607,7 +612,7 @@ void gl_init_fbo(void *data, unsigned width, unsigned height)
gl->fbo_scale[0] = scale;
for (int i = 1; i < gl->fbo_pass; i++)
for (i = 1; i < gl->fbo_pass; i++)
{
gl_shader_scale(gl, i + 1, &gl->fbo_scale[i]);
@ -621,7 +626,7 @@ void gl_init_fbo(void *data, unsigned width, unsigned height)
gl_compute_fbo_geometry(gl, width, height, gl->win_width, gl->win_height);
for (int i = 0; i < gl->fbo_pass; i++)
for (i = 0; i < gl->fbo_pass; i++)
{
gl->fbo_rect[i].width = next_pow2(gl->fbo_rect[i].img_width);
gl->fbo_rect[i].height = next_pow2(gl->fbo_rect[i].img_height);
@ -651,6 +656,7 @@ static void gl_deinit_hw_render(gl_t *gl)
static bool gl_init_hw_render(gl_t *gl, unsigned width, unsigned height)
{
unsigned i;
RARCH_LOG("[GL]: Initializing HW render (%u x %u).\n", width, height);
GLint max_fbo_size = 0;
GLint max_renderbuffer_size = 0;
@ -678,7 +684,7 @@ static bool gl_init_hw_render(gl_t *gl, unsigned width, unsigned height)
gl->hw_render_depth_init = true;
}
for (unsigned i = 0; i < gl->textures; i++)
for (i = 0; i < gl->textures; i++)
{
glBindFramebuffer(GL_FRAMEBUFFER, gl->hw_render_fbo[i]);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gl->texture[i], 0);
@ -868,10 +874,11 @@ static inline void gl_start_frame_fbo(void *data)
static void gl_check_fbo_dimensions(void *data)
{
int i;
gl_t *gl = (gl_t*)data;
// Check if we have to recreate our FBO textures.
for (int i = 0; i < gl->fbo_pass; i++)
for (i = 0; i < gl->fbo_pass; i++)
{
// Check proactively since we might suddently get sizes of tex_w width or tex_h height.
if (gl->fbo_rect[i].max_img_width > gl->fbo_rect[i].width ||
@ -904,6 +911,7 @@ static void gl_check_fbo_dimensions(void *data)
static void gl_frame_fbo(void *data, const struct gl_tex_info *tex_info)
{
size_t i;
gl_t *gl = (gl_t*)data;
GLfloat fbo_tex_coords[8] = {0.0f};
@ -919,7 +927,7 @@ static void gl_frame_fbo(void *data, const struct gl_tex_info *tex_info)
unsigned fbo_tex_info_cnt = 0;
// Calculate viewports, texture coordinates etc, and render all passes from FBOs, to another FBO.
for (int i = 1; i < gl->fbo_pass; i++)
for (i = 1; i < gl->fbo_pass; i++)
{
prev_rect = &gl->fbo_rect[i - 1];
rect = &gl->fbo_rect[i];
@ -1097,14 +1105,15 @@ static inline void gl_convert_frame_argb8888_abgr8888(void *data, void *output,
static void gl_init_textures_data(void *data)
{
unsigned i;
gl_t *gl = (gl_t*)data;
for (unsigned i = 0; i < gl->textures; i++)
for (i = 0; i < gl->textures; i++)
{
gl->last_width[i] = gl->tex_w;
gl->last_height[i] = gl->tex_h;
}
for (unsigned i = 0; i < gl->textures; i++)
for (i = 0; i < gl->textures; i++)
{
gl->prev_info[i].tex = gl->texture[0];
gl->prev_info[i].input_size[0] = gl->tex_w;
@ -1117,6 +1126,7 @@ static void gl_init_textures_data(void *data)
static void gl_init_textures(void *data, const video_info_t *video)
{
unsigned i;
gl_t *gl = (gl_t*)data;
#if defined(HAVE_EGL) && defined(HAVE_OPENGLES2)
// Use regular textures if we use HW render.
@ -1164,7 +1174,7 @@ static void gl_init_textures(void *data, const video_info_t *video)
glGenTextures(gl->textures, gl->texture);
for (unsigned i = 0; i < gl->textures; i++)
for (i = 0; i < gl->textures; i++)
{
glBindTexture(GL_TEXTURE_2D, gl->texture[i]);
@ -1193,6 +1203,7 @@ static void gl_init_textures(void *data, const video_info_t *video)
static inline void gl_copy_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch)
{
unsigned h;
gl_t *gl = (gl_t*)data;
#if defined(HAVE_OPENGLES2)
#if defined(HAVE_EGL)
@ -1240,7 +1251,7 @@ static inline void gl_copy_frame(void *data, const void *frame, unsigned width,
uint8_t *dst = (uint8_t*)gl->conv_buffer; // This buffer is preallocated for this purpose.
const uint8_t *src = (const uint8_t*)frame;
for (unsigned h = 0; h < height; h++, src += pitch, dst += line_bytes)
for (h = 0; h < height; h++, src += pitch, dst += line_bytes)
memcpy(dst, src, line_bytes);
glTexSubImage2D(GL_TEXTURE_2D,
@ -1256,7 +1267,7 @@ static inline void gl_copy_frame(void *data, const void *frame, unsigned width,
size_t frame_copy_size = width * gl->base_size;
uint8_t *buffer = (uint8_t*)glMapBuffer(GL_TEXTURE_REFERENCE_BUFFER_SCE, GL_READ_WRITE) + buffer_addr;
for (unsigned h = 0; h < height; h++, buffer += buffer_stride, frame_copy += pitch)
for (h = 0; h < height; h++, buffer += buffer_stride, frame_copy += pitch)
memcpy(buffer, frame_copy, frame_copy_size);
glUnmapBuffer(GL_TEXTURE_REFERENCE_BUFFER_SCE);
@ -1552,7 +1563,8 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei
#ifdef HAVE_OVERLAY
static void gl_free_overlay(gl_t *gl)
{
for (unsigned i = 0; i < gl->overlays; i++)
unsigned i;
for (i = 0; i < gl->overlays; i++)
if (gl->overlay[i].tex)
glDeleteTextures(1, &gl->overlay[i].tex);
@ -2174,6 +2186,7 @@ static bool gl_focus(void *data)
static void gl_update_tex_filter_frame(gl_t *gl)
{
unsigned i;
bool smooth = false;
if (!gl_shader_filter_type(gl, 1, &smooth))
smooth = g_settings.video.smooth;
@ -2186,7 +2199,7 @@ static void gl_update_tex_filter_frame(gl_t *gl)
gl->tex_filter = new_filt;
gl->wrap_mode = wrap_mode;
for (unsigned i = 0; i < gl->textures; i++)
for (i = 0; i < gl->textures; i++)
{
if (gl->texture[i])
{
@ -2307,6 +2320,7 @@ static void gl_viewport_info(void *data, struct rarch_viewport *vp)
static bool gl_read_viewport(void *data, uint8_t *buffer)
{
unsigned i;
gl_t *gl = (gl_t*)data;
RARCH_PERFORMANCE_INIT(read_viewport);
@ -2328,7 +2342,7 @@ static bool gl_read_viewport(void *data, uint8_t *buffer)
uint8_t *pixels = (uint8_t*)buffer;
unsigned num_pixels = gl->vp.width * gl->vp.height;
// Convert RGB to BGR. Formats are byte ordered, so just swap 1st and 3rd byte.
for (unsigned i = 0; i <= num_pixels; pixels += 3, i++)
for (i = 0; i <= num_pixels; pixels += 3, i++)
{
uint8_t tmp = pixels[2];
pixels[2] = pixels[0];
@ -2421,6 +2435,7 @@ static void gl_restart(void)
static void gl_free_overlay(gl_t *gl);
static bool gl_overlay_load(void *data, const struct video_overlay_image *images, unsigned num_images)
{
unsigned i;
gl_t *gl = (gl_t*)data;
gl_free_overlay(gl);
@ -2430,7 +2445,7 @@ static bool gl_overlay_load(void *data, const struct video_overlay_image *images
gl->overlays = num_images;
for (unsigned i = 0; i < num_images; i++)
for (i = 0; i < num_images; i++)
{
struct gl_overlay_data *data = &gl->overlay[i];
glGenTextures(1, &data->tex);
@ -2509,6 +2524,7 @@ static void gl_overlay_set_alpha(void *data, unsigned image, float mod)
static void gl_render_overlay(void *data)
{
unsigned i, j;
gl_t *gl = (gl_t*)data;
GLfloat white_color_mod[16] = {
@ -2526,10 +2542,10 @@ static void gl_render_overlay(void *data)
if (gl->overlay_full_screen)
glViewport(0, 0, gl->win_width, gl->win_height);
for (unsigned i = 0; i < gl->overlays; i++)
for (i = 0; i < gl->overlays; i++)
{
glBindTexture(GL_TEXTURE_2D, gl->overlay[i].tex);
for (unsigned j = 0; j < 4; j++)
for (j = 0; j < 4; j++)
white_color_mod[3 + j * 4] = gl->overlay[i].alpha_mod;
gl->coords.vertex = gl->overlay[i].vertex_coord;
gl->coords.tex_coord = gl->overlay[i].tex_coord;

View File

@ -32,6 +32,7 @@
bool texture_image_load_argb_shift(const char *path, struct texture_image *out_img,
unsigned a_shift, unsigned r_shift, unsigned g_shift, unsigned b_shift)
{
int y, x;
SDL_Surface *img = IMG_Load(path);
if (!img)
return false;
@ -52,12 +53,12 @@ bool texture_image_load_argb_shift(const char *path, struct texture_image *out_i
RARCH_LOG("SDL_image: %dx%d @ %d bpp\n", img->w, img->h, img->format->BitsPerPixel);
if (img->format->BitsPerPixel == 32)
{
for (int y = 0; y < img->h; y++)
for (y = 0; y < img->h; y++)
{
uint32_t *dst = out_img->pixels + y * img->w;
const uint32_t *src = (const uint32_t*)img->pixels + y * img->pitch / sizeof(uint32_t);
for (int x = 0; x < img->w; x++)
for (x = 0; x < img->w; x++)
{
uint32_t r = (src[x] & fmt->Rmask) >> fmt->Rshift;
uint32_t g = (src[x] & fmt->Gmask) >> fmt->Gshift;
@ -69,12 +70,12 @@ bool texture_image_load_argb_shift(const char *path, struct texture_image *out_i
}
else if (img->format->BitsPerPixel == 24)
{
for (int y = 0; y < img->h; y++)
for (y = 0; y < img->h; y++)
{
uint32_t *dst = out_img->pixels + y * img->w;
const uint8_t *src = (const uint8_t*)img->pixels + y * img->pitch;
for (int x = 0; x < img->w; x++)
for (x = 0; x < img->w; x++)
{
// Correct?
uint32_t color = 0;
@ -105,6 +106,7 @@ bool texture_image_load_argb_shift(const char *path, struct texture_image *out_i
static bool texture_image_load_tga_shift(const char *path, struct texture_image *out_img,
unsigned a_shift, unsigned r_shift, unsigned g_shift, unsigned b_shift)
{
unsigned i;
void *raw_buf = NULL;
ssize_t len = read_file(path, &raw_buf);
if (len < 0)
@ -148,7 +150,7 @@ static bool texture_image_load_tga_shift(const char *path, struct texture_image
const uint8_t *tmp = buf + 18;
if (bits == 32)
{
for (unsigned i = 0; i < width * height; i++)
for (i = 0; i < width * height; i++)
{
uint32_t b = tmp[i * 4 + 0];
uint32_t g = tmp[i * 4 + 1];
@ -160,7 +162,7 @@ static bool texture_image_load_tga_shift(const char *path, struct texture_image
}
else if (bits == 24)
{
for (unsigned i = 0; i < width * height; i++)
for (i = 0; i < width * height; i++)
{
uint32_t b = tmp[i * 3 + 0];
uint32_t g = tmp[i * 3 + 1];
@ -186,6 +188,7 @@ static bool texture_image_load_tga_shift(const char *path, struct texture_image
bool texture_image_load_argb_shift(const char *path, struct texture_image *out_img,
unsigned a_shift, unsigned r_shift, unsigned g_shift, unsigned b_shift)
{
unsigned i;
if (strstr(path, ".tga"))
return texture_image_load_tga_shift(path, out_img, a_shift, r_shift, g_shift, b_shift);
#ifdef HAVE_ZLIB
@ -201,7 +204,7 @@ bool texture_image_load_argb_shift(const char *path, struct texture_image *out_i
{
unsigned num_pixels = out_img->width * out_img->height;
uint32_t *pixels = out_img->pixels;
for (unsigned i = 0; i < num_pixels; i++)
for (i = 0; i < num_pixels; i++)
{
uint32_t col = pixels[i];
uint8_t a = (uint8_t)(col >> 24);

View File

@ -247,6 +247,7 @@ static const char *stock_fragment_core_blend =
static GLint get_uniform(GLuint prog, const char *base)
{
unsigned i;
char buf[64];
snprintf(buf, sizeof(buf), "%s%s", glsl_shader->prefix, base);
@ -254,7 +255,7 @@ static GLint get_uniform(GLuint prog, const char *base)
if (loc >= 0)
return loc;
for (unsigned i = 0; i < ARRAY_SIZE(glsl_prefixes); i++)
for (i = 0; i < ARRAY_SIZE(glsl_prefixes); i++)
{
snprintf(buf, sizeof(buf), "%s%s", glsl_prefixes[i], base);
GLint loc = glGetUniformLocation(prog, buf);
@ -267,13 +268,14 @@ static GLint get_uniform(GLuint prog, const char *base)
static GLint get_attrib(GLuint prog, const char *base)
{
unsigned i;
char buf[64];
snprintf(buf, sizeof(buf), "%s%s", glsl_shader->prefix, base);
GLint loc = glGetUniformLocation(prog, buf);
if (loc >= 0)
return loc;
for (unsigned i = 0; i < ARRAY_SIZE(glsl_prefixes); i++)
for (i = 0; i < ARRAY_SIZE(glsl_prefixes); i++)
{
snprintf(buf, sizeof(buf), "%s%s", glsl_prefixes[i], base);
GLint loc = glGetAttribLocation(prog, buf);
@ -286,12 +288,13 @@ static GLint get_attrib(GLuint prog, const char *base)
static bool load_luts(void)
{
unsigned i;
if (!glsl_shader->luts)
return true;
glGenTextures(1, gl_teximage);
for (unsigned i = 0; i < glsl_shader->luts; i++)
for (i = 0; i < glsl_shader->luts; i++)
{
RARCH_LOG("Loading texture image from: \"%s\" ...\n",
glsl_shader->lut[i].path);
@ -479,7 +482,8 @@ static bool load_source_path(struct gfx_shader_pass *pass, const char *path)
static bool compile_programs(GLuint *gl_prog)
{
for (unsigned i = 0; i < glsl_shader->passes; i++)
unsigned i;
for (i = 0; i < glsl_shader->passes; i++)
{
struct gfx_shader_pass *pass = &glsl_shader->pass[i];
@ -510,7 +514,8 @@ static bool compile_programs(GLuint *gl_prog)
static void gl_glsl_reset_attrib(void)
{
for (unsigned i = 0; i < gl_attrib_index; i++)
unsigned i;
for (i = 0; i < gl_attrib_index; i++)
glDisableVertexAttribArray(gl_attribs[i]);
gl_attrib_index = 0;
}
@ -529,11 +534,12 @@ static void gl_glsl_set_vbo(GLfloat *buffer, size_t *buffer_elems, const GLfloat
static void gl_glsl_set_attribs(GLuint vbo, GLfloat *buffer, size_t *buffer_elems,
const GLfloat *data, size_t elems, const struct glsl_attrib *attrs, size_t num_attrs)
{
size_t i;
glBindBuffer(GL_ARRAY_BUFFER, vbo);
gl_glsl_set_vbo(buffer, buffer_elems, data, elems);
for (size_t i = 0; i < num_attrs; i++)
for (i = 0; i < num_attrs; i++)
{
GLint loc = attrs[i].loc;
glEnableVertexAttribArray(loc);
@ -578,6 +584,7 @@ static void find_uniforms_frame(GLuint prog, struct shader_uniforms_frame *frame
static void find_uniforms(unsigned pass, GLuint prog, struct shader_uniforms *uni)
{
unsigned i;
glUseProgram(prog);
uni->mvp = get_uniform(prog, "MVPMatrix");
@ -593,7 +600,7 @@ static void find_uniforms(unsigned pass, GLuint prog, struct shader_uniforms *un
uni->frame_count = get_uniform(prog, "FrameCount");
uni->frame_direction = get_uniform(prog, "FrameDirection");
for (unsigned i = 0; i < glsl_shader->luts; i++)
for (i = 0; i < glsl_shader->luts; i++)
uni->lut_texture[i] = glGetUniformLocation(prog, glsl_shader->lut[i].id);
char frame_base[64];
@ -605,7 +612,7 @@ static void find_uniforms(unsigned pass, GLuint prog, struct shader_uniforms *un
find_uniforms_frame(prog, &uni->orig, frame_base);
}
for (unsigned i = 0; i < GFX_MAX_SHADERS; i++)
for (i = 0; i < GFX_MAX_SHADERS; i++)
{
snprintf(frame_base, sizeof(frame_base), "Pass%u", i + 1);
clear_uniforms_frame(&uni->pass[i]);
@ -619,7 +626,7 @@ static void find_uniforms(unsigned pass, GLuint prog, struct shader_uniforms *un
clear_uniforms_frame(&uni->prev[0]);
find_uniforms_frame(prog, &uni->prev[0], "Prev");
for (unsigned i = 1; i < PREV_TEXTURES; i++)
for (i = 1; i < PREV_TEXTURES; i++)
{
snprintf(frame_base, sizeof(frame_base), "Prev%u", i);
clear_uniforms_frame(&uni->prev[i]);
@ -631,11 +638,11 @@ static void find_uniforms(unsigned pass, GLuint prog, struct shader_uniforms *un
static void gl_glsl_delete_shader(GLuint prog)
{
GLsizei count;
GLsizei count, i;
GLuint shaders[2] = {0};
glGetAttachedShaders(prog, 2, &count, shaders);
for (GLsizei i = 0; i < count; i++)
for (i = 0; i < count; i++)
{
glDetachShader(prog, shaders[i]);
glDeleteShader(shaders[i]);
@ -646,10 +653,11 @@ static void gl_glsl_delete_shader(GLuint prog)
static void gl_glsl_free_shader(void)
{
unsigned i;
if (!glsl_shader)
return;
for (unsigned i = 0; i < glsl_shader->passes; i++)
for (i = 0; i < glsl_shader->passes; i++)
{
free(glsl_shader->pass[i].source.xml.vertex);
free(glsl_shader->pass[i].source.xml.fragment);
@ -662,8 +670,9 @@ static void gl_glsl_free_shader(void)
static void gl_glsl_deinit(void)
{
unsigned i;
glUseProgram(0);
for (unsigned i = 0; i < GFX_MAX_SHADERS; i++)
for (i = 0; i < GFX_MAX_SHADERS; i++)
{
if (gl_program[i] == 0 || (i && gl_program[i] == gl_program[0]))
continue;
@ -687,7 +696,7 @@ static void gl_glsl_deinit(void)
gl_glsl_reset_attrib();
for (unsigned i = 0; i < GFX_MAX_SHADERS; i++)
for (i = 0; i < GFX_MAX_SHADERS; i++)
{
if (glsl_vbo[i].vbo_primary)
glDeleteBuffers(1, &glsl_vbo[i].vbo_primary);
@ -699,6 +708,7 @@ static void gl_glsl_deinit(void)
static bool gl_glsl_init(const char *path)
{
unsigned i;
#ifndef HAVE_OPENGLES2
RARCH_LOG("Checking GLSL shader support ...\n");
bool shader_support = glCreateProgram && glUseProgram && glCreateShader
@ -804,7 +814,7 @@ static bool gl_glsl_init(const char *path)
goto error;
}
for (unsigned i = 0; i <= glsl_shader->passes; i++)
for (i = 0; i <= glsl_shader->passes; i++)
find_uniforms(i, gl_program[i], &gl_uniforms[i]);
#ifdef GLSL_DEBUG
@ -848,7 +858,7 @@ static bool gl_glsl_init(const char *path)
gl_glsl_reset_attrib();
for (unsigned i = 0; i < GFX_MAX_SHADERS; i++)
for (i = 0; i < GFX_MAX_SHADERS; i++)
{
glGenBuffers(1, &glsl_vbo[i].vbo_primary);
glGenBuffers(1, &glsl_vbo[i].vbo_secondary);
@ -880,6 +890,7 @@ static void gl_glsl_set_params(unsigned width, unsigned height,
return;
GLfloat buffer[128];
unsigned i;
size_t size = 0;
struct glsl_attrib attribs[32];
size_t attribs_size = 0;
@ -911,7 +922,7 @@ static void gl_glsl_set_params(unsigned width, unsigned height,
if (uni->frame_direction >= 0)
glUniform1i(uni->frame_direction, g_extern.frame_is_reverse ? -1 : 1);
for (unsigned i = 0; i < glsl_shader->luts; i++)
for (i = 0; i < glsl_shader->luts; i++)
{
if (uni->lut_texture[i] >= 0)
{
@ -964,7 +975,7 @@ static void gl_glsl_set_params(unsigned width, unsigned height,
}
// Bind FBO textures.
for (unsigned i = 0; i < fbo_info_cnt; i++)
for (i = 0; i < fbo_info_cnt; i++)
{
if (uni->pass[i].texture)
glUniform1i(uni->pass[i].texture, texunit);
@ -1001,7 +1012,7 @@ static void gl_glsl_set_params(unsigned width, unsigned height,
// Unbind any lurking FBO passes.
// Rendering to a texture that is bound to a texture unit
// sounds very shaky ... ;)
for (unsigned i = 0; i < glsl_shader->passes; i++)
for (i = 0; i < glsl_shader->passes; i++)
{
glActiveTexture(GL_TEXTURE0 + base_tex + i);
glBindTexture(GL_TEXTURE_2D, 0);
@ -1009,7 +1020,7 @@ static void gl_glsl_set_params(unsigned width, unsigned height,
}
// Set previous textures. Only bind if they're actually used.
for (unsigned i = 0; i < PREV_TEXTURES; i++)
for (i = 0; i < PREV_TEXTURES; i++)
{
if (uni->prev[i].texture >= 0)
{
@ -1058,7 +1069,7 @@ static void gl_glsl_set_params(unsigned width, unsigned height,
if (active_index == 1)
cnt = state_get_uniform(gl_state_tracker, info, GFX_MAX_VARIABLES, frame_count);
for (unsigned i = 0; i < cnt; i++)
for (i = 0; i < cnt; i++)
{
int location = glGetUniformLocation(gl_program[active_index], info[i].id);
glUniform1f(location, info[i].value);
@ -1198,12 +1209,13 @@ static void gl_glsl_shader_scale(unsigned index, struct gfx_fbo_scale *scale)
static unsigned gl_glsl_get_prev_textures(void)
{
int i, j;
if (!glsl_enable)
return 0;
unsigned max_prev = 0;
for (unsigned i = 1; i <= glsl_shader->passes; i++)
for (unsigned j = 0; j < PREV_TEXTURES; j++)
for (i = 1; i <= glsl_shader->passes; i++)
for (j = 0; j < PREV_TEXTURES; j++)
if (gl_uniforms[i].prev[j].texture >= 0)
max_prev = max(j + 1, max_prev);

View File

@ -224,12 +224,13 @@ static bool shader_parse_pass(config_file_t *conf, struct gfx_shader_pass *pass,
static bool shader_parse_textures(config_file_t *conf, struct gfx_shader *shader)
{
const char *id;
char *save;
char textures[1024];
if (!config_get_array(conf, "textures", textures, sizeof(textures)))
return true;
char *save;
for (const char *id = strtok_r(textures, ";", &save);
for (id = strtok_r(textures, ";", &save);
id && shader->luts < GFX_MAX_TEXTURES;
shader->luts++, id = strtok_r(NULL, ";", &save))
{
@ -263,11 +264,12 @@ static bool shader_parse_textures(config_file_t *conf, struct gfx_shader *shader
static bool shader_parse_imports(config_file_t *conf, struct gfx_shader *shader)
{
char imports[1024];
char *save;
const char *id;
if (!config_get_array(conf, "imports", imports, sizeof(imports)))
return true;
char *save;
for (const char *id = strtok_r(imports, ";", &save);
for (id = strtok_r(imports, ";", &save);
id && shader->variables < GFX_MAX_VARIABLES;
shader->variables++, id = strtok_r(NULL, ";", &save))
{
@ -359,11 +361,12 @@ static bool shader_parse_imports(config_file_t *conf, struct gfx_shader *shader)
bool gfx_shader_read_conf_cgp(config_file_t *conf, struct gfx_shader *shader)
{
unsigned shaders, i;
memset(shader, 0, sizeof(*shader));
shader->type = RARCH_SHADER_CG;
unsigned shaders = 0;
shaders = 0;
if (!config_get_uint(conf, "shaders", &shaders))
{
RARCH_ERR("Cannot find \"shaders\" param.\n");
@ -377,7 +380,7 @@ bool gfx_shader_read_conf_cgp(config_file_t *conf, struct gfx_shader *shader)
}
shader->passes = min(shaders, GFX_MAX_SHADERS);
for (unsigned i = 0; i < shader->passes; i++)
for (i = 0; i < shader->passes; i++)
{
if (!shader_parse_pass(conf, &shader->pass[i], i))
return false;
@ -1031,8 +1034,9 @@ static void shader_write_variable(config_file_t *conf, const struct state_tracke
void gfx_shader_write_conf_cgp(config_file_t *conf, const struct gfx_shader *shader)
{
unsigned i;
config_set_int(conf, "shaders", shader->passes);
for (unsigned i = 0; i < shader->passes; i++)
for (i = 0; i < shader->passes; i++)
{
const struct gfx_shader_pass *pass = &shader->pass[i];
@ -1062,7 +1066,7 @@ void gfx_shader_write_conf_cgp(config_file_t *conf, const struct gfx_shader *sha
{
char textures[4096] = {0};
strlcpy(textures, shader->lut[0].id, sizeof(textures));
for (unsigned i = 1; i < shader->luts; i++)
for (i = 1; i < shader->luts; i++)
{
// O(n^2), but number of textures is very limited.
strlcat(textures, ";", sizeof(textures));
@ -1071,7 +1075,7 @@ void gfx_shader_write_conf_cgp(config_file_t *conf, const struct gfx_shader *sha
config_set_string(conf, "textures", textures);
for (unsigned i = 0; i < shader->luts; i++)
for (i = 0; i < shader->luts; i++)
{
char key[64];
@ -1097,7 +1101,7 @@ void gfx_shader_write_conf_cgp(config_file_t *conf, const struct gfx_shader *sha
{
char variables[4096] = {0};
strlcpy(variables, shader->variable[0].id, sizeof(variables));
for (unsigned i = 1; i < shader->variables; i++)
for (i = 1; i < shader->variables; i++)
{
strlcat(variables, ";", sizeof(variables));
strlcat(variables, shader->variable[i].id, sizeof(variables));
@ -1105,7 +1109,7 @@ void gfx_shader_write_conf_cgp(config_file_t *conf, const struct gfx_shader *sha
config_set_string(conf, "imports", variables);
for (unsigned i = 0; i < shader->variables; i++)
for (i = 0; i < shader->variables; i++)
shader_write_variable(conf, &shader->variable[i]);
}
}
@ -1127,8 +1131,9 @@ enum rarch_shader_type gfx_shader_parse_type(const char *path, enum rarch_shader
void gfx_shader_resolve_relative(struct gfx_shader *shader, const char *ref_path)
{
unsigned i;
char tmp_path[PATH_MAX];
for (unsigned i = 0; i < shader->passes; i++)
for (i = 0; i < shader->passes; i++)
{
if (!*shader->pass[i].source.cg)
continue;
@ -1138,7 +1143,7 @@ void gfx_shader_resolve_relative(struct gfx_shader *shader, const char *ref_path
ref_path, tmp_path, sizeof(shader->pass[i].source.cg));
}
for (unsigned i = 0; i < shader->luts; i++)
for (i = 0; i < shader->luts; i++)
{
strlcpy(tmp_path, shader->lut[i].path, sizeof(tmp_path));
fill_pathname_resolve_relative(shader->lut[i].path,

View File

@ -62,6 +62,7 @@ struct state_tracker
state_tracker_t* state_tracker_init(const struct state_tracker_info *info)
{
unsigned i;
state_tracker_t *tracker = (state_tracker_t*)calloc(1, sizeof(*tracker));
if (!tracker)
return NULL;
@ -82,7 +83,7 @@ state_tracker_t* state_tracker_init(const struct state_tracker_info *info)
tracker->info = (struct state_tracker_internal*)calloc(info->info_elem, sizeof(struct state_tracker_internal));
tracker->info_elem = info->info_elem;
for (unsigned i = 0; i < info->info_elem; i++)
for (i = 0; i < info->info_elem; i++)
{
strlcpy(tracker->info[i].id, info->info[i].id, sizeof(tracker->info[i].id));
tracker->info[i].addr = info->info[i].addr;
@ -218,6 +219,7 @@ static void update_element(
// Updates 16-bit input in same format as SNES itself.
static void update_input(state_tracker_t *tracker)
{
unsigned i;
if (driver.input == NULL)
return;
@ -243,23 +245,24 @@ static void update_input(state_tracker_t *tracker)
};
uint16_t state[2] = {0};
for (unsigned i = 4; i < 16; i++)
for (i = 4; i < 16; i++)
{
state[0] |= (input_input_state_func(binds, 0, RETRO_DEVICE_JOYPAD, 0, buttons[i - 4]) ? 1 : 0) << i;
state[1] |= (input_input_state_func(binds, 1, RETRO_DEVICE_JOYPAD, 0, buttons[i - 4]) ? 1 : 0) << i;
}
for (unsigned i = 0; i < 2; i++)
for (i = 0; i < 2; i++)
tracker->input_state[i] = state[i];
}
unsigned state_get_uniform(state_tracker_t *tracker, struct state_tracker_uniform *uniforms, unsigned elem, unsigned frame_count)
{
unsigned elems = tracker->info_elem < elem ? tracker->info_elem : elem;
unsigned i, elems;
elems = tracker->info_elem < elem ? tracker->info_elem : elem;
update_input(tracker);
for (unsigned i = 0; i < elems; i++)
for (i = 0; i < elems; i++)
update_element(&uniforms[i], &tracker->info[i], frame_count);
return elems;

View File

@ -430,7 +430,8 @@ static bool thread_frame(void *data, const void *frame_,
{
if (src)
{
for (unsigned h = 0; h < height; h++, src += pitch, dst += copy_stride)
unsigned h;
for (h = 0; h < height; h++, src += pitch, dst += copy_stride)
memcpy(dst, src, copy_stride);
}

View File

@ -63,10 +63,11 @@ static const rarch_joypad_driver_t *joypad_drivers[] = {
const rarch_joypad_driver_t *input_joypad_init_driver(const char *ident)
{
unsigned i;
if (!ident || !*ident)
return input_joypad_init_first();
for (unsigned i = 0; joypad_drivers[i]; i++)
for (i = 0; joypad_drivers[i]; i++)
{
if (strcmp(ident, joypad_drivers[i]->ident) == 0 && joypad_drivers[i]->init())
{
@ -80,7 +81,8 @@ const rarch_joypad_driver_t *input_joypad_init_driver(const char *ident)
const rarch_joypad_driver_t *input_joypad_init_first(void)
{
for (unsigned i = 0; joypad_drivers[i]; i++)
unsigned i;
for (i = 0; joypad_drivers[i]; i++)
{
if (joypad_drivers[i]->init())
{
@ -633,7 +635,8 @@ void input_init_keyboard_lut(const struct rarch_key_map *map)
enum retro_key input_translate_keysym_to_rk(unsigned sym)
{
for (unsigned i = 0; i < ARRAY_SIZE(rarch_keysym_lut); i++)
unsigned i;
for (i = 0; i < ARRAY_SIZE(rarch_keysym_lut); i++)
{
if (rarch_keysym_lut[i] == sym)
return (enum retro_key)i;
@ -654,7 +657,8 @@ void input_translate_rk_to_str(enum retro_key key, char *buf, size_t size)
}
else
{
for (unsigned i = 0; input_config_key_map[i].str; i++)
unsigned i;
for (i = 0; input_config_key_map[i].str; i++)
{
if (input_config_key_map[i].key == key)
{
@ -868,7 +872,8 @@ void input_get_bind_string(char *buf, const struct retro_keybind *bind, size_t s
static enum retro_key find_sk_bind(const char *str)
{
for (size_t i = 0; input_config_key_map[i].str; i++)
size_t i;
for (i = 0; input_config_key_map[i].str; i++)
{
if (strcasecmp(input_config_key_map[i].str, str) == 0)
return input_config_key_map[i].key;
@ -982,7 +987,8 @@ void input_config_parse_joy_axis(config_file_t *conf, const char *prefix,
#if !defined(IS_JOYCONFIG) && !defined(IS_RETROLAUNCH)
static void input_autoconfigure_joypad_conf(config_file_t *conf, struct retro_keybind *binds)
{
for (unsigned i = 0; i < RARCH_BIND_LIST_END; i++)
unsigned i;
for (i = 0; i < RARCH_BIND_LIST_END; i++)
{
input_config_parse_joy_button(conf, "input", input_config_bind_map[i].base, &binds[i]);
input_config_parse_joy_axis(conf, "input", input_config_bind_map[i].base, &binds[i]);
@ -1023,6 +1029,8 @@ static bool input_try_autoconfigure_joypad_from_conf(config_file_t *conf, unsign
void input_config_autoconfigure_joypad(unsigned index, const char *name, const char *driver)
{
size_t i;
if (!g_settings.input.autodetect_enable)
return;
@ -1030,7 +1038,7 @@ void input_config_autoconfigure_joypad(unsigned index, const char *name, const c
// every time (fine in log).
bool block_osd_spam = g_settings.input.autoconfigured[index] && name;
for (unsigned i = 0; i < RARCH_BIND_LIST_END; i++)
for (i = 0; i < RARCH_BIND_LIST_END; i++)
{
g_settings.input.autoconf_binds[index][i].joykey = NO_BTN;
g_settings.input.autoconf_binds[index][i].joyaxis = AXIS_NONE;
@ -1045,7 +1053,7 @@ void input_config_autoconfigure_joypad(unsigned index, const char *name, const c
#ifdef HAVE_BUILTIN_AUTOCONFIG
// First internal
for (size_t i = 0; input_builtin_autoconfs[i]; i++)
for (i = 0; input_builtin_autoconfs[i]; i++)
{
config_file_t *conf = config_file_new_from_string(input_builtin_autoconfs[i]);
bool success = input_try_autoconfigure_joypad_from_conf(conf, index, name, driver, block_osd_spam);
@ -1062,7 +1070,7 @@ void input_config_autoconfigure_joypad(unsigned index, const char *name, const c
if (!list)
return;
for (size_t i = 0; i < list->size; i++)
for (i = 0; i < list->size; i++)
{
config_file_t *conf = config_file_new(list->elems[i].data);
if (!conf)

View File

@ -167,7 +167,8 @@ static const struct str_to_bind_map str_to_bind[] = {
static unsigned input_str_to_bind(const char *str)
{
for (unsigned i = 0; i < ARRAY_SIZE(str_to_bind); i++)
unsigned i;
for (i = 0; i < ARRAY_SIZE(str_to_bind); i++)
{
if (!strcmp(str_to_bind[i].str, str))
return str_to_bind[i].bind;
@ -178,6 +179,7 @@ static unsigned input_str_to_bind(const char *str)
static void input_overlay_scale(struct overlay *overlay, float scale)
{
size_t i;
if (overlay->block_scale)
scale = 1.0f;
@ -187,7 +189,7 @@ static void input_overlay_scale(struct overlay *overlay, float scale)
overlay->mod_x = overlay->center_x + (overlay->x - overlay->center_x) * scale;
overlay->mod_y = overlay->center_y + (overlay->y - overlay->center_y) * scale;
for (size_t i = 0; i < overlay->size; i++)
for (i = 0; i < overlay->size; i++)
{
struct overlay_desc *desc = &overlay->descs[i];
@ -206,11 +208,12 @@ static void input_overlay_scale(struct overlay *overlay, float scale)
static void input_overlay_set_vertex_geom(input_overlay_t *ol)
{
size_t i;
if (ol->active->image.image)
ol->iface->vertex_geom(ol->iface_data, 0,
ol->active->mod_x, ol->active->mod_y, ol->active->mod_w, ol->active->mod_h);
for (size_t i = 0; i < ol->active->size; i++)
for (i = 0; i < ol->active->size; i++)
{
struct overlay_desc *desc = &ol->active->descs[i];
if (desc->image.image)
@ -221,7 +224,8 @@ static void input_overlay_set_vertex_geom(input_overlay_t *ol)
void input_overlay_set_scale_factor(input_overlay_t *ol, float scale)
{
for (size_t i = 0; i < ol->size; i++)
size_t i;
for (i = 0; i < ol->size; i++)
input_overlay_scale(&ol->overlays[i], scale);
input_overlay_set_vertex_geom(ol);
@ -229,7 +233,8 @@ void input_overlay_set_scale_factor(input_overlay_t *ol, float scale)
static void input_overlay_free_overlay(struct overlay *overlay)
{
for (size_t i = 0; i < overlay->size; i++)
size_t i;
for (i = 0; i < overlay->size; i++)
free((void*)overlay->descs[i].image.image);
free(overlay->load_images);
free(overlay->descs);
@ -238,7 +243,8 @@ static void input_overlay_free_overlay(struct overlay *overlay)
static void input_overlay_free_overlays(input_overlay_t *ol)
{
for (size_t i = 0; i < ol->size; i++)
size_t i;
for (i = 0; i < ol->size; i++)
input_overlay_free_overlay(&ol->overlays[i]);
free(ol->overlays);
}
@ -318,8 +324,9 @@ static bool input_overlay_load_desc(input_overlay_t *ol, config_file_t *conf, st
desc->type = OVERLAY_TYPE_ANALOG_RIGHT;
else
{
const char *tmp;
desc->type = OVERLAY_TYPE_BUTTONS;
for (const char *tmp = strtok_r(key, "|", &save); tmp; tmp = strtok_r(NULL, "|", &save))
for (tmp = strtok_r(key, "|", &save); tmp; tmp = strtok_r(NULL, "|", &save))
{
if (strcmp(tmp, "nul") != 0)
desc->key_mask |= UINT64_C(1) << input_str_to_bind(tmp);
@ -394,6 +401,7 @@ end:
static bool input_overlay_load_overlay(input_overlay_t *ol, config_file_t *conf, const char *config_path,
struct overlay *overlay, unsigned index)
{
size_t i;
char overlay_path_key[64];
char overlay_name_key[64];
char overlay_path[PATH_MAX];
@ -484,7 +492,7 @@ static bool input_overlay_load_overlay(input_overlay_t *ol, config_file_t *conf,
snprintf(conf_key, sizeof(conf_key), "overlay%u_range_mod", index);
config_get_float(conf, conf_key, &range_mod);
for (size_t i = 0; i < overlay->size; i++)
for (i = 0; i < overlay->size; i++)
{
if (!input_overlay_load_desc(ol, conf, &overlay->descs[i], index, i,
overlay->image.width, overlay->image.height,
@ -506,7 +514,7 @@ static bool input_overlay_load_overlay(input_overlay_t *ol, config_file_t *conf,
if (overlay->image.image)
overlay->load_images[overlay->load_images_size++] = overlay->image;
for (size_t i = 0; i < overlay->size; i++)
for (i = 0; i < overlay->size; i++)
{
if (overlay->descs[i].image.image)
{
@ -526,7 +534,8 @@ static bool input_overlay_load_overlay(input_overlay_t *ol, config_file_t *conf,
static ssize_t input_overlay_find_index(const struct overlay *ol, const char *name, size_t size)
{
for (size_t i = 0; i < size; i++)
size_t i;
for (i = 0; i < size; i++)
{
if (strcmp(ol[i].name, name) == 0)
return i;
@ -537,9 +546,10 @@ static ssize_t input_overlay_find_index(const struct overlay *ol, const char *na
static bool input_overlay_resolve_targets(struct overlay *ol, size_t index, size_t size)
{
size_t i;
struct overlay *current = &ol[index];
for (size_t i = 0; i < current->size; i++)
for (i = 0; i < current->size; i++)
{
const char *next = current->descs[i].next_index_name;
if (*next)
@ -562,6 +572,7 @@ static bool input_overlay_resolve_targets(struct overlay *ol, size_t index, size
static bool input_overlay_load_overlays(input_overlay_t *ol, const char *path)
{
size_t i;
bool ret = true;
config_file_t *conf = config_file_new(path);
if (!conf)
@ -593,7 +604,7 @@ static bool input_overlay_load_overlays(input_overlay_t *ol, const char *path)
ol->size = overlays;
for (size_t i = 0; i < ol->size; i++)
for (i = 0; i < ol->size; i++)
{
if (!input_overlay_load_overlay(ol, conf, path, &ol->overlays[i], i))
{
@ -603,7 +614,7 @@ static bool input_overlay_load_overlays(input_overlay_t *ol, const char *path)
}
}
for (size_t i = 0; i < ol->size; i++)
for (i = 0; i < ol->size; i++)
{
if (!input_overlay_resolve_targets(ol->overlays, i, ol->size))
{
@ -713,6 +724,7 @@ static inline float clamp(float val, float lower, float upper)
void input_overlay_poll(input_overlay_t *ol, input_overlay_state_t *out, int16_t norm_x, int16_t norm_y)
{
size_t i;
memset(out, 0, sizeof(*out));
if (!ol->enable)
@ -732,7 +744,7 @@ void input_overlay_poll(input_overlay_t *ol, input_overlay_state_t *out, int16_t
input_overlay_set_alpha_mod(ol, g_settings.input.overlay_opacity);
for (size_t i = 0; i < ol->active->size; i++)
for (i = 0; i < ol->active->size; i++)
{
struct overlay_desc *desc = &ol->active->descs[i];
if (!inside_hitbox(desc, x, y))
@ -777,10 +789,11 @@ void input_overlay_poll(input_overlay_t *ol, input_overlay_state_t *out, int16_t
void input_overlay_poll_clear(input_overlay_t *ol)
{
size_t i;
ol->blocked = false;
input_overlay_set_alpha_mod(ol, g_settings.input.overlay_opacity);
for (size_t i = 0; i < ol->active->size; i++)
for (i = 0; i < ol->active->size; i++)
{
struct overlay_desc *desc = &ol->active->descs[i];
desc->range_x_mod = desc->range_x;
@ -820,7 +833,8 @@ void input_overlay_free(input_overlay_t *ol)
void input_overlay_set_alpha_mod(input_overlay_t *ol, float mod)
{
for (unsigned i = 0; i < ol->active->load_images_size; i++)
unsigned i;
for (i = 0; i < ol->active->load_images_size; i++)
ol->iface->set_alpha(ol->iface_data, i, g_settings.input.overlay_opacity);
}

View File

@ -90,7 +90,8 @@ void msg_queue_push(msg_queue_t *queue, const char *msg, unsigned prio, unsigned
void msg_queue_clear(msg_queue_t *queue)
{
for (size_t i = 1; i < queue->ptr; i++)
size_t i;
for (i = 1; i < queue->ptr; i++)
{
if (queue->elems[i])
{

View File

@ -455,8 +455,10 @@ static void audio_sample_rewind(int16_t left, int16_t right)
size_t audio_sample_batch_rewind(const int16_t *data, size_t frames)
{
size_t samples = frames << 1;
for (size_t i = 0; i < samples; i++)
size_t i, samples;
samples = frames << 1;
for (i = 0; i < samples; i++)
g_extern.audio_data.rewind_buf[--g_extern.audio_data.rewind_ptr] = data[i];
return frames;
@ -494,7 +496,8 @@ static inline void input_poll_overlay(void)
RARCH_DEVICE_POINTER_SCREEN : RETRO_DEVICE_POINTER;
bool polled = false;
for (unsigned i = 0;
unsigned i, j;
for (i = 0;
input_input_state_func(NULL, 0, device, i, RETRO_DEVICE_ID_POINTER_PRESSED);
i++)
{
@ -508,7 +511,7 @@ static inline void input_poll_overlay(void)
driver.overlay_state.buttons |= polled_data.buttons;
for (unsigned j = 0; j < 4; j ++)
for (j = 0; j < 4; j ++)
if (driver.overlay_state.analog[j] == 0)
driver.overlay_state.analog[j] = polled_data.analog[j];
@ -1183,7 +1186,8 @@ static void parse_input(int argc, char *argv[])
static void init_controllers(void)
{
for (unsigned i = 0; i < MAX_PLAYERS; i++)
unsigned i;
for (i = 0; i < MAX_PLAYERS; i++)
{
unsigned device = g_settings.input.libretro_device[i];
@ -1708,7 +1712,8 @@ void rarch_init_autosave(void)
if (g_settings.autosave_interval > 0)
{
for (unsigned i = 0; i < sizeof(g_extern.autosave) / sizeof(g_extern.autosave[0]); i++)
unsigned i;
for (i = 0; i < sizeof(g_extern.autosave) / sizeof(g_extern.autosave[0]); i++)
{
if (ram_paths[i] && *ram_paths[i] && pretro_get_memory_size(ram_types[i]) > 0)
{
@ -1725,7 +1730,8 @@ void rarch_init_autosave(void)
void rarch_deinit_autosave(void)
{
for (unsigned i = 0; i < ARRAY_SIZE(g_extern.autosave); i++)
unsigned i;
for (i = 0; i < ARRAY_SIZE(g_extern.autosave); i++)
{
if (g_extern.autosave[i])
autosave_free(g_extern.autosave[i]);
@ -1754,7 +1760,8 @@ static void set_savestate_auto_index(void)
if (!dir_list)
return;
for (size_t i = 0; i < dir_list->size; i++)
size_t i;
for (i = 0; i < dir_list->size; i++)
{
const char *dir_elem = dir_list->elems[i].data;
@ -2082,9 +2089,10 @@ static inline void flush_rewind_audio(void)
static inline void setup_rewind_audio(void)
{
unsigned i;
// Push audio ready to be played.
g_extern.audio_data.rewind_ptr = g_extern.audio_data.rewind_size;
for (unsigned i = 0; i < g_extern.audio_data.data_ptr; i += 2)
for (i = 0; i < g_extern.audio_data.data_ptr; i += 2)
{
g_extern.audio_data.rewind_buf[--g_extern.audio_data.rewind_ptr] =
g_extern.audio_data.conv_outsamples[i + 1];
@ -2332,6 +2340,8 @@ static void check_reset(void)
static void check_turbo(void)
{
unsigned i;
g_extern.turbo_count++;
static const struct retro_keybind *binds[MAX_PLAYERS] = {
@ -2345,7 +2355,7 @@ static void check_turbo(void)
g_settings.input.binds[7],
};
for (unsigned i = 0; i < MAX_PLAYERS; i++)
for (i = 0; i < MAX_PLAYERS; i++)
g_extern.turbo_frame_enable[i] =
input_input_state_func(binds, i, RETRO_DEVICE_JOYPAD, 0, RARCH_TURBO_ENABLE);
}
@ -2810,8 +2820,10 @@ static void init_state(void)
static void init_state_first(void)
{
unsigned i;
init_state();
for (unsigned i = 0; i < MAX_PLAYERS; i++)
for (i = 0; i < MAX_PLAYERS; i++)
g_settings.input.libretro_device[i] = RETRO_DEVICE_JOYPAD;
}
@ -3203,6 +3215,7 @@ void rarch_main_deinit(void)
int rarch_main_init_wrap(const struct rarch_main_wrap *args)
{
unsigned i;
if (g_extern.main_is_init)
rarch_main_deinit();
@ -3256,7 +3269,7 @@ int rarch_main_init_wrap(const struct rarch_main_wrap *args)
argv[argc++] = strdup("-v");
#ifdef HAVE_FILE_LOGGER
for (int i = 0; i < argc; i++)
for (i = 0; i < argc; i++)
RARCH_LOG("arg #%d: %s\n", i, argv[i]);
#endif
@ -3265,7 +3278,7 @@ int rarch_main_init_wrap(const struct rarch_main_wrap *args)
int ret = rarch_main_init(argc, argv);
for (unsigned i = 0; i < ARRAY_SIZE(argv_copy); i++)
for (i = 0; i < ARRAY_SIZE(argv_copy); i++)
free(argv_copy[i]);
return ret;

View File

@ -149,6 +149,7 @@ static void reassign_bottom(state_manager_t *state)
static void generate_delta(state_manager_t *state, const void *data)
{
uint64_t i;
bool crossed = false;
const uint32_t *old_state = state->tmp_state;
const uint32_t *new_state = (const uint32_t*)data;
@ -160,7 +161,7 @@ static void generate_delta(state_manager_t *state, const void *data)
if (state->top_ptr == state->bottom_ptr)
crossed = true;
for (uint64_t i = 0; i < state->state_size; i++)
for (i = 0; i < state->state_size; i++)
{
uint64_t xor_ = old_state[i] ^ new_state[i];

View File

@ -61,7 +61,8 @@ static bool write_header_bmp(FILE *file, unsigned width, unsigned height)
static void dump_lines_file(FILE *file, uint8_t **lines, size_t line_size, unsigned height)
{
for (unsigned i = 0; i < height; i++)
unsigned i;
for (i = 0; i < height; i++)
fwrite(lines[i], 1, line_size, file);
}
@ -72,7 +73,8 @@ static void dump_line_bgr(uint8_t *line, const uint8_t *src, unsigned width)
static void dump_line_16(uint8_t *line, const uint16_t *src, unsigned width)
{
for (unsigned i = 0; i < width; i++)
unsigned i;
for (i = 0; i < width; i++)
{
uint16_t pixel = *src++;
uint8_t b = (pixel >> 0) & 0x1f;
@ -86,7 +88,8 @@ static void dump_line_16(uint8_t *line, const uint16_t *src, unsigned width)
static void dump_line_32(uint8_t *line, const uint32_t *src, unsigned width)
{
for (unsigned i = 0; i < width; i++)
unsigned i;
for (i = 0; i < width; i++)
{
uint32_t pixel = *src++;
*line++ = (pixel >> 0) & 0xff;
@ -98,6 +101,7 @@ static void dump_line_32(uint8_t *line, const uint32_t *src, unsigned width)
static void dump_content(FILE *file, const void *frame,
int width, int height, int pitch, bool bgr24)
{
int i, j;
union
{
const uint8_t *u8;
@ -112,7 +116,7 @@ static void dump_content(FILE *file, const void *frame,
size_t line_size = (width * 3 + 3) & ~3;
for (int i = 0; i < height; i++)
for (i = 0; i < height; i++)
{
lines[i] = (uint8_t*)calloc(1, line_size);
if (!lines[i])
@ -121,24 +125,24 @@ static void dump_content(FILE *file, const void *frame,
if (bgr24) // BGR24 byte order. Can directly copy.
{
for (int j = 0; j < height; j++, u.u8 += pitch)
for (j = 0; j < height; j++, u.u8 += pitch)
dump_line_bgr(lines[j], u.u8, width);
}
else if (g_extern.system.pix_fmt == RETRO_PIXEL_FORMAT_XRGB8888)
{
for (int j = 0; j < height; j++, u.u8 += pitch)
for (j = 0; j < height; j++, u.u8 += pitch)
dump_line_32(lines[j], u.u32, width);
}
else // RGB565
{
for (int j = 0; j < height; j++, u.u8 += pitch)
for (j = 0; j < height; j++, u.u8 += pitch)
dump_line_16(lines[j], u.u16, width);
}
dump_lines_file(file, lines, line_size, height);
end:
for (int i = 0; i < height; i++)
for (i = 0; i < height; i++)
free(lines[i]);
free(lines);
}

View File

@ -150,6 +150,7 @@ const char *config_get_default_input(void)
void config_set_defaults(void)
{
unsigned i, j;
const char *def_video = config_get_default_video();
const char *def_audio = config_get_default_audio();
const char *def_input = config_get_default_input();
@ -235,12 +236,12 @@ void config_set_defaults(void)
rarch_assert(sizeof(g_settings.input.binds[0]) >= sizeof(retro_keybinds_1));
rarch_assert(sizeof(g_settings.input.binds[1]) >= sizeof(retro_keybinds_rest));
memcpy(g_settings.input.binds[0], retro_keybinds_1, sizeof(retro_keybinds_1));
for (unsigned i = 1; i < MAX_PLAYERS; i++)
for (i = 1; i < MAX_PLAYERS; i++)
memcpy(g_settings.input.binds[i], retro_keybinds_rest, sizeof(retro_keybinds_rest));
for (unsigned i = 0; i < MAX_PLAYERS; i++)
for (i = 0; i < MAX_PLAYERS; i++)
{
for (unsigned j = 0; j < RARCH_BIND_LIST_END; j++)
for (j = 0; j < RARCH_BIND_LIST_END; j++)
{
g_settings.input.autoconf_binds[i][j].joykey = NO_BTN;
g_settings.input.autoconf_binds[i][j].joyaxis = AXIS_NONE;
@ -249,8 +250,8 @@ void config_set_defaults(void)
memset(g_settings.input.autoconfigured, 0, sizeof(g_settings.input.autoconfigured));
// Verify that binds are in proper order.
for (int i = 0; i < MAX_PLAYERS; i++)
for (int j = 0; j < RARCH_BIND_LIST_END; j++)
for (i = 0; i < MAX_PLAYERS; i++)
for (j = 0; j < RARCH_BIND_LIST_END; j++)
if (g_settings.input.binds[i][j].valid)
rarch_assert(j == g_settings.input.binds[i][j].id);
@ -266,7 +267,7 @@ void config_set_defaults(void)
g_settings.input.back_behavior = BACK_BUTTON_QUIT;
#endif
for (int i = 0; i < MAX_PLAYERS; i++)
for (i = 0; i < MAX_PLAYERS; i++)
{
g_settings.input.joypad_map[i] = i;
if (!g_extern.has_set_libretro_device[i])
@ -527,6 +528,7 @@ static void parse_config_file(void)
bool config_load_file(const char *path)
{
unsigned i;
config_file_t *conf = NULL;
if (path)
@ -695,7 +697,7 @@ bool config_load_file(const char *path)
CONFIG_GET_FLOAT(input.axis_threshold, "input_axis_threshold");
CONFIG_GET_BOOL(input.netplay_client_swap_input, "netplay_client_swap_input");
for (unsigned i = 0; i < MAX_PLAYERS; i++)
for (i = 0; i < MAX_PLAYERS; i++)
{
char buf[64];
snprintf(buf, sizeof(buf), "input_player%u_joypad_index", i + 1);
@ -893,7 +895,8 @@ static void read_keybinds_axis(config_file_t *conf, unsigned player, unsigned in
static void read_keybinds_player(config_file_t *conf, unsigned player)
{
for (unsigned i = 0; input_config_bind_map[i].valid; i++)
unsigned i;
for (i = 0; input_config_bind_map[i].valid; i++)
{
struct retro_keybind *bind = &g_settings.input.binds[player][i];
if (!bind->valid)
@ -907,7 +910,8 @@ static void read_keybinds_player(config_file_t *conf, unsigned player)
static void config_read_keybinds_conf(config_file_t *conf)
{
for (unsigned i = 0; i < MAX_PLAYERS; i++)
unsigned i;
for (i = 0; i < MAX_PLAYERS; i++)
read_keybinds_player(conf, i);
}
@ -1025,7 +1029,8 @@ static void save_keybind(config_file_t *conf, const char *prefix, const char *ba
static void save_keybinds_player(config_file_t *conf, unsigned player)
{
for (unsigned i = 0; input_config_bind_map[i].valid; i++)
unsigned i = 0;
for (i = 0; input_config_bind_map[i].valid; i++)
{
const char *prefix = input_config_get_prefix(player, input_config_bind_map[i].meta);
if (prefix)
@ -1035,6 +1040,7 @@ static void save_keybinds_player(config_file_t *conf, unsigned player)
bool config_save_file(const char *path)
{
unsigned i = 0;
config_file_t *conf = config_file_new(path);
if (!conf)
conf = config_file_new(NULL);
@ -1142,7 +1148,7 @@ bool config_save_file(const char *path)
config_set_string(conf, "input_driver", g_settings.input.driver);
config_set_string(conf, "input_joypad_driver", g_settings.input.joypad_driver);
for (unsigned i = 0; i < MAX_PLAYERS; i++)
for (i = 0; i < MAX_PLAYERS; i++)
{
char cfg[64];
snprintf(cfg, sizeof(cfg), "input_device_p%u", i + 1);
@ -1153,7 +1159,7 @@ bool config_save_file(const char *path)
config_set_int(conf, cfg, g_settings.input.libretro_device[i]);
}
for (unsigned i = 0; i < MAX_PLAYERS; i++)
for (i = 0; i < MAX_PLAYERS; i++)
save_keybinds_player(conf, i);
bool ret = config_file_write(conf, path);