More standardization of local len variables

This commit is contained in:
LibretroAdmin 2025-01-07 03:20:39 +01:00
parent fc48ecaa1d
commit 839b7654db
6 changed files with 34 additions and 32 deletions

View File

@ -273,10 +273,10 @@ static void frontend_darwin_get_name(char *s, size_t len)
if (uname(&buffer) == 0) if (uname(&buffer) == 0)
strlcpy(s, buffer.machine, len); strlcpy(s, buffer.machine, len);
#elif defined(OSX) #elif defined(OSX)
size_t length = 0; size_t _len = 0;
sysctlbyname("hw.model", NULL, &length, NULL, 0); sysctlbyname("hw.model", NULL, &_len, NULL, 0);
if (length) if (_len)
sysctlbyname("hw.model", s, &length, NULL, 0); sysctlbyname("hw.model", s, &_len, NULL, 0);
#endif #endif
} }

View File

@ -107,11 +107,11 @@ static void frontend_dos_get_env_settings(int *argc, char *argv[],
static void frontend_dos_exec(const char *path, bool should_load_game) static void frontend_dos_exec(const char *path, bool should_load_game)
{ {
char *newargv[] = { NULL, NULL }; char *newargv[] = { NULL, NULL };
size_t len = strlen(path); size_t _len = strlen(path);
newargv[0] = (char*)malloc(len); newargv[0] = (char*)malloc(_len);
strlcpy(newargv[0], path, len); strlcpy(newargv[0], path, _len);
execv(path, newargv); execv(path, newargv);
} }

View File

@ -2353,11 +2353,11 @@ static bool frontend_unix_set_fork(enum frontend_fork fork_mode)
static void frontend_unix_exec(const char *path, bool should_load_content) static void frontend_unix_exec(const char *path, bool should_load_content)
{ {
char *newargv[] = { NULL, NULL }; char *newargv[] = { NULL, NULL };
size_t len = strlen(path); size_t _len = strlen(path);
newargv[0] = (char*)malloc(len); newargv[0] = (char*)malloc(_len);
strlcpy(newargv[0], path, len); strlcpy(newargv[0], path, _len);
execv(path, newargv); execv(path, newargv);
} }

View File

@ -1325,13 +1325,13 @@ static LRESULT CALLBACK wnd_proc_common_dinput_internal(HWND hwnd,
if (gcs) if (gcs)
{ {
int i; int i;
wchar_t wstr[4]={0,}; wchar_t wstr[4] = {0,};
int len1 = ImmGetCompositionStringW(hIMC, gcs, wstr, 4); LONG _len = ImmGetCompositionStringW(hIMC, gcs, wstr, 4);
wstr[2] = wstr[1]; wstr[2] = wstr[1];
wstr[1] = 0; wstr[1] = 0;
if ((len1 <= 0) || (len1 > 4)) if ((_len <= 0) || (_len > 4))
break; break;
for (i = 0; i < len1; i = i + 2) for (i = 0; i < _len; i = i + 2)
{ {
size_t __len; size_t __len;
char *utf8 = utf16_to_utf8_string_alloc(wstr+i); char *utf8 = utf16_to_utf8_string_alloc(wstr+i);
@ -1373,8 +1373,10 @@ static LRESULT CALLBACK wnd_proc_common_dinput_internal(HWND hwnd,
keysym |= 0x80; keysym |= 0x80;
/* tell the driver about shift and alt key events */ /* tell the driver about shift and alt key events */
if (keysym == 0x2A/*DIK_LSHIFT*/ || keysym == 0x36/*DIK_RSHIFT*/ if ( keysym == 0x2A/*DIK_LSHIFT*/
|| keysym == 0x38/*DIK_LMENU*/ || keysym == 0xB8/*DIK_RMENU*/) || keysym == 0x36/*DIK_RSHIFT*/
|| keysym == 0x38/*DIK_LMENU*/
|| keysym == 0xB8/*DIK_RMENU*/)
{ {
void* input_data = (void*)(LONG_PTR)GetWindowLongPtr(main_window.hwnd, GWLP_USERDATA); void* input_data = (void*)(LONG_PTR)GetWindowLongPtr(main_window.hwnd, GWLP_USERDATA);
if (input_data && dinput_handle_message(input_data, if (input_data && dinput_handle_message(input_data,
@ -2173,21 +2175,21 @@ static void win32_localize_menu(HMENU menu)
/* Append localized name, tab character, and Shortcut Key */ /* Append localized name, tab character, and Shortcut Key */
if (meta_key_name && string_is_not_equal(meta_key_name, "nul")) if (meta_key_name && string_is_not_equal(meta_key_name, "nul"))
{ {
size_t len1 = strlen(new_label); size_t _len = strlen(new_label);
size_t buf_size = len1 + __len + 2; size_t buf_size = _len + __len + 2;
new_label_text = (char*)malloc(buf_size); new_label_text = (char*)malloc(buf_size);
if (new_label_text) if (new_label_text)
{ {
size_t _len; size_t __len;
new_label2 = new_label_text; new_label2 = new_label_text;
_len = strlcpy(new_label_text, new_label, __len = strlcpy(new_label_text, new_label,
buf_size); buf_size);
new_label_text[ _len] = '\t'; new_label_text[ __len] = '\t';
new_label_text[++_len] = '\0'; new_label_text[++__len] = '\0';
strlcpy(new_label_text + _len, meta_key_name, buf_size - _len); strlcpy(new_label_text + __len, meta_key_name, buf_size - __len);
/* Make first character of shortcut name uppercase */ /* Make first character of shortcut name uppercase */
new_label_text[len1 + 1] = toupper(new_label_text[len1 + 1]); new_label_text[_len + 1] = toupper(new_label_text[_len + 1]);
} }
} }

View File

@ -813,13 +813,13 @@ bool x11_connect(void)
void x11_update_title(void *data) void x11_update_title(void *data)
{ {
size_t len; size_t _len;
char title[128]; char title[128];
title[0] = '\0'; title[0] = '\0';
len = video_driver_get_window_title(title, sizeof(title)); _len = video_driver_get_window_title(title, sizeof(title));
if (title[0]) if (title[0])
XChangeProperty(g_x11_dpy, g_x11_win, XA_WM_NAME, XA_STRING, XChangeProperty(g_x11_dpy, g_x11_win, XA_WM_NAME, XA_STRING,
8, PropModeReplace, (const unsigned char*)title, len); 8, PropModeReplace, (const unsigned char*)title, _len);
} }
bool x11_input_ctx_new(bool true_full) bool x11_input_ctx_new(bool true_full)

View File

@ -122,14 +122,14 @@ static void osmesa_fifo_accept(gfx_ctx_osmesa_data_t *osmesa)
static void osmesa_fifo_write(gfx_ctx_osmesa_data_t *osmesa) static void osmesa_fifo_write(gfx_ctx_osmesa_data_t *osmesa)
{ {
int i; int i;
size_t len = osmesa->width * osmesa->pixsize; size_t _len = osmesa->width * osmesa->pixsize;
if (osmesa->client < 0) if (osmesa->client < 0)
return; return;
for (i = osmesa->height -1; i >= 0; --i) for (i = osmesa->height -1; i >= 0; --i)
{ {
int res = send(osmesa->client, osmesa->screen + i * len, len, MSG_NOSIGNAL); int res = send(osmesa->client, osmesa->screen + i * _len, _len, MSG_NOSIGNAL);
if (res < 0) if (res < 0)
{ {