diff --git a/frontend/drivers/platform_dos.c b/frontend/drivers/platform_dos.c index 6d94a949a6d..17d3541f64a 100644 --- a/frontend/drivers/platform_dos.c +++ b/frontend/drivers/platform_dos.c @@ -37,15 +37,9 @@ static void frontend_dos_init(void *data) printf("Loading RetroArch. Time is @%ld...\n", (long) time(NULL)); } -static void frontend_dos_shutdown(bool unused) -{ - (void)unused; -} - -static int frontend_dos_get_rating(void) -{ - return -1; -} +/* TODO/FIXME - implement */ +static void frontend_dos_shutdown(bool unused) { } +static int frontend_dos_get_rating(void) { return -1; } enum frontend_architecture frontend_dos_get_arch(void) { @@ -128,16 +122,8 @@ static void frontend_dos_exitspawn(char *s, size_t len, char *args) if (dos_fork_mode == FRONTEND_FORK_NONE) return; - - switch (dos_fork_mode) - { - case FRONTEND_FORK_CORE_WITH_ARGS: - should_load_content = true; - break; - case FRONTEND_FORK_NONE: - default: - break; - } + if (dos_fork_mode == FRONTEND_FORK_CORE_WITH_ARGS) + should_load_content = true; frontend_dos_exec(s, should_load_content); } diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index 43e3269e5f1..5d1a3b18c6d 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -193,10 +193,8 @@ static void x11_set_window_pid(Display *dpy, Window win) if (gethostname(hostname, scret + 1) == -1) RARCH_WARN("Failed to get hostname.\n"); else - { XChangeProperty(dpy, win, XA_WM_CLIENT_MACHINE, XA_STRING, 8, PropModeReplace, (unsigned char *)hostname, strlen(hostname)); - } free(hostname); } @@ -209,10 +207,10 @@ void x11_set_window_attr(Display *dpy, Window win) static void xdg_screensaver_inhibit(Window wnd) { int ret; + size_t _len; char cmd[64]; char title[128]; - cmd[0] = '\0'; title[0] = '\0'; RARCH_LOG("[X11]: Suspending screensaver (X11, xdg-screensaver).\n"); @@ -230,7 +228,8 @@ static void xdg_screensaver_inhibit(Window wnd) 8, PropModeReplace, (const unsigned char*) title, title_len); } - snprintf(cmd, sizeof(cmd), "xdg-screensaver suspend 0x%x", (int)wnd); + _len = strlcpy(cmd, "xdg-screensaver suspend 0x", sizeof(cmd)); + snprintf(cmd + _len, sizeof(cmd) - _len, "%x", (int)wnd); if ((ret = system(cmd)) == -1) { diff --git a/gfx/display_servers/dispserv_x11.c b/gfx/display_servers/dispserv_x11.c index dd2ef33172f..8a55f63d03b 100644 --- a/gfx/display_servers/dispserv_x11.c +++ b/gfx/display_servers/dispserv_x11.c @@ -80,8 +80,8 @@ static Display* x11_display_server_open_display(dispserv_x11_t *dispserv) static void x11_display_server_close_display(dispserv_x11_t *dispserv, Display *dpy) { - if ( !dpy - || !dispserv + if ( !dpy + || !dispserv || (dispserv->flags & DISPSERV_X11_FLAG_USING_GLOBAL_DPY) || dpy == g_x11_dpy) return; @@ -93,9 +93,10 @@ static bool x11_display_server_set_resolution(void *data, unsigned width, unsigned height, int int_hz, float hz, int center, int monitor_index, int xoffset, int padjust) { + size_t _len; int m, screen; Window window; - XRRScreenResources + XRRScreenResources *resources = NULL; XRRScreenResources *res = NULL; Display *dpy = NULL; @@ -121,8 +122,10 @@ static bool x11_display_server_set_resolution(void *data, dispserv->monitor_index = monitor_index; dispserv->flags |= DISPSERV_X11_FLAG_CRT_EN; dispserv->crt_name_id += 1; - snprintf(dispserv->crt_name, sizeof(dispserv->crt_name), - "CRT%d", dispserv->crt_name_id); + _len = strlcpy(dispserv->crt_name, "CRT", sizeof(dispserv->crt_name)); + _len += snprintf(dispserv->crt_name + _len, + sizeof(dispserv->crt_name) - _len, + "%d", dispserv->crt_name_id); strlcpy(dispserv->old_mode, dispserv->new_mode, sizeof(dispserv->old_mode)); @@ -192,11 +195,11 @@ static bool x11_display_server_set_resolution(void *data, /* Create interlaced new mode from modline variables */ if (height < 300) - crt_mode_flag = 10; + crt_mode_flag = 10; /* Create interlaced new mode from modline variables */ if (height > 300) - crt_mode_flag = 26; + crt_mode_flag = 26; strlcpy(dispserv->old_mode, dispserv->new_mode, sizeof(dispserv->old_mode)); /* variable for new mode */ strlcpy(dispserv->new_mode, dispserv->crt_name, sizeof(dispserv->new_mode)); @@ -205,7 +208,7 @@ static bool x11_display_server_set_resolution(void *data, * add and delete modes */ dispserv->crt_rrmode.name = dispserv->new_mode; - dispserv->crt_rrmode.nameLength = strlen(dispserv->crt_name); + dispserv->crt_rrmode.nameLength = _len; dispserv->crt_rrmode.dotClock = pixel_clock; dispserv->crt_rrmode.width = width; dispserv->crt_rrmode.hSyncStart = hfp; @@ -235,7 +238,7 @@ static bool x11_display_server_set_resolution(void *data, XRRFreeScreenResources(resources); if (!crt_exists) - XRRCreateMode(dpy, window, &dispserv->crt_rrmode); + XRRCreateMode(dpy, window, &dispserv->crt_rrmode); resources = XRRGetScreenResourcesCurrent(dpy, window); @@ -273,7 +276,7 @@ static bool x11_display_server_set_resolution(void *data, XSync(dpy, False); XRRSetCrtcConfig(dpy, res, res->crtcs[i], CurrentTime, crtc->x, crtc->y, crtc->mode, crtc->rotation, - crtc->outputs, crtc->noutput); + crtc->outputs, crtc->noutput); XSync(dpy, False); @@ -497,16 +500,16 @@ static void x11_display_server_destroy(void *data) #ifdef HAVE_XRANDR if (dispserv->flags & DISPSERV_X11_FLAG_CRT_EN) { + char dmode[25]; XRRModeInfo *swoldmode = NULL; XRRModeInfo *swdeskmode = NULL; - XRRScreenResources + XRRScreenResources *resources = NULL; XRRScreenResources *res = NULL; Display *dpy = XOpenDisplay(0); int screen = DefaultScreen(dpy); Window window = RootWindow(dpy, screen); bool crt_exists = false; - char dmode[25] = {0}; strlcpy(dmode, "d_mo", sizeof(dmode)); @@ -544,7 +547,7 @@ static void x11_display_server_destroy(void *data) if (!crt_exists) - XRRCreateMode(dpy, window, &dispserv->crt_rrmode); + XRRCreateMode(dpy, window, &dispserv->crt_rrmode); resources = XRRGetScreenResourcesCurrent(dpy, window); @@ -561,7 +564,7 @@ static void x11_display_server_destroy(void *data) { for (i = 0; i < res->noutput; i++) { - XRROutputInfo *outputs = + XRROutputInfo *outputs = XRRGetOutputInfo(dpy, res, res->outputs[i]); if (outputs->connection == RR_Connected) @@ -586,7 +589,7 @@ static void x11_display_server_destroy(void *data) XRRFreeCrtcInfo(crtc); - } + } XRRFreeOutputInfo(outputs); } diff --git a/gfx/drivers/d3d9hlsl.c b/gfx/drivers/d3d9hlsl.c index ad5e24605f4..b1c0b432b3f 100644 --- a/gfx/drivers/d3d9hlsl.c +++ b/gfx/drivers/d3d9hlsl.c @@ -483,19 +483,20 @@ static bool d3d9_hlsl_load_program( struct shader_pass *pass, const char *prog) { - ID3DXBuffer *listing_f = NULL; - ID3DXBuffer *listing_v = NULL; - ID3DXBuffer *code_f = NULL; - ID3DXBuffer *code_v = NULL; + ID3DXBuffer *listing_f = NULL; + ID3DXBuffer *listing_v = NULL; + ID3DXBuffer *code_f = NULL; + ID3DXBuffer *code_v = NULL; + size_t prog_len = strlen(prog); - if (!d3d9x_compile_shader(prog, strlen(prog), NULL, NULL, + if (!d3d9x_compile_shader(prog, prog_len, NULL, NULL, "main_fragment", "ps_3_0", 0, &code_f, &listing_f, &pass->ftable )) { RARCH_ERR("Could not compile stock fragment shader..\n"); goto error; } - if (!d3d9x_compile_shader(prog, strlen(prog), NULL, NULL, + if (!d3d9x_compile_shader(prog, prog_len, NULL, NULL, "main_vertex", "vs_3_0", 0, &code_v, &listing_v, &pass->vtable )) { diff --git a/gfx/drivers_context/orbis_ctx.c b/gfx/drivers_context/orbis_ctx.c index 0a7771ae7b8..8d9899eae13 100644 --- a/gfx/drivers_context/orbis_ctx.c +++ b/gfx/drivers_context/orbis_ctx.c @@ -122,8 +122,8 @@ static void *orbis_ctx_init(void *video_driver) goto error; #if defined(HAVE_OOSDK) - shdr_cache_dir = "/data/retroarch/temp/"; memset(&ctx_orbis->shdr_cache_config, 0, sizeof(ctx_orbis->shdr_cache_config)); + shdr_cache_dir = "/data/retroarch/temp/"; ctx_orbis->shdr_cache_config.ver = 0x00010064; snprintf(ctx_orbis->shdr_cache_config.cache_dir, strlen(shdr_cache_dir) + 1, "%s", diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c index 5856c5851f7..936604feb63 100644 --- a/gfx/drivers_context/wgl_ctx.c +++ b/gfx/drivers_context/wgl_ctx.c @@ -144,31 +144,30 @@ static gfx_ctx_proc_t gfx_ctx_wgl_get_proc_address(const char *symbol) } #if (defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE)) && !defined(HAVE_OPENGLES) -static bool wgl_has_extension(const char *extension, const char *extensions) +static bool wgl_has_extension(const char *ext, const char *exts) { - const char *start = NULL; - const char *terminator = NULL; - const char *where = strchr(extension, ' '); + const char *where = strchr(ext, ' '); - if (where || *extension == '\0') + if (where || *ext == '\0') return false; - if (!extensions) - return false; - - start = extensions; - - for (;;) + if (exts) { - if (!(where = strstr(start, extension))) - break; + const char *terminator = NULL; + const char *start = exts; - terminator = where + strlen(extension); - if (where == start || *(where - 1) == ' ') - if (*terminator == ' ' || *terminator == '\0') - return true; + for (;;) + { + if (!(where = strstr(start, ext))) + break; + + terminator = where + strlen(ext); + if (where == start || *(where - 1) == ' ') + if (*terminator == ' ' || *terminator == '\0') + return true; - start = terminator; + start = terminator; + } } return false; } @@ -267,11 +266,11 @@ void create_gl_context(HWND hwnd, bool *quit) pcreate_context = (wglCreateContextAttribsProc) gfx_ctx_wgl_get_proc_address("wglCreateContextAttribsARB"); - /* In order to support the core info "required_hw_api" + /* In order to support the core info "required_hw_api" * field correctly, we should try to init the highest available - * version GL context possible. This means trying successively + * version GL context possible. This means trying successively * lower versions until it works, because GL has - * no facility for determining the highest possible + * no facility for determining the highest possible * supported version. */ if (pcreate_context) @@ -329,8 +328,8 @@ void create_gl_context(HWND hwnd, bool *quit) (versions[i][0] == (int)win32_major) && (versions[i][1] == (int)win32_minor)) { - /* The requested version was tried and - * is not supported, go ahead and fail + /* The requested version was tried and + * is not supported, go ahead and fail * since everything else will be lower than that. */ break; } @@ -348,16 +347,16 @@ void create_gl_context(HWND hwnd, bool *quit) { const char *(WINAPI * wglGetExtensionsStringARB) (HDC) = 0; - const char *extensions = NULL; - wglGetExtensionsStringARB = + const char *exts = NULL; + wglGetExtensionsStringARB = (const char *(WINAPI *) (HDC)) gfx_ctx_wgl_get_proc_address("wglGetExtensionsStringARB"); if (wglGetExtensionsStringARB) { - extensions = wglGetExtensionsStringARB(win32_hdc); - RARCH_LOG("[WGL]: Extensions: %s\n", extensions); - if (wgl_has_extension("WGL_EXT_swap_control_tear", extensions)) + exts = wglGetExtensionsStringARB(win32_hdc); + RARCH_LOG("[WGL]: Extensions: %s\n", exts); + if (wgl_has_extension("WGL_EXT_swap_control_tear", exts)) { RARCH_LOG("[WGL]: Adaptive VSync supported.\n"); wgl_flags |= WGL_FLAG_ADAPTIVE_VSYNC; diff --git a/gfx/drivers_context/x_ctx.c b/gfx/drivers_context/x_ctx.c index 44ca7a1a8c4..47f9b530e3d 100644 --- a/gfx/drivers_context/x_ctx.c +++ b/gfx/drivers_context/x_ctx.c @@ -123,26 +123,26 @@ static const unsigned long retroarch_icon_data[] = { #if defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE) static PFNGLXCREATECONTEXTATTRIBSARBPROC glx_create_context_attribs; -static int GLXExtensionSupported(Display *dpy, const char *extension) +static int GLXExtensionSupported(Display *dpy, const char *ext) { - const char *extensionsString = glXQueryExtensionsString(dpy, DefaultScreen(dpy)); + const char *ext_string = glXQueryExtensionsString(dpy, DefaultScreen(dpy)); const char *client_extensions = glXGetClientString(dpy, GLX_EXTENSIONS); - const char *pos = strstr(extensionsString, extension); - size_t pos_ext_len = strlen(extension); + const char *pos = strstr(ext_string, ext); + size_t pos_ext_len = strlen(ext); - if ( pos && - (pos == extensionsString || pos[-1] == ' ') && - (pos[pos_ext_len] == ' ' || pos[pos_ext_len] == '\0') + if ( pos + && (pos == ext_string || pos[-1] == ' ') + && (pos[pos_ext_len] == ' ' || pos[pos_ext_len] == '\0') ) return 1; - pos = strstr(client_extensions, extension); - pos_ext_len = strlen(extension); + pos = strstr(client_extensions, ext); + pos_ext_len = strlen(ext); if ( - pos && - (pos == extensionsString || pos[-1] == ' ') && - (pos[pos_ext_len] == ' ' || pos[pos_ext_len] == '\0') + pos + && (pos == ext_string || pos[-1] == ' ') + && (pos[pos_ext_len] == ' ' || pos[pos_ext_len] == '\0') ) return 1; @@ -424,8 +424,8 @@ static void *gfx_ctx_x_init(void *data) x->adaptive_vsync = true; } - if (GLXExtensionSupported(g_x11_dpy, "GLX_OML_sync_control") && - GLXExtensionSupported(g_x11_dpy, "GLX_MESA_swap_control") + if ( GLXExtensionSupported(g_x11_dpy, "GLX_OML_sync_control") + && GLXExtensionSupported(g_x11_dpy, "GLX_MESA_swap_control") ) x->swap_mode = 1; #endif @@ -465,7 +465,7 @@ static bool gfx_ctx_x_set_video_mode(void *data, Atom net_wm_icon = XInternAtom(g_x11_dpy, "_NET_WM_ICON", False); Atom cardinal = XInternAtom(g_x11_dpy, "CARDINAL", False); settings_t *settings = config_get_ptr(); - unsigned opacity = settings->uints.video_window_opacity + unsigned opacity = settings->uints.video_window_opacity * ((unsigned)-1 / 100.0); bool disable_composition = settings->bools.video_disable_composition; bool show_decorations = settings->bools.video_window_show_decorations; @@ -593,7 +593,7 @@ static bool gfx_ctx_x_set_video_mode(void *data, if (!show_decorations) { - /* We could have just set _NET_WM_WINDOW_TYPE_DOCK instead, + /* We could have just set _NET_WM_WINDOW_TYPE_DOCK instead, * but that removes the window from any taskbar/panel, * so we are forced to use the old motif hints method. */ Hints hints; diff --git a/gfx/gfx_widgets.c b/gfx/gfx_widgets.c index 0d50578e625..b54d4a38c86 100644 --- a/gfx/gfx_widgets.c +++ b/gfx/gfx_widgets.c @@ -201,6 +201,7 @@ void gfx_widgets_msg_queue_push( if (!msg_widget) { const char *title = msg; + size_t title_length = strlen(title); msg_widget = (disp_widget_msg_t*)malloc(sizeof(*msg_widget)); @@ -242,7 +243,7 @@ void gfx_widgets_msg_queue_push( { title = msg_widget->msg = strdup(task->title); msg_widget->msg_new = strdup(title); - msg_widget->msg_len = strlen(title); + msg_widget->msg_len = title_length; if (!string_is_empty(task->error)) msg_widget->flags |= DISPWIDG_FLAG_TASK_ERROR; @@ -271,7 +272,6 @@ void gfx_widgets_msg_queue_push( /* Compute rect width, wrap if necessary */ /* Single line text > two lines text > two lines * text with expanded width */ - size_t title_length = strlen(title); char *msg = NULL; size_t msg_len = 0; unsigned width = menu_is_alive @@ -303,17 +303,17 @@ void gfx_widgets_msg_queue_push( 100, 2); msg_widget->text_height *= 2; + msg_widget->msg_len = strlen(msg); } else { - width = text_width; - strlcpy(msg, title, msg_len); + width = text_width; + msg_widget->msg_len = strlcpy(msg, title, msg_len); } - msg_widget->msg = msg; - msg_widget->msg_len = strlen(msg); - msg_widget->width = width + - p_dispwidget->simple_widget_padding / 2; + msg_widget->msg = msg; + msg_widget->width = width + + p_dispwidget->simple_widget_padding / 2; } fifo_write(&p_dispwidget->msg_queue, @@ -1104,8 +1104,7 @@ static int gfx_widgets_draw_indicator( width = font_driver_get_message_width( p_dispwidget->gfx_widget_fonts.regular.font, - txt, - strlen(txt), 1.0f) + txt, strlen(txt), 1.0f) + p_dispwidget->simple_widget_padding * 2; gfx_display_draw_quad( @@ -1620,23 +1619,22 @@ void gfx_widgets_frame(void *data) || core_status_msg_show ) { - const char *text = *p_dispwidget->gfx_widgets_status_text == '\0' + const char *txt = *p_dispwidget->gfx_widgets_status_text == '\0' ? msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE) : p_dispwidget->gfx_widgets_status_text; - int text_width = font_driver_get_message_width( + int txt_width = font_driver_get_message_width( p_dispwidget->gfx_widget_fonts.regular.font, - text, - strlen(text), 1.0f); - int total_width = text_width + txt, strlen(txt), 1.0f); + int total_width = txt_width + p_dispwidget->simple_widget_padding * 2; - int status_text_x = top_right_x_advance - - p_dispwidget->simple_widget_padding - text_width; + int status_txt_x = top_right_x_advance + - p_dispwidget->simple_widget_padding - txt_width; /* Ensure that left hand side of text does * not bleed off the edge of the screen */ - if (status_text_x < 0) - status_text_x = 0; + if (status_txt_x < 0) + status_txt_x = 0; gfx_display_set_alpha(p_dispwidget->backdrop_orig, DEFAULT_BACKDROP); @@ -1645,7 +1643,8 @@ void gfx_widgets_frame(void *data) userdata, video_width, video_height, - top_right_x_advance - total_width, 0, + top_right_x_advance - total_width, + 0, total_width, p_dispwidget->simple_widget_height, video_width, @@ -1655,8 +1654,8 @@ void gfx_widgets_frame(void *data) ); gfx_widgets_draw_text(&p_dispwidget->gfx_widget_fonts.regular, - text, - status_text_x, + txt, + status_txt_x, p_dispwidget->simple_widget_height / 2.0f + p_dispwidget->gfx_widget_fonts.regular.line_centre_offset, video_width, video_height, @@ -1887,7 +1886,6 @@ static void gfx_widgets_context_reset( /* Load textures */ /* Icons */ for (i = 0; i < MENU_WIDGETS_ICON_LAST; i++) - { gfx_display_reset_textures_list( gfx_widgets_icons_names[i], p_dispwidget->monochrome_png_path, @@ -1895,7 +1893,6 @@ static void gfx_widgets_context_reset( TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL); - } /* Message queue */ gfx_display_reset_textures_list(