Skip to content

Commit

Permalink
More standardization of local len variables
Browse files Browse the repository at this point in the history
  • Loading branch information
LibretroAdmin committed Jan 7, 2025
1 parent fc48eca commit 839b765
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 32 deletions.
8 changes: 4 additions & 4 deletions frontend/drivers/platform_darwin.m
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,10 @@ static void frontend_darwin_get_name(char *s, size_t len)
if (uname(&buffer) == 0)
strlcpy(s, buffer.machine, len);
#elif defined(OSX)
size_t length = 0;
sysctlbyname("hw.model", NULL, &length, NULL, 0);
if (length)
sysctlbyname("hw.model", s, &length, NULL, 0);
size_t _len = 0;
sysctlbyname("hw.model", NULL, &_len, NULL, 0);
if (_len)
sysctlbyname("hw.model", s, &_len, NULL, 0);
#endif
}

Expand Down
6 changes: 3 additions & 3 deletions frontend/drivers/platform_dos.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
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);
}
Expand Down
6 changes: 3 additions & 3 deletions frontend/drivers/platform_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
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);
}
Expand Down
34 changes: 18 additions & 16 deletions gfx/common/win32_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1325,13 +1325,13 @@ static LRESULT CALLBACK wnd_proc_common_dinput_internal(HWND hwnd,
if (gcs)
{
int i;
wchar_t wstr[4]={0,};
int len1 = ImmGetCompositionStringW(hIMC, gcs, wstr, 4);
wstr[2] = wstr[1];
wstr[1] = 0;
if ((len1 <= 0) || (len1 > 4))
wchar_t wstr[4] = {0,};
LONG _len = ImmGetCompositionStringW(hIMC, gcs, wstr, 4);
wstr[2] = wstr[1];
wstr[1] = 0;
if ((_len <= 0) || (_len > 4))
break;
for (i = 0; i < len1; i = i + 2)
for (i = 0; i < _len; i = i + 2)
{
size_t __len;
char *utf8 = utf16_to_utf8_string_alloc(wstr+i);
Expand Down Expand Up @@ -1373,8 +1373,10 @@ static LRESULT CALLBACK wnd_proc_common_dinput_internal(HWND hwnd,
keysym |= 0x80;

/* tell the driver about shift and alt key events */
if (keysym == 0x2A/*DIK_LSHIFT*/ || keysym == 0x36/*DIK_RSHIFT*/
|| keysym == 0x38/*DIK_LMENU*/ || keysym == 0xB8/*DIK_RMENU*/)
if ( keysym == 0x2A/*DIK_LSHIFT*/
|| keysym == 0x36/*DIK_RSHIFT*/
|| keysym == 0x38/*DIK_LMENU*/
|| keysym == 0xB8/*DIK_RMENU*/)
{
void* input_data = (void*)(LONG_PTR)GetWindowLongPtr(main_window.hwnd, GWLP_USERDATA);
if (input_data && dinput_handle_message(input_data,
Expand Down Expand Up @@ -2173,21 +2175,21 @@ static void win32_localize_menu(HMENU menu)
/* Append localized name, tab character, and Shortcut Key */
if (meta_key_name && string_is_not_equal(meta_key_name, "nul"))
{
size_t len1 = strlen(new_label);
size_t buf_size = len1 + __len + 2;
size_t _len = strlen(new_label);
size_t buf_size = _len + __len + 2;
new_label_text = (char*)malloc(buf_size);

if (new_label_text)
{
size_t _len;
size_t __len;
new_label2 = new_label_text;
_len = strlcpy(new_label_text, new_label,
__len = strlcpy(new_label_text, new_label,
buf_size);
new_label_text[ _len] = '\t';
new_label_text[++_len] = '\0';
strlcpy(new_label_text + _len, meta_key_name, buf_size - _len);
new_label_text[ __len] = '\t';
new_label_text[++__len] = '\0';
strlcpy(new_label_text + __len, meta_key_name, buf_size - __len);
/* 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]);
}
}

Expand Down
8 changes: 4 additions & 4 deletions gfx/common/x11_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -813,13 +813,13 @@ bool x11_connect(void)

void x11_update_title(void *data)
{
size_t len;
size_t _len;
char title[128];
title[0] = '\0';
len = video_driver_get_window_title(title, sizeof(title));
title[0] = '\0';
_len = video_driver_get_window_title(title, sizeof(title));
if (title[0])
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)
Expand Down
4 changes: 2 additions & 2 deletions gfx/drivers_context/osmesa_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
int i;
size_t len = osmesa->width * osmesa->pixsize;
size_t _len = osmesa->width * osmesa->pixsize;

if (osmesa->client < 0)
return;

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)
{
Expand Down

0 comments on commit 839b765

Please sign in to comment.