Skip to content

Commit

Permalink
Standardize len variables - argument should always be named 'len',
Browse files Browse the repository at this point in the history
while local len variables should have '_' prefix
  • Loading branch information
LibretroAdmin committed Jan 13, 2025
1 parent e081bde commit 47d8883
Show file tree
Hide file tree
Showing 20 changed files with 139 additions and 145 deletions.
2 changes: 1 addition & 1 deletion audio/drivers/pulse.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ static void stream_state_cb(pa_stream *s, void *data)
}
}

static void stream_request_cb(pa_stream *s, size_t length, void *data)
static void stream_request_cb(pa_stream *s, size_t len, void *data)
{
pa_t *pa = (pa_t*)data;
pa_threaded_mainloop_signal(pa->mainloop, 0);
Expand Down
10 changes: 5 additions & 5 deletions core_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ static core_info_state_t core_info_st = {
/* JSON Handlers START */

static bool CCJSONObjectMemberHandler(void *context,
const char *pValue, size_t length)
const char *pValue, size_t len)
{
CCJSONContext *pCtx = (CCJSONContext *)context;

if (length)
if (len)
{
switch (pCtx->array_depth)
{
Expand Down Expand Up @@ -262,12 +262,12 @@ static bool CCJSONObjectMemberHandler(void *context,
}

static bool CCJSONStringHandler(void *context,
const char *pValue, size_t length)
const char *pValue, size_t len)
{
CCJSONContext *pCtx = (CCJSONContext*)context;

if ( pCtx->current_string_val
&& length
&& len
&& !string_is_empty(pValue))
{
if (*pCtx->current_string_val)
Expand All @@ -290,7 +290,7 @@ static bool CCJSONStringHandler(void *context,
}

static bool CCJSONNumberHandler(void *context,
const char *pValue, size_t length)
const char *pValue, size_t len)
{
CCJSONContext *pCtx = (CCJSONContext*)context;

Expand Down
22 changes: 11 additions & 11 deletions cores/libretro-net-retropad/net_retropad_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,15 @@ static bool ITifJSONObjectEndHandler(void* context)
return true;
}

static bool ITifJSONObjectMemberHandler(void* context, const char *pValue, size_t length)
static bool ITifJSONObjectMemberHandler(void* context, const char *pValue, size_t len)
{
ITifJSONContext *pCtx = (ITifJSONContext*)context;

/* something went wrong */
if (pCtx->current_entry_str_val)
return false;

if (length)
if (len)
{
if (string_is_equal(pValue, "expected_button"))
pCtx->current_entry_uint_val = &pCtx->expected_button;
Expand All @@ -298,11 +298,11 @@ static bool ITifJSONObjectMemberHandler(void* context, const char *pValue, size_
return true;
}

static bool ITifJSONNumberHandler(void* context, const char *pValue, size_t length)
static bool ITifJSONNumberHandler(void* context, const char *pValue, size_t len)
{
ITifJSONContext *pCtx = (ITifJSONContext*)context;

if (pCtx->current_entry_uint_val && length && !string_is_empty(pValue))
if (pCtx->current_entry_uint_val && len && !string_is_empty(pValue))
*pCtx->current_entry_uint_val = string_to_unsigned(pValue);
/* ignore unknown members */

Expand All @@ -311,11 +311,11 @@ static bool ITifJSONNumberHandler(void* context, const char *pValue, size_t leng
return true;
}

static bool ITifJSONStringHandler(void* context, const char *pValue, size_t length)
static bool ITifJSONStringHandler(void* context, const char *pValue, size_t len)
{
ITifJSONContext *pCtx = (ITifJSONContext*)context;

if (pCtx->current_entry_str_val && length && !string_is_empty(pValue))
if (pCtx->current_entry_str_val && len && !string_is_empty(pValue))
{
if (*pCtx->current_entry_str_val)
free(*pCtx->current_entry_str_val);
Expand Down Expand Up @@ -728,7 +728,7 @@ static void retropad_update_input(void)
pointer_y = (int16_t)state;
}
}

/* Do not send extra descriptor state - RA side is not prepared to receive it */
if (i>1)
continue;
Expand Down Expand Up @@ -1035,7 +1035,7 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void)
sensor_item_colors[median_index] = (uint16_t)(fabsf(32*4*value)) << 11;
}
}

/* Button values for sensor test screen, since they do not follow any pattern, it is *
* provided as a direct list. */
if (mouse_type == NETRETROPAD_MOUSE)
Expand All @@ -1062,7 +1062,7 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void)

offset = DESC_OFFSET(&mouse, 0, 0, RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP);
sensor_item_colors[86] = mouse.value[offset] ? 0xA000 : 0x0000;

offset = DESC_OFFSET(&mouse, 0, 0, RETRO_DEVICE_ID_MOUSE_BUTTON_4);
sensor_item_colors[88] = mouse.value[offset] ? 0xA000 : 0x0000;

Expand Down Expand Up @@ -1094,7 +1094,7 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void)

offset = DESC_OFFSET(&lightgun, 0, 0, RETRO_DEVICE_ID_LIGHTGUN_SELECT);
sensor_item_colors[76] = lightgun.value[offset] ? 0xA000 : 0x0000;

offset = DESC_OFFSET(&lightgun, 0, 0, RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN);
sensor_item_colors[77] = lightgun.value[offset] ? 0xA000 : 0x0000;

Expand Down Expand Up @@ -1390,7 +1390,7 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void)
pointer_prev_y = pointer_y_coord;
}
}

