From 7aa8b4075916524bb6e8112b1fb9278be4947bec Mon Sep 17 00:00:00 2001 From: Themaister Date: Tue, 22 Oct 2013 21:26:33 +0200 Subject: [PATCH] Fixup C89 for loops. --- audio/jack.c | 34 ++++++++++++++++++------------ command.c | 15 ++++++++------ frontend/frontend.c | 5 +++-- gfx/context/drm_egl_ctx.c | 5 +++-- gfx/context/vc_egl_ctx.c | 5 +++-- gfx/context/x11_common.c | 11 ++++++---- gfx/fonts/freetype.c | 6 ++++-- gfx/gl.c | 6 ++++-- gfx/sdl_gfx.c | 5 +++-- gfx/shader_cg.c | 37 ++++++++++++++++++++------------- gfx/xvideo.c | 40 ++++++++++++++++++++++-------------- input/dinput.c | 19 +++++++++-------- input/linuxraw_input.c | 3 ++- input/linuxraw_joypad.c | 16 ++++++++------- input/sdl_joypad.c | 6 ++++-- input/udev_joypad.c | 41 ++++++++++++++++++++++--------------- input/winxinput_joypad.c | 14 ++++++++----- netplay.c | 32 ++++++++++++++++++----------- record/ffemu.c | 15 +++++++++----- tools/retroarch-joyconfig.c | 21 +++++++++++-------- 20 files changed, 206 insertions(+), 130 deletions(-) diff --git a/audio/jack.c b/audio/jack.c index bdf0409779..56311a605d 100644 --- a/audio/jack.c +++ b/audio/jack.c @@ -44,6 +44,8 @@ typedef struct jack static int process_cb(jack_nframes_t nframes, void *data) { + int i; + jack_nframes_t f; jack_t *jd = (jack_t*)data; if (nframes <= 0) { @@ -59,13 +61,13 @@ static int process_cb(jack_nframes_t nframes, void *data) if (min_avail > nframes) min_avail = nframes; - for (int i = 0; i < 2; i++) + for (i = 0; i < 2; i++) { jack_default_audio_sample_t *out = (jack_default_audio_sample_t*)jack_port_get_buffer(jd->ports[i], nframes); assert(out); jack_ringbuffer_read(jd->buffer[i], (char*)out, min_avail * sizeof(jack_default_audio_sample_t)); - for (jack_nframes_t f = min_avail; f < nframes; f++) + for (f = min_avail; f < nframes; f++) { out[f] = 0.0f; } @@ -83,17 +85,18 @@ static void shutdown_cb(void *data) static int parse_ports(char **dest_ports, const char **jports) { - int parsed = 0; - + int i; char *save; const char *con = strtok_r(g_settings.audio.device, ",", &save); + int parsed = 0; + if (con) dest_ports[parsed++] = strdup(con); con = strtok_r(NULL, ",", &save); if (con) dest_ports[parsed++] = strdup(con); - for (int i = parsed; i < 2; i++) + for (i = parsed; i < 2; i++) dest_ports[i] = strdup(jports[i]); return 2; @@ -101,11 +104,12 @@ static int parse_ports(char **dest_ports, const char **jports) static size_t find_buffersize(jack_t *jd, int latency) { + int i; int frames = latency * g_settings.audio.out_rate / 1000; jack_latency_range_t range; int jack_latency = 0; - for (int i = 0; i < 2; i++) + for (i = 0; i < 2; i++) { jack_port_get_latency_range(jd->ports[i], JackPlaybackLatency, &range); if ((int)range.max > jack_latency) @@ -126,6 +130,7 @@ static size_t find_buffersize(jack_t *jd, int latency) static void *ja_init(const char *device, unsigned rate, unsigned latency) { + int i; jack_t *jd = (jack_t*)calloc(1, sizeof(jack_t)); if (!jd) return NULL; @@ -166,7 +171,7 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency) jd->buffer_size = bufsize; RARCH_LOG("JACK: Internal buffer size: %d frames.\n", (int)(bufsize / sizeof(jack_default_audio_sample_t))); - for (int i = 0; i < 2; i++) + for (i = 0; i < 2; i++) { jd->buffer[i] = jack_ringbuffer_create(bufsize); if (jd->buffer[i] == NULL) @@ -184,7 +189,7 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency) goto error; } - for (int i = 0; i < 2; i++) + for (i = 0; i < 2; i++) { if (jack_connect(jd->client, jack_port_name(jd->ports[i]), dest_ports[i])) { @@ -193,7 +198,7 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency) } } - for (int i = 0; i < parsed; i++) + for (i = 0; i < parsed; i++) free(dest_ports[i]); jack_free(jports); @@ -207,10 +212,12 @@ error: static size_t write_buffer(jack_t *jd, const float *buf, size_t size) { + int i; + size_t j; jack_default_audio_sample_t out_deinterleaved_buffer[2][AUDIO_CHUNK_SIZE_NONBLOCKING]; - for (int i = 0; i < 2; i++) - for (size_t j = 0; j < FRAMES(size); j++) + for (i = 0; i < 2; i++) + for (j = 0; j < FRAMES(size); j++) out_deinterleaved_buffer[i][j] = buf[j * 2 + i]; size_t frames = FRAMES(size); @@ -233,7 +240,7 @@ static size_t write_buffer(jack_t *jd, const float *buf, size_t size) if (write_frames > 0) { - for (int i = 0; i < 2; i++) + for (i = 0; i < 2; i++) { jack_ringbuffer_write(jd->buffer[i], (const char*)&out_deinterleaved_buffer[i][written], write_frames * sizeof(jack_default_audio_sample_t)); @@ -281,6 +288,7 @@ static bool ja_start(void *data) static void ja_free(void *data) { + int i; jack_t *jd = (jack_t*)data; jd->shutdown = true; @@ -291,7 +299,7 @@ static void ja_free(void *data) jack_client_close(jd->client); } - for (int i = 0; i < 2; i++) + for (i = 0; i < 2; i++) if (jd->buffer[i] != NULL) jack_ringbuffer_free(jd->buffer[i]); diff --git a/command.c b/command.c index d45946147e..4c26773691 100644 --- a/command.c +++ b/command.c @@ -243,7 +243,8 @@ static const struct cmd_action_map action_map[] = { static bool command_get_arg(const char *tok, const char **arg, unsigned *index) { - for (unsigned i = 0; i < ARRAY_SIZE(map); i++) + unsigned i; + for (i = 0; i < ARRAY_SIZE(map); i++) { if (strcmp(tok, map[i].str) == 0) { @@ -257,7 +258,7 @@ static bool command_get_arg(const char *tok, const char **arg, unsigned *index) } } - for (unsigned i = 0; i < ARRAY_SIZE(action_map); i++) + for (i = 0; i < ARRAY_SIZE(action_map); i++) { const char *str = strstr(tok, action_map[i].str); if (str == tok) @@ -356,6 +357,7 @@ static void network_cmd_pre_frame(rarch_cmd_t *handle) // Oh you, Win32 ... <_< static size_t read_stdin(char *buf, size_t size) { + DWORD i; HANDLE hnd = GetStdHandle(STD_INPUT_HANDLE); if (hnd == INVALID_HANDLE_VALUE) return 0; @@ -383,7 +385,7 @@ static size_t read_stdin(char *buf, size_t size) return 0; bool has_key = false; - for (DWORD i = 0; i < has_read; i++) + for (i = 0; i < has_read; i++) { // Very crude, but should get the job done ... if (recs[i].EventType == KEY_EVENT && @@ -414,7 +416,7 @@ static size_t read_stdin(char *buf, size_t size) if (!ReadFile(hnd, buf, avail, &has_read, NULL)) return 0; - for (DWORD i = 0; i < has_read; i++) + for (i = 0; i < has_read; i++) if (buf[i] == '\r') buf[i] = '\n'; @@ -554,15 +556,16 @@ end: static bool verify_command(const char *cmd) { + unsigned i; if (command_get_arg(cmd, NULL, NULL)) return true; RARCH_ERR("Command \"%s\" is not recognized by RetroArch.\n", cmd); RARCH_ERR("\tValid commands:\n"); - for (unsigned i = 0; i < sizeof(map) / sizeof(map[0]); i++) + for (i = 0; i < sizeof(map) / sizeof(map[0]); i++) RARCH_ERR("\t\t%s\n", map[i].str); - for (unsigned i = 0; i < sizeof(action_map) / sizeof(action_map[0]); i++) + for (i = 0; i < sizeof(action_map) / sizeof(action_map[0]); i++) RARCH_ERR("\t\t%s %s\n", action_map[i].str, action_map[i].arg_desc); return false; diff --git a/frontend/frontend.c b/frontend/frontend.c index d0b7b5d5b9..3a1ee0aec6 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -104,7 +104,8 @@ static void rarch_get_environment_console(void) returntype main_entry(signature()) { - void* args = NULL; + void *args = NULL; + unsigned i; frontend_ctx = (frontend_ctx_driver_t*)frontend_ctx_init_first(); if (frontend_ctx && frontend_ctx->init) @@ -201,7 +202,7 @@ returntype main_entry(signature()) // Menu should always run with vsync on. video_set_nonblock_state_func(false); // Stop all rumbling when entering RGUI. - for (unsigned i = 0; i < MAX_PLAYERS; i++) + for (i = 0; i < MAX_PLAYERS; i++) { driver_set_rumble_state(i, RETRO_RUMBLE_STRONG, 0); driver_set_rumble_state(i, RETRO_RUMBLE_WEAK, 0); diff --git a/gfx/context/drm_egl_ctx.c b/gfx/context/drm_egl_ctx.c index fe7759644d..479633a12c 100644 --- a/gfx/context/drm_egl_ctx.c +++ b/gfx/context/drm_egl_ctx.c @@ -231,6 +231,7 @@ static void gfx_ctx_get_video_size(unsigned *width, unsigned *height) static bool gfx_ctx_init(void) { + int i; if (g_inited) return false; @@ -248,7 +249,7 @@ static bool gfx_ctx_init(void) goto error; } - for (int i = 0; i < g_resources->count_connectors; i++) + for (i = 0; i < g_resources->count_connectors; i++) { g_connector = drmModeGetConnector(g_drm_fd, g_resources->connectors[i]); @@ -267,7 +268,7 @@ static bool gfx_ctx_init(void) goto error; } - for (int i = 0; i < g_resources->count_encoders; i++) + for (i = 0; i < g_resources->count_encoders; i++) { g_encoder = drmModeGetEncoder(g_drm_fd, g_resources->encoders[i]); diff --git a/gfx/context/vc_egl_ctx.c b/gfx/context/vc_egl_ctx.c index f39b0c3482..4ab814bcb2 100644 --- a/gfx/context/vc_egl_ctx.c +++ b/gfx/context/vc_egl_ctx.c @@ -267,9 +267,10 @@ static bool gfx_ctx_bind_api(enum gfx_ctx_api api, unsigned major, unsigned mino static void gfx_ctx_destroy(void) { + unsigned i; if (g_egl_dpy) { - for (unsigned i = 0; i < MAX_EGLIMAGE_TEXTURES; i++) + for (i = 0; i < MAX_EGLIMAGE_TEXTURES; i++) { if (eglBuffer[i] && peglDestroyImageKHR) { @@ -327,7 +328,7 @@ static void gfx_ctx_destroy(void) g_config = 0; g_inited = false; - for (unsigned i = 0; i < MAX_EGLIMAGE_TEXTURES; i++) + for (i = 0; i < MAX_EGLIMAGE_TEXTURES; i++) { eglBuffer[i] = NULL; g_egl_vgimage[i] = 0; diff --git a/gfx/context/x11_common.c b/gfx/context/x11_common.c index 332bee23cd..492775ea0b 100644 --- a/gfx/context/x11_common.c +++ b/gfx/context/x11_common.c @@ -131,8 +131,9 @@ void x11_suspend_screensaver(Window wnd) static bool get_video_mode(Display *dpy, unsigned width, unsigned height, XF86VidModeModeInfo *mode, XF86VidModeModeInfo *desktop_mode) { - XF86VidModeModeInfo **modes = NULL; + int i; int num_modes = 0; + XF86VidModeModeInfo **modes = NULL; XF86VidModeGetAllModeLines(dpy, DefaultScreen(dpy), &num_modes, &modes); if (!num_modes) @@ -144,7 +145,7 @@ static bool get_video_mode(Display *dpy, unsigned width, unsigned height, XF86Vi *desktop_mode = *modes[0]; bool ret = false; - for (int i = 0; i < num_modes; i++) + for (i = 0; i < num_modes; i++) { if (modes[i]->hdisplay == width && modes[i]->vdisplay == height) { @@ -200,13 +201,14 @@ static XineramaScreenInfo *x11_query_screens(Display *dpy, int *num_screens) bool x11_get_xinerama_coord(Display *dpy, int screen, int *x, int *y, unsigned *w, unsigned *h) { + int i; bool ret = false; int num_screens = 0; XineramaScreenInfo *info = x11_query_screens(dpy, &num_screens); RARCH_LOG("[X11]: Xinerama screens: %d.\n", num_screens); - for (int i = 0; i < num_screens; i++) + for (i = 0; i < num_screens; i++) { if (info[i].screen_number == screen) { @@ -226,6 +228,7 @@ bool x11_get_xinerama_coord(Display *dpy, int screen, unsigned x11_get_xinerama_monitor(Display *dpy, int x, int y, int w, int h) { + int i; unsigned monitor = 0; int largest_area = 0; @@ -233,7 +236,7 @@ unsigned x11_get_xinerama_monitor(Display *dpy, int x, int y, XineramaScreenInfo *info = x11_query_screens(dpy, &num_screens); RARCH_LOG("[X11]: Xinerama screens: %d.\n", num_screens); - for (int i = 0; i < num_screens; i++) + for (i = 0; i < num_screens; i++) { int max_lx = max(x, info[i].x_org); int min_rx = min(x + w, info[i].x_org + info[i].width); diff --git a/gfx/fonts/freetype.c b/gfx/fonts/freetype.c index 9d5acddd49..ccfd987cb8 100644 --- a/gfx/fonts/freetype.c +++ b/gfx/fonts/freetype.c @@ -70,6 +70,7 @@ error: static void ft_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; @@ -78,7 +79,7 @@ static void ft_renderer_msg(void *data, const char *msg, struct font_output_list size_t len = strlen(msg); int off_x = 0, off_y = 0; - for (size_t i = 0; i < len; i++) + for (i = 0; i < len; i++) { FT_Error err = FT_Load_Char(handle->face, msg[i], FT_LOAD_RENDER); @@ -159,7 +160,8 @@ static const char *font_paths[] = { // Highly OS/platform dependent. static const char *ft_renderer_get_default_font(void) { - for (size_t i = 0; i < sizeof(font_paths) / sizeof(font_paths[0]); i++) + size_t i; + for (i = 0; i < ARRAY_SIZE(font_paths); i++) { if (path_file_exists(font_paths[i])) return font_paths[i]; diff --git a/gfx/gl.c b/gfx/gl.c index 36ada44704..7c1e4d173d 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -1586,7 +1586,8 @@ static void gl_free(void *data) #ifdef HAVE_GL_SYNC if (gl->have_sync) { - for (unsigned i = 0; i < gl->fence_count; i++) + unsigned i; + for (i = 0; i < gl->fence_count; i++) { glClientWaitSync(gl->fences[i], GL_SYNC_FLUSH_COMMANDS_BIT, 1000000000); glDeleteSync(gl->fences[i]); @@ -1789,6 +1790,7 @@ static inline void gl_reinit_textures(void *data, const video_info_t *video) #if !defined(HAVE_OPENGLES) && defined(HAVE_FFMPEG) static void gl_init_pbo_readback(void *data) { + unsigned i; gl_t *gl = (gl_t*)data; // Only bother with this if we're doing FFmpeg GPU recording. gl->pbo_readback_enable = g_settings.video.gpu_record && g_extern.recording; @@ -1798,7 +1800,7 @@ static void gl_init_pbo_readback(void *data) RARCH_LOG("Async PBO readback enabled.\n"); glGenBuffers(4, gl->pbo_readback); - for (unsigned i = 0; i < 4; i++) + for (i = 0; i < 4; i++) { glBindBuffer(GL_PIXEL_PACK_BUFFER, gl->pbo_readback[i]); glBufferData(GL_PIXEL_PACK_BUFFER, gl->vp.width * gl->vp.height * sizeof(uint32_t), diff --git a/gfx/sdl_gfx.c b/gfx/sdl_gfx.c index a6a2100e55..b45c6edf03 100644 --- a/gfx/sdl_gfx.c +++ b/gfx/sdl_gfx.c @@ -91,6 +91,7 @@ static void sdl_init_font(sdl_video_t *vid, const char *font_path, unsigned font static void sdl_render_msg(sdl_video_t *vid, SDL_Surface *buffer, const char *msg, unsigned width, unsigned height, const SDL_PixelFormat *fmt) { + int x, y; if (!vid->font) return; @@ -142,9 +143,9 @@ static void sdl_render_msg(sdl_video_t *vid, SDL_Surface *buffer, uint32_t *out = (uint32_t*)buffer->pixels + base_y * (buffer->pitch >> 2) + base_x; - for (int y = 0; y < glyph_height; y++, src += head->pitch, out += buffer->pitch >> 2) + for (y = 0; y < glyph_height; y++, src += head->pitch, out += buffer->pitch >> 2) { - for (int x = 0; x < glyph_width; x++) + for (x = 0; x < glyph_width; x++) { unsigned blend = src[x]; unsigned out_pix = out[x]; diff --git a/gfx/shader_cg.c b/gfx/shader_cg.c index 7f00885b20..1d26d57ec4 100644 --- a/gfx/shader_cg.c +++ b/gfx/shader_cg.c @@ -149,7 +149,8 @@ static unsigned cg_attrib_index; static void gl_cg_reset_attrib(void) { - for (unsigned i = 0; i < cg_attrib_index; i++) + unsigned i; + for (i = 0; i < cg_attrib_index; i++) cgGLDisableClientState(cg_attribs[i]); cg_attrib_index = 0; } @@ -201,6 +202,7 @@ static void gl_cg_set_params(unsigned width, unsigned height, const struct gl_tex_info *fbo_info, unsigned fbo_info_cnt) { + unsigned i; if (!cg_active || (active_index == 0) || (active_index == GL_SHADER_STOCK_BLEND)) return; @@ -245,7 +247,7 @@ static void gl_cg_set_params(unsigned width, unsigned height, } // Set prev textures. - for (unsigned i = 0; i < PREV_TEXTURES; i++) + for (i = 0; i < PREV_TEXTURES; i++) { param = prg[active_index].prev[i].tex; if (param) @@ -268,7 +270,7 @@ static void gl_cg_set_params(unsigned width, unsigned height, } // Set lookup textures. - for (unsigned i = 0; i < cg_shader->luts; i++) + for (i = 0; i < cg_shader->luts; i++) { CGparameter fparam = cgGetNamedParameter(prg[active_index].fprg, cg_shader->lut[i].id); if (fparam) @@ -288,7 +290,7 @@ static void gl_cg_set_params(unsigned width, unsigned height, // Set FBO textures. if (active_index > 2) { - for (unsigned i = 0; i < fbo_info_cnt; i++) + for (i = 0; i < fbo_info_cnt; i++) { if (prg[active_index].fbo[i].tex) { @@ -321,7 +323,7 @@ static void gl_cg_set_params(unsigned width, unsigned height, if (active_index == 1) cnt = state_get_uniform(state_tracker, info, MAX_VARIABLES, frame_count); - for (unsigned i = 0; i < cnt; i++) + for (i = 0; i < cnt; i++) { CGparameter param_v = cgGetNamedParameter(prg[active_index].vprg, info[i].id); CGparameter param_f = cgGetNamedParameter(prg[active_index].fprg, info[i].id); @@ -333,12 +335,13 @@ static void gl_cg_set_params(unsigned width, unsigned height, static void gl_cg_deinit_progs(void) { + unsigned i; RARCH_LOG("CG: Destroying programs.\n"); cgGLUnbindProgram(cgFProf); cgGLUnbindProgram(cgVProf); // Programs may alias [0]. - for (unsigned i = 1; i < GFX_MAX_SHADERS; i++) + for (i = 1; i < GFX_MAX_SHADERS; i++) { if (prg[i].fprg && prg[i].fprg != prg[0].fprg) cgDestroyProgram(prg[i].fprg); @@ -514,12 +517,13 @@ static void load_texture_data(GLuint obj, const struct texture_image *img, bool static bool load_textures(void) { + unsigned i; if (!cg_shader->luts) return true; glGenTextures(cg_shader->luts, lut_textures); - for (unsigned i = 0; i < cg_shader->luts; i++) + for (i = 0; i < cg_shader->luts; i++) { RARCH_LOG("Loading image from: \"%s\".\n", cg_shader->lut[i].path); @@ -542,12 +546,13 @@ static bool load_textures(void) static bool load_imports(void) { + unsigned i; if (!cg_shader->variables) return true; struct state_tracker_info tracker_info = {0}; - for (unsigned i = 0; i < cg_shader->variables; i++) + for (i = 0; i < cg_shader->variables; i++) { unsigned memtype; switch (cg_shader->variable[i].ram_type) @@ -601,6 +606,7 @@ static bool load_shader(unsigned i) static bool load_preset(const char *path) { + unsigned i; if (!load_stock()) return false; @@ -632,7 +638,7 @@ static bool load_preset(const char *path) RARCH_WARN("Too many shaders ... Capping shader amount to %d.\n", GFX_MAX_SHADERS - 3); cg_shader->passes = GFX_MAX_SHADERS - 3; } - for (unsigned i = 0; i < cg_shader->passes; i++) + for (i = 0; i < cg_shader->passes; i++) { if (!load_shader(i)) { @@ -718,6 +724,7 @@ static void set_pass_attrib(struct cg_program *prg, struct cg_fbo_params *fbo, static void set_program_attributes(unsigned i) { + unsigned j; cgGLBindProgram(prg[i].fprg); cgGLBindProgram(prg[i].vprg); @@ -752,7 +759,7 @@ static void set_program_attributes(unsigned i) set_pass_attrib(&prg[i], &prg[i].orig, pass_str); } - for (unsigned j = 0; j < PREV_TEXTURES; j++) + for (j = 0; j < PREV_TEXTURES; j++) { char attr_buf_tex[64]; char attr_buf_vid_size[64]; @@ -784,7 +791,7 @@ static void set_program_attributes(unsigned i) prg[i].prev[j].coord = cgGetNamedParameter(prg[i].vprg, attr_buf_coord); } - for (unsigned j = 0; j < i - 1; j++) + for (j = 0; j < i - 1; j++) { char pass_str[64]; snprintf(pass_str, sizeof(pass_str), "PASS%u", j + 1); @@ -796,6 +803,7 @@ static void set_program_attributes(unsigned i) static bool gl_cg_init(const char *path) { + unsigned i; #ifdef HAVE_CG_RUNTIME_COMPILER cgRTCgcInit(); #endif @@ -842,7 +850,7 @@ static bool gl_cg_init(const char *path) } prg[0].mvp = cgGetNamedParameter(prg[0].vprg, "IN.mvp_matrix"); - for (unsigned i = 1; i <= cg_shader->passes; i++) + for (i = 1; i <= cg_shader->passes; i++) set_program_attributes(i); // If we aren't using last pass non-FBO shader, @@ -916,12 +924,13 @@ static void gl_cg_shader_scale(unsigned index, struct gfx_fbo_scale *scale) static unsigned gl_cg_get_prev_textures(void) { + unsigned i, j; if (!cg_active) return 0; unsigned max_prev = 0; - for (unsigned i = 1; i <= cg_shader->passes; i++) - for (unsigned j = 0; j < PREV_TEXTURES; j++) + for (i = 1; i <= cg_shader->passes; i++) + for (j = 0; j < PREV_TEXTURES; j++) if (prg[i].prev[j].tex) max_prev = max(j + 1, max_prev); diff --git a/gfx/xvideo.c b/gfx/xvideo.c index ff90a04cd8..67933df395 100644 --- a/gfx/xvideo.c +++ b/gfx/xvideo.c @@ -105,11 +105,12 @@ static inline void calculate_yuv(uint8_t *y, uint8_t *u, uint8_t *v, unsigned r, static void init_yuv_tables(xv_t *xv) { + unsigned i; xv->ytable = (uint8_t*)malloc(0x10000); xv->utable = (uint8_t*)malloc(0x10000); xv->vtable = (uint8_t*)malloc(0x10000); - for (unsigned i = 0; i < 0x10000; i++) + for (i = 0; i < 0x10000; i++) { // Extract RGB565 color data from i unsigned r = (i >> 11) & 0x1f, g = (i >> 5) & 0x3f, b = (i >> 0) & 0x1f; @@ -145,12 +146,13 @@ static void xv_init_font(xv_t *xv, const char *font_path, unsigned font_size) // We render @ 2x scale to combat chroma downsampling. Also makes fonts more bearable :) static void render16_yuy2(xv_t *xv, const void *input_, unsigned width, unsigned height, unsigned pitch) { + unsigned x, y; const uint16_t *input = (const uint16_t*)input_; uint8_t *output = (uint8_t*)xv->image->data; - for (unsigned y = 0; y < height; y++) + for (y = 0; y < height; y++) { - for (unsigned x = 0; x < width; x++) + for (x = 0; x < width; x++) { uint16_t p = *input++; @@ -173,12 +175,13 @@ static void render16_yuy2(xv_t *xv, const void *input_, unsigned width, unsigned static void render16_uyvy(xv_t *xv, const void *input_, unsigned width, unsigned height, unsigned pitch) { + unsigned x, y; const uint16_t *input = (const uint16_t*)input_; uint8_t *output = (uint8_t*)xv->image->data; - for (unsigned y = 0; y < height; y++) + for (y = 0; y < height; y++) { - for (unsigned x = 0; x < width; x++) + for (x = 0; x < width; x++) { uint16_t p = *input++; @@ -201,12 +204,13 @@ static void render16_uyvy(xv_t *xv, const void *input_, unsigned width, unsigned static void render32_yuy2(xv_t *xv, const void *input_, unsigned width, unsigned height, unsigned pitch) { + unsigned x, y; const uint32_t *input = (const uint32_t*)input_; uint8_t *output = (uint8_t*)xv->image->data; - for (unsigned y = 0; y < height; y++) + for (y = 0; y < height; y++) { - for (unsigned x = 0; x < width; x++) + for (x = 0; x < width; x++) { uint32_t p = *input++; p = ((p >> 8) & 0xf800) | ((p >> 5) & 0x07e0) | ((p >> 3) & 0x1f); // ARGB -> RGB16 @@ -230,12 +234,13 @@ static void render32_yuy2(xv_t *xv, const void *input_, unsigned width, unsigned static void render32_uyvy(xv_t *xv, const void *input_, unsigned width, unsigned height, unsigned pitch) { + unsigned x, y; const uint32_t *input = (const uint32_t*)input_; uint16_t *output = (uint16_t*)xv->image->data; - for (unsigned y = 0; y < height; y++) + for (y = 0; y < height; y++) { - for (unsigned x = 0; x < width; x++) + for (x = 0; x < width; x++) { uint32_t p = *input++; p = ((p >> 8) & 0xf800) | ((p >> 5) & 0x07e0) | ((p >> 3) & 0x1f); // ARGB -> RGB16 @@ -290,14 +295,16 @@ static const struct format_desc formats[] = { static bool adaptor_set_format(xv_t *xv, Display *dpy, XvPortID port, const video_info_t *video) { + int i; + unsigned j; int format_count; XvImageFormatValues *format = XvListImageFormats(xv->display, port, &format_count); if (!format) return false; - for (int i = 0; i < format_count; i++) + for (i = 0; i < format_count; i++) { - for (unsigned j = 0; j < sizeof(formats) / sizeof(formats[0]); j++) + for (j = 0; j < ARRAY_SIZE(formats); j++) { if (format[i].type == XvYUV && format[i].bits_per_pixel == 16 && format[i].format == XvPacked) { @@ -332,6 +339,7 @@ static void *xv_init(const video_info_t *video, const input_driver_t **input, vo XInitThreads(); + unsigned i; xv->display = XOpenDisplay(NULL); struct sigaction sa; unsigned adaptor_count = 0; @@ -357,7 +365,7 @@ static void *xv_init(const video_info_t *video, const input_driver_t **input, vo xv->port = 0; XvAdaptorInfo *adaptor_info; XvQueryAdaptors(xv->display, DefaultRootWindow(xv->display), &adaptor_count, &adaptor_info); - for (unsigned i = 0; i < adaptor_count; i++) + for (i = 0; i < adaptor_count; i++) { // Find adaptor that supports both input (memory->drawable) and image (drawable->screen) masks. if (adaptor_info[i].num_formats < 1) continue; @@ -587,6 +595,8 @@ static void xv_render_msg(xv_t *xv, const char *msg, unsigned width, unsigned he if (!xv->font) return; + int x, y; + unsigned i; struct font_output_list out; xv->font_driver->render_msg(xv->font, msg, &out); struct font_output *head = out.head; @@ -637,10 +647,10 @@ static void xv_render_msg(xv_t *xv, const char *msg, unsigned width, unsigned he uint8_t *out = (uint8_t*)xv->image->data + base_y * pitch + (base_x << 1); - for (int y = 0; y < glyph_height; y++, src += head->pitch, out += pitch) + for (y = 0; y < glyph_height; y++, src += head->pitch, out += pitch) { // 2 input pixels => 4 bytes (2Y, 1U, 1V). - for (int x = 0; x < glyph_width; x += 2) + for (x = 0; x < glyph_width; x += 2) { int out_x = x << 1; @@ -654,7 +664,7 @@ static void xv_render_msg(xv_t *xv, const char *msg, unsigned width, unsigned he unsigned alpha_sub = (alpha[0] + alpha[1]) >> 1; // Blended alpha for the sub-sampled U/V channels. - for (unsigned i = 0; i < 2; i++) + for (i = 0; i < 2; i++) { unsigned blended = (xv->font_y * alpha[i] + ((256 - alpha[i]) * out[out_x + luma_index[i]])) >> 8; out[out_x + luma_index[i]] = blended; diff --git a/input/dinput.c b/input/dinput.c index e8f5674be2..390b63389b 100644 --- a/input/dinput.c +++ b/input/dinput.c @@ -368,7 +368,8 @@ bool g_xinput_block_pads; static void dinput_joypad_destroy(void) { - for (unsigned i = 0; i < MAX_PLAYERS; i++) + unsigned i; + for (i = 0; i < MAX_PLAYERS; i++) { if (g_pads[i].joypad) { @@ -440,14 +441,14 @@ static const char* const XINPUT_PAD_NAMES[] = static bool name_is_xinput_pad(const char* name) { - for (unsigned i = 0; ; ++i) + unsigned i; + for (i = 0; XINPUT_PAD_NAMES[i]; i++) { - const char* t = XINPUT_PAD_NAMES[i]; - if (t == NULL) - return false; - else if (strcasecmp(name, t) == 0) + if (strcasecmp(name, XINPUT_PAD_NAMES[i]) == 0) return true; } + + return false; } // Forward declaration @@ -504,12 +505,13 @@ enum_iteration_done: static bool dinput_joypad_init(void) { + unsigned i; if (!dinput_init_context()) return false; g_last_xinput_pad_index = 0; - for (unsigned i = 0; i < MAX_PLAYERS; ++i) + for (i = 0; i < MAX_PLAYERS; ++i) { g_xinput_pad_indexes[i] = -1; g_pads[i].joy_name = NULL; @@ -617,7 +619,8 @@ static int16_t dinput_joypad_axis(unsigned port_num, uint32_t joyaxis) static void dinput_joypad_poll(void) { - for (unsigned i = 0; i < MAX_PLAYERS; i++) + unsigned i; + for (i = 0; i < MAX_PLAYERS; i++) { struct dinput_joypad *pad = &g_pads[i]; diff --git a/input/linuxraw_input.c b/input/linuxraw_input.c index 507f46e20d..7a6e22ba15 100644 --- a/input/linuxraw_input.c +++ b/input/linuxraw_input.c @@ -152,8 +152,9 @@ static const struct key_bind lut_binds[] = { static void init_lut(void) { + unsigned i; memset(keysym_lut, 0, sizeof(keysym_lut)); - for (unsigned i = 0; i < sizeof(lut_binds) / sizeof(lut_binds[0]); i++) + for (i = 0; i < ARRAY_SIZE(lut_binds); i++) keysym_lut[lut_binds[i].sk] = lut_binds[i].x; } diff --git a/input/linuxraw_joypad.c b/input/linuxraw_joypad.c index ecc0544e94..c80936f8cf 100644 --- a/input/linuxraw_joypad.c +++ b/input/linuxraw_joypad.c @@ -112,17 +112,17 @@ static bool linuxraw_joypad_init_pad(const char *path, struct linuxraw_joypad *p static void handle_plugged_pad(void) { + int i, rc; size_t event_size = sizeof(struct inotify_event) + NAME_MAX + 1; uint8_t *event_buf = (uint8_t*)calloc(1, event_size); if (!event_buf) return; - int rc; while ((rc = read(g_notify, event_buf, event_size)) >= 0) { struct inotify_event *event = NULL; // Can read multiple events in one read() call. - for (int i = 0; i < rc; i += event->len + sizeof(struct inotify_event)) + for (i = 0; i < rc; i += event->len + sizeof(struct inotify_event)) { event = (struct inotify_event*)&event_buf[i]; @@ -174,7 +174,7 @@ static void handle_plugged_pad(void) static void linuxraw_joypad_poll(void) { - int ret; + int i, ret; struct epoll_event events[MAX_PLAYERS + 1]; retry: @@ -182,7 +182,7 @@ retry: if (ret < 0 && errno == EINTR) goto retry; - for (int i = 0; i < ret; i++) + for (i = 0; i < ret; i++) { if (events[i].data.ptr) poll_pad((struct linuxraw_joypad*)events[i].data.ptr); @@ -199,11 +199,12 @@ static void linuxraw_joypad_setup_notify(void) static bool linuxraw_joypad_init(void) { + unsigned i; g_epoll = epoll_create(MAX_PLAYERS + 1); if (g_epoll < 0) return false; - for (unsigned i = 0; i < MAX_PLAYERS; i++) + for (i = 0; i < MAX_PLAYERS; i++) { struct linuxraw_joypad *pad = &g_pads[i]; pad->fd = -1; @@ -239,14 +240,15 @@ static bool linuxraw_joypad_init(void) static void linuxraw_joypad_destroy(void) { - for (unsigned i = 0; i < MAX_PLAYERS; i++) + unsigned i; + for (i = 0; i < MAX_PLAYERS; i++) { if (g_pads[i].fd >= 0) close(g_pads[i].fd); } memset(g_pads, 0, sizeof(g_pads)); - for (unsigned i = 0; i < MAX_PLAYERS; i++) + for (i = 0; i < MAX_PLAYERS; i++) g_pads[i].fd = -1; if (g_notify >= 0) diff --git a/input/sdl_joypad.c b/input/sdl_joypad.c index e18ef87e95..b242470e00 100644 --- a/input/sdl_joypad.c +++ b/input/sdl_joypad.c @@ -29,7 +29,8 @@ static struct sdl_joypad g_pads[MAX_PLAYERS]; static void sdl_joypad_destroy(void) { - for (unsigned i = 0; i < MAX_PLAYERS; i++) + unsigned i; + for (i = 0; i < MAX_PLAYERS; i++) { if (g_pads[i].joypad) SDL_JoystickClose(g_pads[i].joypad); @@ -41,6 +42,7 @@ static void sdl_joypad_destroy(void) static bool sdl_joypad_init(void) { + unsigned i; if (SDL_Init(SDL_INIT_JOYSTICK) < 0) return false; @@ -48,7 +50,7 @@ static bool sdl_joypad_init(void) if (num_sticks > MAX_PLAYERS) num_sticks = MAX_PLAYERS; - for (unsigned i = 0; i < num_sticks; i++) + for (i = 0; i < num_sticks; i++) { struct sdl_joypad *pad = &g_pads[i]; pad->joypad = SDL_JoystickOpen(i); diff --git a/input/udev_joypad.c b/input/udev_joypad.c index 62253e2bca..0bdb6ae39a 100644 --- a/input/udev_joypad.c +++ b/input/udev_joypad.c @@ -80,19 +80,19 @@ static inline int16_t compute_axis(const struct input_absinfo *info, int value) return axis; } -static void poll_pad(unsigned i) +static void poll_pad(unsigned p) { - struct udev_joypad *pad = &g_pads[i]; + struct udev_joypad *pad = &g_pads[p]; if (pad->fd < 0) return; - int len; + int i, len; struct input_event events[32]; while ((len = read(pad->fd, events, sizeof(events))) > 0) { len /= sizeof(*events); - for (int i = 0; i < len; i++) + for (i = 0; i < len; i++) { int code = events[i].code; switch (events[i].type) @@ -241,10 +241,11 @@ static bool udev_set_rumble(unsigned i, enum retro_rumble_effect effect, uint16_ static void udev_joypad_poll(void) { + unsigned i; while (hotplug_available()) handle_hotplug(); - for (unsigned i = 0; i < MAX_PLAYERS; i++) + for (i = 0; i < MAX_PLAYERS; i++) poll_pad(i); } @@ -351,7 +352,8 @@ error: static int find_vacant_pad(void) { - for (unsigned i = 0; i < MAX_PLAYERS; i++) + unsigned i; + for (i = 0; i < MAX_PLAYERS; i++) if (g_pads[i].fd < 0) return i; return -1; @@ -375,16 +377,17 @@ static void free_pad(unsigned pad, bool hotplug) input_config_autoconfigure_joypad(pad, NULL, NULL); } -static bool add_pad(unsigned i, int fd, const char *path) +static bool add_pad(unsigned p, int fd, const char *path) { - struct udev_joypad *pad = &g_pads[i]; + int i; + struct udev_joypad *pad = &g_pads[p]; if (ioctl(fd, EVIOCGNAME(sizeof(g_settings.input.device_names[0])), pad->ident) < 0) { RARCH_LOG("[udev]: Failed to get pad name.\n"); return false; } - RARCH_LOG("[udev]: Plugged pad: %s on port #%u.\n", pad->ident, i); + RARCH_LOG("[udev]: Plugged pad: %s on port #%u.\n", pad->ident, p); struct stat st; if (fstat(fd, &st) < 0) @@ -401,13 +404,13 @@ static bool add_pad(unsigned i, int fd, const char *path) // and map them to button/axes/hat indices. unsigned buttons = 0; unsigned axes = 0; - for (int i = BTN_JOYSTICK; i < KEY_MAX && buttons < NUM_BUTTONS; i++) + for (i = BTN_JOYSTICK; i < KEY_MAX && buttons < NUM_BUTTONS; i++) if (test_bit(i, keybit)) pad->button_bind[i] = buttons++; - for (int i = BTN_MISC; i < BTN_JOYSTICK; i++) + for (i = BTN_MISC; i < BTN_JOYSTICK; i++) if (test_bit(i, keybit)) pad->button_bind[i] = buttons++; - for (int i = 0; i < ABS_MISC && axes < NUM_AXES; i++) + for (i = 0; i < ABS_MISC && axes < NUM_AXES; i++) { // Skip hats for now. if (i == ABS_HAT0X) @@ -452,11 +455,12 @@ static bool add_pad(unsigned i, int fd, const char *path) static void check_device(const char *path, bool hotplugged) { + unsigned i; struct stat st; if (stat(path, &st) < 0) return; - for (unsigned i = 0; i < MAX_PLAYERS; i++) + for (i = 0; i < MAX_PLAYERS; i++) { if (st.st_rdev == g_pads[i].device) { @@ -500,7 +504,8 @@ static void check_device(const char *path, bool hotplugged) static void remove_device(const char *path) { - for (unsigned i = 0; i < MAX_PLAYERS; i++) + unsigned i; + for (i = 0; i < MAX_PLAYERS; i++) { if (g_pads[i].path && !strcmp(g_pads[i].path, path)) { @@ -518,7 +523,8 @@ static void remove_device(const char *path) static void udev_joypad_destroy(void) { - for (unsigned i = 0; i < MAX_PLAYERS; i++) + unsigned i; + for (i = 0; i < MAX_PLAYERS; i++) free_pad(i, false); if (g_udev_mon) @@ -531,7 +537,8 @@ static void udev_joypad_destroy(void) static bool udev_joypad_init(void) { - for (unsigned i = 0; i < MAX_PLAYERS; i++) + unsigned i; + for (i = 0; i < MAX_PLAYERS; i++) { g_pads[i].fd = -1; g_pads[i].ident = g_settings.input.device_names[i]; @@ -558,7 +565,7 @@ static bool udev_joypad_init(void) udev_enumerate_add_match_property(enumerate, "ID_INPUT_JOYSTICK", "1"); udev_enumerate_scan_devices(enumerate); devs = udev_enumerate_get_list_entry(enumerate); - for (struct udev_list_entry *item = devs; item; item = udev_list_entry_get_next(item)) + for (item = devs; item; item = udev_list_entry_get_next(item)) { const char *name = udev_list_entry_get_name(item); struct udev_device *dev = udev_device_new_from_syspath(g_udev, name); diff --git a/input/winxinput_joypad.c b/input/winxinput_joypad.c index cd36ffb31c..44dd9108fb 100644 --- a/input/winxinput_joypad.c +++ b/input/winxinput_joypad.c @@ -145,6 +145,7 @@ const char* winxinput_joypad_name (unsigned pad) static bool winxinput_joypad_init(void) { + unsigned i, autoconf_pad; g_winxinput_dll = NULL; // Find the correct path to load the DLL from. @@ -201,12 +202,12 @@ static bool winxinput_joypad_init(void) } // Zero out the states - for (unsigned i = 0; i < 4; ++i) + for (i = 0; i < 4; ++i) memset(&g_winxinput_states[i], 0, sizeof(winxinput_joypad_state)); // Do a dummy poll to check which controllers are connected. XINPUT_STATE dummy_state; - for (unsigned i = 0; i < 4; ++i) + for (i = 0; i < 4; ++i) { g_winxinput_states[i].connected = !(g_XInputGetStateEx(i, &dummy_state) == ERROR_DEVICE_NOT_CONNECTED); if (g_winxinput_states[i].connected) @@ -229,7 +230,7 @@ static bool winxinput_joypad_init(void) return false; } - for (unsigned autoconf_pad = 0; autoconf_pad < MAX_PLAYERS; autoconf_pad++) + for (autoconf_pad = 0; autoconf_pad < MAX_PLAYERS; autoconf_pad++) { if (pad_index_to_xplayer_index(autoconf_pad) > -1) { @@ -253,7 +254,8 @@ static bool winxinput_joypad_query_pad(unsigned pad) static void winxinput_joypad_destroy(void) { - for (unsigned i = 0; i < 4; ++i) + unsigned i; + for (i = 0; i < 4; ++i) memset(&g_winxinput_states[i], 0, sizeof(winxinput_joypad_state)); FreeLibrary(g_winxinput_dll); @@ -376,7 +378,8 @@ static int16_t winxinput_joypad_axis (unsigned port_num, uint32_t joyaxis) static void winxinput_joypad_poll(void) { - for (unsigned i = 0; i < 4; ++i) + unsigned i; + for (i = 0; i < 4; ++i) if (g_winxinput_states[i].connected) if (g_XInputGetStateEx(i, &(g_winxinput_states[i].xstate)) == ERROR_DEVICE_NOT_CONNECTED) g_winxinput_states[i].connected = false; @@ -416,3 +419,4 @@ const rarch_joypad_driver_t winxinput_joypad = { winxinput_joypad_name, "winxinput", }; + diff --git a/netplay.c b/netplay.c index 9322297fe5..181579c3f8 100644 --- a/netplay.c +++ b/netplay.c @@ -446,6 +446,7 @@ bool netplay_can_poll(netplay_t *handle) // The alternative would have been checking serialization sizes, but it was troublesome for cross platform compat. static uint32_t implementation_magic_value(void) { + size_t i; uint32_t res = 0; unsigned api = pretro_api_version(); @@ -453,17 +454,17 @@ static uint32_t implementation_magic_value(void) const char *lib = g_extern.system.info.library_name; size_t len = strlen(lib); - for (size_t i = 0; i < len; i++) + for (i = 0; i < len; i++) res ^= lib[i] << (i & 0xf); lib = g_extern.system.info.library_version; len = strlen(lib); - for (size_t i = 0; i < len; i++) + for (i = 0; i < len; i++) res ^= lib[i] << (i & 0xf); const char *ver = PACKAGE_VERSION; len = strlen(ver); - for (size_t i = 0; i < len; i++) + for (i = 0; i < len; i++) res ^= ver[i] << ((i & 0xf) + 16); return res; @@ -728,9 +729,10 @@ static bool get_info_spectate(netplay_t *handle) static void init_buffers(netplay_t *handle) { + unsigned i; handle->buffer = (struct delta_frame*)calloc(handle->buffer_size, sizeof(*handle->buffer)); handle->state_size = pretro_serialize_size(); - for (unsigned i = 0; i < handle->buffer_size; i++) + for (i = 0; i < handle->buffer_size; i++) { handle->buffer[i].state = malloc(handle->state_size); handle->buffer[i].is_simulated = true; @@ -742,6 +744,7 @@ netplay_t *netplay_new(const char *server, uint16_t port, bool spectate, const char *nick) { + unsigned i; if (frames > UDP_FRAME_PACKETS) frames = UDP_FRAME_PACKETS; @@ -771,7 +774,7 @@ netplay_t *netplay_new(const char *server, uint16_t port, goto error; } - for (unsigned i = 0; i < MAX_SPECTATORS; i++) + for (i = 0; i < MAX_SPECTATORS; i++) handle->spectate_fds[i] = -1; } else @@ -890,13 +893,14 @@ static int poll_input(netplay_t *handle, bool block) // Grab our own input state and send this over the network. static bool get_self_input_state(netplay_t *handle) { + unsigned i; struct delta_frame *ptr = &handle->buffer[handle->self_ptr]; uint32_t state = 0; if (handle->frame_count > 0) // First frame we always give zero input since relying on input from first frame screws up when we use -F 0. { retro_input_state_t cb = handle->cbs.state_cb; - for (unsigned i = 0; i < RARCH_FIRST_META_KEY; i++) + for (i = 0; i < RARCH_FIRST_META_KEY; i++) { int16_t tmp = cb(g_settings.input.netplay_client_swap_input ? 0 : !handle->port, RETRO_DEVICE_JOYPAD, 0, i); @@ -934,10 +938,11 @@ static void simulate_input(netplay_t *handle) static void parse_packet(netplay_t *handle, uint32_t *buffer, unsigned size) { - for (unsigned i = 0; i < size * 2; i++) + unsigned i; + for (i = 0; i < size * 2; i++) buffer[i] = ntohl(buffer[i]); - for (unsigned i = 0; i < size && handle->read_frame_count <= handle->frame_count; i++) + for (i = 0; i < size && handle->read_frame_count <= handle->frame_count; i++) { uint32_t frame = buffer[2 * i + 0]; uint32_t state = buffer[2 * i + 1]; @@ -1194,11 +1199,12 @@ int16_t netplay_input_state(netplay_t *handle, bool port, unsigned device, unsig void netplay_free(netplay_t *handle) { + unsigned i; close(handle->fd); if (handle->spectate) { - for (unsigned i = 0; i < MAX_SPECTATORS; i++) + for (i = 0; i < MAX_SPECTATORS; i++) if (handle->spectate_fds[i] >= 0) close(handle->spectate_fds[i]); @@ -1208,7 +1214,7 @@ void netplay_free(netplay_t *handle) { close(handle->udp_fd); - for (unsigned i = 0; i < handle->buffer_size; i++) + for (i = 0; i < handle->buffer_size; i++) free(handle->buffer[i].state); free(handle->buffer); @@ -1276,6 +1282,7 @@ int16_t input_state_spectate_client(unsigned port, unsigned device, unsigned ind static void netplay_pre_frame_spectate(netplay_t *handle) { + unsigned i; if (handle->spectate_client) return; @@ -1300,7 +1307,7 @@ static void netplay_pre_frame_spectate(netplay_t *handle) } int index = -1; - for (unsigned i = 0; i < MAX_SPECTATORS; i++) + for (i = 0; i < MAX_SPECTATORS; i++) { if (handle->spectate_fds[i] == -1) { @@ -1416,10 +1423,11 @@ static void netplay_post_frame_net(netplay_t *handle) static void netplay_post_frame_spectate(netplay_t *handle) { + unsigned i; if (handle->spectate_client) return; - for (unsigned i = 0; i < MAX_SPECTATORS; i++) + for (i = 0; i < MAX_SPECTATORS; i++) { if (handle->spectate_fds[i] == -1) continue; diff --git a/record/ffemu.c b/record/ffemu.c index d55eb1c667..8b51a5177a 100644 --- a/record/ffemu.c +++ b/record/ffemu.c @@ -173,7 +173,8 @@ struct ffemu static bool ffemu_codec_has_sample_format(enum AVSampleFormat fmt, const enum AVSampleFormat *fmts) { - for (unsigned i = 0; fmts[i] != AV_SAMPLE_FMT_NONE; i++) + unsigned i; + for (i = 0; fmts[i] != AV_SAMPLE_FMT_NONE; i++) if (fmt == fmts[i]) return true; return false; @@ -216,6 +217,7 @@ static void ffemu_audio_resolve_format(struct ff_audio_info *audio, const AVCode static void ffemu_audio_resolve_sample_rate(ffemu_t *handle, const AVCodec *codec) { + unsigned i; struct ff_config_param *params = &handle->config; struct ffemu_params *param = &handle->params; @@ -228,7 +230,7 @@ static void ffemu_audio_resolve_sample_rate(ffemu_t *handle, const AVCodec *code int best_rate = codec->supported_samplerates[0]; int best_diff = best_rate - input_rate; - for (unsigned i = 1; codec->supported_samplerates[i]; i++) + for (i = 1; codec->supported_samplerates[i]; i++) { int diff = codec->supported_samplerates[i] - input_rate; @@ -702,6 +704,7 @@ void ffemu_free(ffemu_t *handle) bool ffemu_push_video(ffemu_t *handle, const struct ffemu_video_data *data) { + unsigned y; bool drop_frame = handle->video.frame_drop_count++ % handle->video.frame_drop_ratio; handle->video.frame_drop_count %= handle->video.frame_drop_ratio; if (drop_frame) @@ -745,7 +748,7 @@ bool ffemu_push_video(ffemu_t *handle, const struct ffemu_video_data *data) fifo_write(handle->attr_fifo, &attr_data, sizeof(attr_data)); int offset = 0; - for (unsigned y = 0; y < attr_data.height; y++, offset += data->pitch) + for (y = 0; y < attr_data.height; y++, offset += data->pitch) fifo_write(handle->video_fifo, (const uint8_t*)data->data + offset, attr_data.pitch); slock_unlock(handle->lock); @@ -882,7 +885,8 @@ static bool ffemu_push_video_thread(ffemu_t *handle, const struct ffemu_video_da static void planarize_float(float *out, const float *in, size_t frames) { - for (size_t i = 0; i < frames; i++) + size_t i; + for (i = 0; i < frames; i++) { out[i] = in[2 * i + 0]; out[i + frames] = in[2 * i + 1]; @@ -891,7 +895,8 @@ static void planarize_float(float *out, const float *in, size_t frames) static void planarize_s16(int16_t *out, const int16_t *in, size_t frames) { - for (size_t i = 0; i < frames; i++) + size_t i; + for (i = 0; i < frames; i++) { out[i] = in[2 * i + 0]; out[i + frames] = in[2 * i + 1]; diff --git a/tools/retroarch-joyconfig.c b/tools/retroarch-joyconfig.c index eca6ee862e..12355154b7 100644 --- a/tools/retroarch-joyconfig.c +++ b/tools/retroarch-joyconfig.c @@ -77,15 +77,16 @@ static void poll_joypad(const rarch_joypad_driver_t *driver, unsigned pad, struct poll_data *data) { + unsigned i; input_joypad_poll(driver); - for (unsigned i = 0; i < MAX_BUTTONS; i++) + for (i = 0; i < MAX_BUTTONS; i++) data->buttons[i] = input_joypad_button_raw(driver, pad, i); - for (unsigned i = 0; i < MAX_AXES; i++) + for (i = 0; i < MAX_AXES; i++) data->axes[i] = input_joypad_axis_raw(driver, pad, i); - for (unsigned i = 0; i < MAX_HATS; i++) + for (i = 0; i < MAX_HATS; i++) { uint16_t hat = 0; hat |= input_joypad_hat_raw(driver, pad, HAT_UP_MASK, i) << HAT_UP_SHIFT; @@ -99,6 +100,7 @@ static void poll_joypad(const rarch_joypad_driver_t *driver, static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player, int joypad) { + int i, timeout_cnt; const rarch_joypad_driver_t *driver = input_joypad_init_driver(g_driver); if (!driver) { @@ -136,7 +138,7 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player, getchar(); poll_joypad(driver, joypad, &old_poll); - for (int i = 0; i < MAX_AXES; i++) + for (i = 0; i < MAX_AXES; i++) { int16_t initial = input_joypad_axis_raw(driver, joypad, i); if (abs(initial) < 20000) @@ -152,7 +154,7 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player, initial_axes[i] = initial; } - for (int i = 0; i < MAX_BUTTONS; i++) + for (i = 0; i < MAX_BUTTONS; i++) { if (old_poll.buttons[i]) fprintf(stderr, "Button %d was initially pressed. This indicates broken initial state.\n", i); @@ -161,8 +163,9 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player, fprintf(stderr, "Configuring binds for player #%d on joypad #%d.\n\n", player + 1, joypad); - for (unsigned i = 0, timeout_cnt = 0; input_config_bind_map[i].valid; i++, timeout_cnt = 0) + for (i = 0, timeout_cnt = 0; input_config_bind_map[i].valid; i++, timeout_cnt = 0) { + int j; if (i == RARCH_TURBO_ENABLE) continue; @@ -194,7 +197,7 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player, } poll_joypad(driver, joypad, &new_poll); - for (int j = 0; j < MAX_BUTTONS; j++) + for (j = 0; j < MAX_BUTTONS; j++) { if (new_poll.buttons[j] && !old_poll.buttons[j]) { @@ -215,7 +218,7 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player, } } - for (int j = 0; j < MAX_AXES; j++) + for (j = 0; j < MAX_AXES; j++) { if (new_poll.axes[j] == old_poll.axes[j]) continue; @@ -270,7 +273,7 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player, } } - for (int j = 0; j < MAX_HATS; j++) + for (j = 0; j < MAX_HATS; j++) { const char *quark = NULL; uint16_t value = new_poll.hats[j];