NETRETROPAD_CORE_PREFIX(video_cb)(frame_buf, 320, 240, 640);
retro_sleep(4);
}
Expand Down
12 changes: 6 additions & 6 deletions disk_index_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ typedef struct
char *image_path;
} DCifJSONContext;

static bool DCifJSONObjectMemberHandler(void* context, const char *pValue, size_t length)
static bool DCifJSONObjectMemberHandler(void* context, const char *pValue, size_t len)
{
DCifJSONContext *pCtx = (DCifJSONContext*)context;

/* something went wrong */
if (pCtx->current_entry_str_val)
return false;

if (length)
if (len)
{
if (string_is_equal(pValue, "image_index"))
pCtx->current_entry_uint_val = &pCtx->image_index;
Expand All @@ -63,11 +63,11 @@ static bool DCifJSONObjectMemberHandler(void* context, const char *pValue, size_
return true;
}

static bool DCifJSONNumberHandler(void* context, const char *pValue, size_t length)
static bool DCifJSONNumberHandler(void* context, const char *pValue, size_t len)
{
DCifJSONContext *pCtx = (DCifJSONContext*)context;

if (pCtx->current_entry_uint_val && length && !string_is_empty(pValue))
if (pCtx->current_entry_uint_val && len && !string_is_empty(pValue))
*pCtx->current_entry_uint_val = string_to_unsigned(pValue);
/* ignore unknown members */

Expand All @@ -76,11 +76,11 @@ static bool DCifJSONNumberHandler(void* context, const char *pValue, size_t leng
return true;
}

static bool DCifJSONStringHandler(void* context, const char *pValue, size_t length)
static bool DCifJSONStringHandler(void* context, const char *pValue, size_t len)
{
DCifJSONContext *pCtx = (DCifJSONContext*)context;

if (pCtx->current_entry_str_val && length && !string_is_empty(pValue))
if (pCtx->current_entry_str_val && len && !string_is_empty(pValue))
{
free(*pCtx->current_entry_str_val);

Expand Down
7 changes: 3 additions & 4 deletions input/common/wayland_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -996,8 +996,7 @@ static void wl_data_device_handle_drop(void *data,
FILE *stream;
int pipefd[2];
void *buffer;
size_t length;
size_t _len = 0;
size_t __len, _len = 0;
ssize_t read = 0;
char *line = NULL;
char file_list[512][512] = { 0 };
Expand All @@ -1012,7 +1011,7 @@ static void wl_data_device_handle_drop(void *data,

pipe(pipefd);

buffer = wayland_data_offer_receive(wl->input.dpy, offer_data->offer, &length, FILE_MIME, false);
buffer = wayland_data_offer_receive(wl->input.dpy, offer_data->offer, &__len, FILE_MIME, false);

close(pipefd[1]);
close(pipefd[0]);
Expand All @@ -1023,7 +1022,7 @@ static void wl_data_device_handle_drop(void *data,
wl_data_offer_destroy(offer_data->offer);
free(offer_data);

if (!(stream = fmemopen(buffer, length, "r")))
if (!(stream = fmemopen(buffer, __len, "r")))
{
RARCH_WARN("[Wayland]: Failed to open DnD buffer\n");
return;
Expand Down
12 changes: 6 additions & 6 deletions input/drivers/test_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ static bool KTifJSONObjectEndHandler(void* context)
return true;
}

static bool KTifJSONObjectMemberHandler(void* context, const char *pValue, size_t length)
static bool KTifJSONObjectMemberHandler(void* context, const char *pValue, size_t len)
{
KTifJSONContext *pCtx = (KTifJSONContext*)context;

/* something went wrong */
if (pCtx->current_entry_str_val)
return false;

if (length)
if (len)
{
if (string_is_equal(pValue, "frame"))
pCtx->current_entry_uint_val = &pCtx->frame;
Expand All @@ -149,11 +149,11 @@ static bool KTifJSONObjectMemberHandler(void* context, const char *pValue, size_
return true;
}

static bool KTifJSONNumberHandler(void* context, const char *pValue, size_t length)
static bool KTifJSONNumberHandler(void* context, const char *pValue, size_t len)
{
KTifJSONContext *pCtx = (KTifJSONContext*)context;

if (pCtx->current_entry_uint_val && length && !string_is_empty(pValue))
if (pCtx->current_entry_uint_val && len && !string_is_empty(pValue))
*pCtx->current_entry_uint_val = string_to_unsigned(pValue);
/* ignore unknown members */

Expand All @@ -162,11 +162,11 @@ static bool KTifJSONNumberHandler(void* context, const char *pValue, size_t leng
return true;
}

static bool KTifJSONStringHandler(void* context, const char *pValue, size_t length)
static bool KTifJSONStringHandler(void* context, const char *pValue, size_t len)
{
KTifJSONContext *pCtx = (KTifJSONContext*)context;

if (pCtx->current_entry_str_val && length && !string_is_empty(pValue))
if (pCtx->current_entry_str_val && len && !string_is_empty(pValue))
{
if (*pCtx->current_entry_str_val)
free(*pCtx->current_entry_str_val);
Expand Down
12 changes: 6 additions & 6 deletions input/drivers_joypad/test_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ static bool JTifJSONObjectEndHandler(void* context)
return true;
}

static bool JTifJSONObjectMemberHandler(void* context, const char *pValue, size_t length)
static bool JTifJSONObjectMemberHandler(void* context, const char *pValue, size_t len)
{
JTifJSONContext *pCtx = (JTifJSONContext*)context;

/* something went wrong */
if (pCtx->current_entry_str_val)
return false;

if (length)
if (len)
{
if (string_is_equal(pValue, "frame"))
pCtx->current_entry_uint_val = &pCtx->frame;
Expand All @@ -149,11 +149,11 @@ static bool JTifJSONObjectMemberHandler(void* context, const char *pValue, size_
return true;
}

static bool JTifJSONNumberHandler(void* context, const char *pValue, size_t length)
static bool JTifJSONNumberHandler(void* context, const char *pValue, size_t len)
{
JTifJSONContext *pCtx = (JTifJSONContext*)context;

if (pCtx->current_entry_uint_val && length && !string_is_empty(pValue))
if (pCtx->current_entry_uint_val && len && !string_is_empty(pValue))
*pCtx->current_entry_uint_val = string_to_unsigned(pValue);
/* ignore unknown members */

Expand All @@ -162,11 +162,11 @@ static bool JTifJSONNumberHandler(void* context, const char *pValue, size_t leng
return true;
}

static bool JTifJSONStringHandler(void* context, const char *pValue, size_t length)
static bool JTifJSONStringHandler(void* context, const char *pValue, size_t len)
{
JTifJSONContext *pCtx = (JTifJSONContext*)context;

if (pCtx->current_entry_str_val && length && !string_is_empty(pValue))
if (pCtx->current_entry_str_val && len && !string_is_empty(pValue))
{
if (*pCtx->current_entry_str_val)
free(*pCtx->current_entry_str_val);
Expand Down
9 changes: 5 additions & 4 deletions input/drivers_joypad/udev_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,17 +520,18 @@ static void udev_joypad_poll(void)

for (p = 0; p < MAX_USERS; p++)
{
int i, len;
int i;
ssize_t _len;
struct input_event events[32];
struct udev_joypad *pad = &udev_pads[p];

if (pad->fd < 0)
continue;

while ((len = read(pad->fd, events, sizeof(events))) > 0)
while ((_len = read(pad->fd, events, sizeof(events))) > 0)
{
len /= sizeof(*events);
for (i = 0; i < len; i++)
_len /= sizeof(*events);
for (i = 0; i < _len; i++)
{
uint16_t type = events[i].type;
uint16_t code = events[i].code;
Expand Down
4 changes: 2 additions & 2 deletions input/include/hid_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ struct hid_driver
const char *(*name)(void *handle, unsigned pad);
const char *ident;
void (*send_control)(void *handle, uint8_t *buf, size_t size);
int32_t (*set_report)(void *handle, uint8_t report_type, uint8_t report_id, uint8_t *data, size_t length);
int32_t (*get_report)(void *handle, uint8_t report_type, uint8_t report_id, uint8_t *data, size_t length);
int32_t (*set_report)(void *handle, uint8_t report_type, uint8_t report_id, uint8_t *data, size_t len);
int32_t (*get_report)(void *handle, uint8_t report_type, uint8_t report_id, uint8_t *data, size_t len);
int32_t (*set_idle)(void *handle, uint8_t amount);
int32_t (*set_protocol)(void *handle, uint8_t protocol);
int32_t (*read)(void *handle, void *buf, size_t size);
Expand Down
10 changes: 5 additions & 5 deletions libretro-common/file/archive_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ static struct string_list *file_archive_filename_split(const char *path)
*/
int file_archive_compressed_read(
const char * path, void **buf,
const char* optional_filename, int64_t *length)
const char* optional_filename, int64_t *len)
{
const struct
file_archive_file_backend *backend = NULL;
Expand All @@ -540,7 +540,7 @@ int file_archive_compressed_read(
*/
if (optional_filename && path_is_valid(optional_filename))
{
*length = 0;
*len = 0;
return 1;
}

Expand All @@ -555,17 +555,17 @@ int file_archive_compressed_read(
{
/* could not extract string and substring. */
string_list_free(str_list);
*length = 0;
*len = 0;
return 0;
}

backend = file_archive_get_file_backend(str_list->elems[0].data);
*length = backend->compressed_file_read(str_list->elems[0].data,
*len = backend->compressed_file_read(str_list->elems[0].data,
str_list->elems[1].data, buf, optional_filename);

string_list_free(str_list);

if (*length != -1)
if (*len != -1)
return 1;

return 0;
Expand Down
4 changes: 2 additions & 2 deletions libretro-common/file/archive_file_7z.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,9 @@ static int sevenzip_parse_file_iterate_step(void *context,
}

static uint32_t sevenzip_stream_crc32_calculate(uint32_t crc,
const uint8_t *data, size_t length)
const uint8_t *data, size_t len)
{
return encoding_crc32(crc, data, length);
return encoding_crc32(crc, data, len);
}

const struct file_archive_file_backend sevenzip_backend = {
Expand Down
Loading

0 comments on commit 47d8883

Please sign in to comment.