From 9da7af46c39a0b8fc2ccc11a762718c7fbe47b1c Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Wed, 15 Jan 2025 16:04:25 +0100 Subject: [PATCH] len variable/argument name standardization --- gfx/common/d3dcompiler_common.c | 10 +-- gfx/common/d3dcompiler_common.h | 2 +- input/drivers_hid/wiiu_hid.c | 28 +++---- libretro-common/formats/json/rjson.c | 4 +- libretro-common/include/formats/rjson.h | 2 +- libretro-common/streams/stdin_stream.c | 26 ++---- libretro-common/streams/trans_stream.c | 8 +- save.c | 8 +- state_manager.c | 32 ++++---- tasks/task_save.c | 105 +++++++++++------------- verbosity.c | 18 ++-- verbosity.h | 2 +- 12 files changed, 113 insertions(+), 132 deletions(-) diff --git a/gfx/common/d3dcompiler_common.c b/gfx/common/d3dcompiler_common.c index 8ea35ad30354..1adbe3a15d1b 100644 --- a/gfx/common/d3dcompiler_common.c +++ b/gfx/common/d3dcompiler_common.c @@ -115,7 +115,7 @@ HRESULT WINAPI } #endif -bool d3d_compile(const char* src, size_t size, +bool d3d_compile(const char* src, size_t len, LPCSTR src_name, LPCSTR entrypoint, LPCSTR target, D3DBlob* out) { D3DBlob error_msg; @@ -125,18 +125,18 @@ bool d3d_compile(const char* src, size_t size, UINT compileflags = 0; #endif - if (!size) - size = strlen(src); + if (!len) + len = strlen(src); if (FAILED(D3DCompile( - src, size, src_name, NULL, NULL, + src, len, src_name, NULL, NULL, entrypoint, target, compileflags, 0, out, &error_msg))) { if (error_msg) { const char* msg = (const char*)error_msg->lpVtbl->GetBufferPointer(error_msg); RARCH_ERR("D3DCompile failed :\n%s\n", msg); - /* Place a breakpoint here, if you want, + /* Place a breakpoint here, if you want, to see shader compilation issues */ Release(error_msg); } diff --git a/gfx/common/d3dcompiler_common.h b/gfx/common/d3dcompiler_common.h index 292cf13fe6ac..3c4c4ba758e4 100644 --- a/gfx/common/d3dcompiler_common.h +++ b/gfx/common/d3dcompiler_common.h @@ -24,7 +24,7 @@ typedef ID3DBlob* D3DBlob; -bool d3d_compile(const char* src, size_t size, +bool d3d_compile(const char* src, size_t len, LPCSTR src_name, LPCSTR entrypoint, LPCSTR target, D3DBlob* out); bool d3d_compile_from_file(LPCWSTR filename, LPCSTR entrypoint, LPCSTR target, D3DBlob* out); diff --git a/input/drivers_hid/wiiu_hid.c b/input/drivers_hid/wiiu_hid.c index 285bcb9e0a47..821863244170 100644 --- a/input/drivers_hid/wiiu_hid.c +++ b/input/drivers_hid/wiiu_hid.c @@ -170,11 +170,11 @@ static int16_t wiiu_hid_joypad_state( const uint32_t joyaxis = (binds[i].joyaxis != AXIS_NONE) ? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis; if ( - (uint16_t)joykey != NO_BTN + (uint16_t)joykey != NO_BTN && pad->iface->button && pad->iface->button(pad->connection, (uint16_t)joykey)) ret |= ( 1 << i); else if (joyaxis != AXIS_NONE && pad->iface->get_axis && - ((float)abs(pad->iface->get_axis(pad->connection, joyaxis)) + ((float)abs(pad->iface->get_axis(pad->connection, joyaxis)) / 0x8000) > joypad_info->axis_threshold) ret |= (1 << i); } @@ -194,12 +194,11 @@ static bool wiiu_hid_joypad_rumble(void *data, unsigned slot, return false; } -static void *wiiu_hid_alloc_zeroed(size_t alignment, size_t size) +static void *wiiu_hid_alloc_zeroed(size_t alignment, size_t len) { - void *result = memalign(alignment, size); + void *result = memalign(alignment, len); if (result) - memset(result, 0, size); - + memset(result, 0, len); return result; } @@ -663,7 +662,7 @@ static uint8_t wiiu_hid_try_init_driver(wiiu_adapter_t *adapter) adapter->device_name); adapter->pad_driver = entry->iface; - + if (entry->iface->multi_pad) return wiiu_hid_try_init_driver_multi(adapter, entry); @@ -749,7 +748,7 @@ static void wiiu_hid_poll(void *data) synchronized_process_adapters(hid); } -static void wiiu_hid_send_control(void *data, uint8_t *buf, size_t size) +static void wiiu_hid_send_control(void *data, uint8_t *buf, size_t len) { wiiu_adapter_t *adapter = (wiiu_adapter_t *)data; int32_t result; @@ -761,7 +760,7 @@ static void wiiu_hid_send_control(void *data, uint8_t *buf, size_t size) } memset(adapter->tx_buffer, 0, adapter->tx_size); - memcpy(adapter->tx_buffer, buf, size); + memcpy(adapter->tx_buffer, buf, len); /* From testing, HIDWrite returns an error that looks like it's two * int16_t's bitmasked together. For example, one error I saw when trying @@ -848,24 +847,19 @@ static int32_t wiiu_hid_set_protocol(void *data, uint8_t protocol) NULL, NULL); } -static int32_t wiiu_hid_read(void *data, void *buffer, size_t size) +static int32_t wiiu_hid_read(void *data, void *buffer, size_t len) { wiiu_adapter_t *adapter = (wiiu_adapter_t *)data; int32_t result; - if (!adapter) return -1; - - if (size > adapter->rx_size) + if (len > adapter->rx_size) return -1; - - if ((result = HIDRead(adapter->handle, buffer, size, NULL, NULL)) < 0) + if ((result = HIDRead(adapter->handle, buffer, len, NULL, NULL)) < 0) wiiu_hid_report_hid_error("read failed", adapter, result); - return result; } - static void wiiu_hid_init_cachealigned_buffer(int32_t min_size, uint8_t **out_buf_ptr, int32_t *actual_size) { *actual_size = (min_size + 0x3f) & ~0x3f; diff --git a/libretro-common/formats/json/rjson.c b/libretro-common/formats/json/rjson.c index 9c79569bf4dd..3f99178984e3 100644 --- a/libretro-common/formats/json/rjson.c +++ b/libretro-common/formats/json/rjson.c @@ -930,14 +930,14 @@ static int _rjson_buffer_io(void* buf, int len, void *user) return len; } -rjson_t *rjson_open_buffer(const void *buffer, size_t size) +rjson_t *rjson_open_buffer(const void *buffer, size_t len) { rjson_t *json = (rjson_t *)malloc(sizeof(rjson_t) + sizeof(const char *)*2); const char **ud = (const char **)(json + 1); if (!json) return NULL; ud[0] = (const char *)buffer; - ud[1] = ud[0] + size; + ud[1] = ud[0] + len; _rjson_setup(json, _rjson_buffer_io, (void*)ud, sizeof(json->input_buf)); return json; } diff --git a/libretro-common/include/formats/rjson.h b/libretro-common/include/formats/rjson.h index 53623dd17e70..3101955b2c47 100644 --- a/libretro-common/include/formats/rjson.h +++ b/libretro-common/include/formats/rjson.h @@ -67,7 +67,7 @@ struct RFILE; /* Create a new parser instance from various sources */ rjson_t *rjson_open_stream(struct intfstream_internal *stream); rjson_t *rjson_open_rfile(struct RFILE *rfile); -rjson_t *rjson_open_buffer(const void *buffer, size_t size); +rjson_t *rjson_open_buffer(const void *buffer, size_t len); rjson_t *rjson_open_string(const char *string, size_t len); rjson_t *rjson_open_user(rjson_io_t io, void *user_data, int io_block_size); diff --git a/libretro-common/streams/stdin_stream.c b/libretro-common/streams/stdin_stream.c index 80f6e9abd5ac..a0800915fc5b 100644 --- a/libretro-common/streams/stdin_stream.c +++ b/libretro-common/streams/stdin_stream.c @@ -39,13 +39,9 @@ #include #if (defined(_WIN32) && defined(_XBOX)) || defined(__WINRT__) || !defined(__PSL1GHT__) && defined(__PS3__) -size_t read_stdin(char *buf, size_t size) -{ - /* Not implemented. */ - return 0; -} +size_t read_stdin(char *buf, size_t len) { return 0; } /* not implemented */ #elif defined(_WIN32) -size_t read_stdin(char *buf, size_t size) +size_t read_stdin(char *buf, size_t len) { DWORD i; DWORD has_read = 0; @@ -90,7 +86,7 @@ size_t read_stdin(char *buf, size_t size) { has_key = true; echo = true; - avail = size; + avail = len; break; } } @@ -105,8 +101,8 @@ size_t read_stdin(char *buf, size_t size) if (!avail) return 0; - if (avail > size) - avail = size; + if (avail > len) + avail = len; if (!ReadFile(hnd, buf, avail, &has_read, NULL)) return 0; @@ -130,22 +126,18 @@ size_t read_stdin(char *buf, size_t size) return has_read; } #else -size_t read_stdin(char *buf, size_t size) +size_t read_stdin(char *buf, size_t len) { size_t has_read = 0; - - while (size) + while (len) { - ssize_t ret = read(STDIN_FILENO, buf, size); - + ssize_t ret = read(STDIN_FILENO, buf, len); if (ret <= 0) break; - buf += ret; has_read += ret; - size -= ret; + len -= ret; } - return has_read; } #endif diff --git a/libretro-common/streams/trans_stream.c b/libretro-common/streams/trans_stream.c index aecb457b66d1..41132565ce7d 100644 --- a/libretro-common/streams/trans_stream.c +++ b/libretro-common/streams/trans_stream.c @@ -28,8 +28,8 @@ * for the new stream data to be saved * @in : input data * @in_size : input size - * @out : output data - * @out_size : output size + * @s : output data + * @len : output size * @error : (optional) output for error code * * Perform a full transcoding from a source to a destination. @@ -37,7 +37,7 @@ bool trans_stream_trans_full( struct trans_stream_backend *backend, void **data, const uint8_t *in, uint32_t in_size, - uint8_t *out, uint32_t out_size, + uint8_t *s, uint32_t len, enum trans_stream_error *error) { void *rdata; @@ -57,7 +57,7 @@ bool trans_stream_trans_full( } backend->set_in(rdata, in, in_size); - backend->set_out(rdata, out, out_size); + backend->set_out(rdata, s, len); ret = backend->trans(rdata, true, &rd, &wn, error); if (data) diff --git a/save.c b/save.c index d79a494ea593..41e10084fe6c 100644 --- a/save.c +++ b/save.c @@ -152,7 +152,7 @@ static void autosave_thread(void *data) * autosave_new: * @path : path to autosave file * @data : pointer to buffer - * @size : size of @data buffer + * @len : size of @data buffer * @interval : interval at which saves should be performed. * * Create and initialize autosave object. @@ -161,7 +161,7 @@ static void autosave_thread(void *data) * NULL. **/ static autosave_t *autosave_new(const char *path, - const void *data, size_t size, + const void *data, size_t len, unsigned interval, bool compress) { void *buf = NULL; @@ -170,14 +170,14 @@ static autosave_t *autosave_new(const char *path, return NULL; handle->flags = 0; - handle->bufsize = size; + handle->bufsize = len; handle->interval = interval; if (compress) handle->flags |= AUTOSAVE_FLAG_COMPRESS_FILES; handle->retro_buffer = data; handle->path = path; - if (!(buf = malloc(size))) + if (!(buf = malloc(len))) { free(handle); return NULL; diff --git a/state_manager.c b/state_manager.c index 9fb25a9993f6..8b16fa8bc12c 100644 --- a/state_manager.c +++ b/state_manager.c @@ -205,8 +205,8 @@ static size_t state_manager_raw_maxsize(size_t uncomp) */ static void *state_manager_raw_alloc(size_t len, uint16_t uniq) { - size_t len16 = (len + sizeof(uint16_t) - 1) & -sizeof(uint16_t); - uint16_t *ret = (uint16_t*)calloc(len16 + sizeof(uint16_t) * 4 + 16, 1); + size_t _len = (len + sizeof(uint16_t) - 1) & -sizeof(uint16_t); + uint16_t *ret = (uint16_t*)calloc(_len + sizeof(uint16_t) * 4 + 16, 1); if (!ret) return NULL; @@ -222,7 +222,7 @@ static void *state_manager_raw_alloc(size_t len, uint16_t uniq) * * It doesn't make any difference to us, but sacrificing 16 bytes to get * Valgrind happy is worth it. */ - ret[len16/sizeof(uint16_t) + 3] = uniq; + ret[_len / sizeof(uint16_t) + 3] = uniq; return ret; } @@ -270,7 +270,7 @@ static size_t state_manager_raw_compress(const void *src, continue; } - changed = find_same(old16, new16); + changed = find_same(old16, new16); if (changed > UINT16_MAX) changed = UINT16_MAX; @@ -301,8 +301,7 @@ static size_t state_manager_raw_compress(const void *src, * If the given arguments do not match a previous call to * state_manager_raw_compress(), anything at all can happen. */ -static void state_manager_raw_decompress(const void *patch, - size_t patchlen, void *data, size_t datalen) +static void state_manager_raw_decompress(const void *patch, void *data) { uint16_t *out16 = (uint16_t*)data; const uint16_t *patch16 = (const uint16_t*)patch; @@ -473,8 +472,7 @@ static bool state_manager_pop(state_manager_t *state, const void **data) compressed = state->data + start + sizeof(size_t); out = state->thisblock; - state_manager_raw_decompress(compressed, - state->maxcompsize, out, state->blocksize); + state_manager_raw_decompress(compressed, out); state->entries--; return true; @@ -512,8 +510,8 @@ static void state_manager_push_do(state_manager_t *state) if (state->thisblock_valid) { - const uint8_t *oldb, *newb; uint8_t *compressed; + const uint8_t *oldb, *newb; size_t headpos, tailpos, remaining; if (state->capacity < sizeof(size_t) + state->maxcompsize) { RARCH_ERR("State capacity insufficient\n"); @@ -666,14 +664,14 @@ void state_manager_event_deinit( free(rewind_st->state); } - rewind_st->state = NULL; - rewind_st->size = 0; - rewind_st->flags &= ~( - STATE_MGR_REWIND_ST_FLAG_FRAME_IS_REVERSED - | STATE_MGR_REWIND_ST_FLAG_HOTKEY_WAS_CHECKED - | STATE_MGR_REWIND_ST_FLAG_HOTKEY_WAS_PRESSED - | STATE_MGR_REWIND_ST_FLAG_INIT_ATTEMPTED - ); + rewind_st->state = NULL; + rewind_st->size = 0; + rewind_st->flags &= ~( + STATE_MGR_REWIND_ST_FLAG_FRAME_IS_REVERSED + | STATE_MGR_REWIND_ST_FLAG_HOTKEY_WAS_CHECKED + | STATE_MGR_REWIND_ST_FLAG_HOTKEY_WAS_PRESSED + | STATE_MGR_REWIND_ST_FLAG_INIT_ATTEMPTED + ); /* Restore regular (non-rewind) core audio * callbacks if required */ diff --git a/tasks/task_save.c b/tasks/task_save.c index 72f38a901482..d078a9b261dc 100644 --- a/tasks/task_save.c +++ b/tasks/task_save.c @@ -371,19 +371,20 @@ size_t content_get_serialized_size(void) rastate_size_info_t size; return content_get_rastate_size(&size, false); } + size_t content_get_serialized_size_rewind(void) { rastate_size_info_t size; return content_get_rastate_size(&size, true); } -static void content_write_block_header(unsigned char* output, const char* header, size_t size) +static void content_write_block_header(unsigned char* output, const char* header, size_t len) { memcpy(output, header, 4); - output[4] = ((size) & 0xFF); - output[5] = ((size >> 8) & 0xFF); - output[6] = ((size >> 16) & 0xFF); - output[7] = ((size >> 24) & 0xFF); + output[4] = ((len) & 0xFF); + output[5] = ((len >> 8) & 0xFF); + output[6] = ((len >> 16) & 0xFF); + output[7] = ((len >> 24) & 0xFF); } static bool content_write_serialized_state(void* buffer, @@ -523,9 +524,9 @@ static void task_save_handler(retro_task_t *task) if (!state->data) { - size_t size = 0; - state->data = content_get_serialized_data(&size); - state->size = (ssize_t)size; + size_t _len = 0; + state->data = content_get_serialized_data(&_len); + state->size = (ssize_t)_len; } remaining = MIN(state->size - state->written, SAVE_STATE_CHUNK); @@ -608,7 +609,7 @@ static void task_save_handler(retro_task_t *task) * * Create a new task to undo the last save of the content state. **/ -static bool task_push_undo_save_state(const char *path, void *data, size_t size) +static bool task_push_undo_save_state(const char *path, void *data, size_t len) { settings_t *settings; retro_task_t *task = task_init(); @@ -623,7 +624,7 @@ static bool task_push_undo_save_state(const char *path, void *data, size_t size) strlcpy(state->path, path, sizeof(state->path)); state->data = data; - state->size = size; + state->size = len; state->flags |= SAVE_TASK_FLAG_UNDO_SAVE; state->state_slot = settings->ints.state_slot; if (video_st->frame_cache_data && (video_st->frame_cache_data == RETRO_HW_FRAME_BUFFER_VALID)) @@ -829,9 +830,9 @@ static void task_load_handler(retro_task_t *task) task_load_handler_finished(task, state); } -static bool content_load_rastate1(unsigned char* input, size_t size) +static bool content_load_rastate1(unsigned char* input, size_t len) { - unsigned char *stop = input + size; + unsigned char *stop = input + len; bool seen_core = false; #ifdef HAVE_CHEEVOS bool seen_cheevos = false; @@ -934,18 +935,16 @@ static bool content_load_rastate1(unsigned char* input, size_t size) return true; } -bool content_deserialize_state( - const void* serialized_data, size_t serialized_size) +bool content_deserialize_state(const void *s, size_t len) { - if (memcmp(serialized_data, "RASTATE", 7) != 0) + if (memcmp(s, "RASTATE", 7) != 0) { /* old format is just core data, load it directly */ retro_ctx_serialize_info_t serial_info; - serial_info.data_const = serialized_data; - serial_info.size = serialized_size; + serial_info.data_const = s; + serial_info.size = len; if (!core_unserialize(&serial_info)) return false; - #ifdef HAVE_CHEEVOS rcheevos_set_serialized_data(NULL); #endif @@ -963,18 +962,17 @@ bool content_deserialize_state( } else { - unsigned char* input = (unsigned char*)serialized_data; + unsigned char* input = (unsigned char*)s; switch (input[7]) /* version */ { case 1: - if (content_load_rastate1(input, serialized_size)) + if (content_load_rastate1(input, len)) break; /* fall-through intentional */ default: return false; } } - return true; } @@ -1158,7 +1156,7 @@ static void save_state_cb(retro_task_t *task, * * Create a new task to save the content state. **/ -static void task_push_save_state(const char *path, void *data, size_t size, bool autosave) +static void task_push_save_state(const char *path, void *data, size_t len, bool autosave) { settings_t *settings = config_get_ptr(); retro_task_t *task = task_init(); @@ -1170,11 +1168,11 @@ static void task_push_save_state(const char *path, void *data, size_t size, bool strlcpy(state->path, path, sizeof(state->path)); state->data = data; - state->size = size; + state->size = len; /* Don't show OSD messages if we are auto-saving */ if (autosave) - state->flags |= (SAVE_TASK_FLAG_AUTOSAVE | - SAVE_TASK_FLAG_MUTE); + state->flags |= ( SAVE_TASK_FLAG_AUTOSAVE + | SAVE_TASK_FLAG_MUTE); if (settings->bools.savestate_thumbnail_enable) { /* Delay OSD messages and widgets for a few frames @@ -1264,7 +1262,7 @@ static void content_load_and_save_state_cb(retro_task_t *task, * and then save the content state. **/ static void task_push_load_and_save_state(const char *path, void *data, - size_t size, bool load_to_backup_buffer, bool autosave) + size_t len, bool load_to_backup_buffer, bool autosave) { retro_task_t *task = NULL; settings_t *settings = config_get_ptr(); @@ -1285,7 +1283,7 @@ static void task_push_load_and_save_state(const char *path, void *data, strlcpy(state->path, path, sizeof(state->path)); if (load_to_backup_buffer) state->flags |= SAVE_TASK_FLAG_LOAD_TO_BACKUP_BUFF; - state->undo_size = size; + state->undo_size = len; state->undo_data = data; /* Don't show OSD messages if we are auto-saving */ if (autosave) @@ -1337,9 +1335,9 @@ static void task_push_load_and_save_state(const char *path, void *data, **/ bool content_auto_save_state(const char *path) { + size_t _len; settings_t *settings = config_get_ptr(); void *serial_data = NULL; - size_t serial_size; intfstream_t *file = NULL; if (!core_info_current_supports_savestate()) @@ -1349,12 +1347,11 @@ bool content_auto_save_state(const char *path) return false; } - serial_size = core_serialize_size(); - - if (serial_size == 0) + _len = core_serialize_size(); + if (_len == 0) return false; - serial_data = content_get_serialized_data(&serial_size); + serial_data = content_get_serialized_data(&_len); if (!serial_data) return false; @@ -1372,7 +1369,7 @@ bool content_auto_save_state(const char *path) return false; } - if (serial_size != (size_t)intfstream_write(file, serial_data, serial_size)) + if (_len != (size_t)intfstream_write(file, serial_data, _len)) { intfstream_close(file); free(serial_data); @@ -1395,7 +1392,6 @@ bool content_auto_save_state(const char *path) take_screenshot(dir_screenshot, path, true, validfb, false, false); } #endif - return true; } @@ -1410,7 +1406,7 @@ bool content_auto_save_state(const char *path) **/ bool content_save_state(const char *path, bool save_to_disk) { - size_t serial_size; + size_t _len; void *data = NULL; if (!core_info_current_supports_savestate()) @@ -1420,14 +1416,13 @@ bool content_save_state(const char *path, bool save_to_disk) return false; } - serial_size = core_serialize_size(); - - if (serial_size == 0) + _len = core_serialize_size(); + if (_len == 0) return false; if (!save_state_in_background) { - if (!(data = content_get_serialized_data(&serial_size))) + if (!(data = content_get_serialized_data(&_len))) { RARCH_ERR("[State]: %s \"%s\".\n", msg_hash_to_str(MSG_FAILED_TO_SAVE_STATE_TO), @@ -1438,7 +1433,7 @@ bool content_save_state(const char *path, bool save_to_disk) RARCH_LOG("[State]: %s \"%s\", %u %s.\n", msg_hash_to_str(MSG_SAVING_STATE), path, - (unsigned)serial_size, + (unsigned)_len, msg_hash_to_str(MSG_BYTES)); } @@ -1451,16 +1446,16 @@ bool content_save_state(const char *path, bool save_to_disk) /* TODO/FIXME - Use msg_hash_to_str here */ RARCH_LOG("[State]: %s ...\n", msg_hash_to_str(MSG_FILE_ALREADY_EXISTS_SAVING_TO_BACKUP_BUFFER)); - task_push_load_and_save_state(path, data, serial_size, true, false); + task_push_load_and_save_state(path, data, _len, true, false); } else - task_push_save_state(path, data, serial_size, false); + task_push_save_state(path, data, _len, false); } else { if (!data) { - if (!(data = content_get_serialized_data(&serial_size))) + if (!(data = content_get_serialized_data(&_len))) { RARCH_ERR("[State]: %s \"%s\".\n", msg_hash_to_str(MSG_FAILED_TO_SAVE_STATE_TO), @@ -1479,15 +1474,15 @@ bool content_save_state(const char *path, bool save_to_disk) undo_load_buf.data = NULL; } - if (!(undo_load_buf.data = malloc(serial_size))) + if (!(undo_load_buf.data = malloc(_len))) { free(data); return false; } - memcpy(undo_load_buf.data, data, serial_size); + memcpy(undo_load_buf.data, data, _len); free(data); - undo_load_buf.size = serial_size; + undo_load_buf.size = _len; strlcpy(undo_load_buf.path, path, sizeof(undo_load_buf.path)); } @@ -1735,8 +1730,8 @@ bool content_load_state_from_ram(void) **/ bool content_save_state_to_ram(void) { + size_t _len; void *data = NULL; - size_t serial_size; if (!core_info_current_supports_savestate()) { @@ -1745,14 +1740,14 @@ bool content_save_state_to_ram(void) return false; } - serial_size = core_serialize_size(); + _len = core_serialize_size(); - if (serial_size == 0) + if (_len == 0) return false; if (!save_state_in_background) { - if (!(data = content_get_serialized_data(&serial_size))) + if (!(data = content_get_serialized_data(&_len))) { RARCH_ERR("[State]: %s.\n", msg_hash_to_str(MSG_FAILED_TO_SAVE_SRAM)); @@ -1761,13 +1756,13 @@ bool content_save_state_to_ram(void) RARCH_LOG("[State]: %s, %u %s.\n", msg_hash_to_str(MSG_SAVING_STATE), - (unsigned)serial_size, + (unsigned)_len, msg_hash_to_str(MSG_BYTES)); } if (!data) { - if (!(data = content_get_serialized_data(&serial_size))) + if (!(data = content_get_serialized_data(&_len))) { RARCH_ERR("[State]: %s.\n", msg_hash_to_str(MSG_FAILED_TO_SAVE_SRAM)); @@ -1782,15 +1777,15 @@ bool content_save_state_to_ram(void) ram_buf.state_buf.data = NULL; } - if (!(ram_buf.state_buf.data = malloc(serial_size))) + if (!(ram_buf.state_buf.data = malloc(_len))) { free(data); return false; } - memcpy(ram_buf.state_buf.data, data, serial_size); + memcpy(ram_buf.state_buf.data, data, _len); free(data); - ram_buf.state_buf.size = serial_size; + ram_buf.state_buf.size = _len; ram_buf.to_write_file = true; return true; diff --git a/verbosity.c b/verbosity.c index da8a34308b11..d785e88e1529 100644 --- a/verbosity.c +++ b/verbosity.c @@ -331,15 +331,15 @@ void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap) #endif } -void RARCH_LOG_BUFFER(uint8_t *data, size_t size) +void RARCH_LOG_BUFFER(uint8_t *data, size_t len) { unsigned i, offset; - int padding = size % 16; + int padding = len % 16; uint8_t buf[16] = {0}; - RARCH_LOG("== %d-byte buffer ==================\n", (int)size); + RARCH_LOG("== %d-byte buffer ==================\n", (int)len); - for (i = 0, offset = 0; i < size; i++) + for (i = 0, offset = 0; i < len; i++) { buf[offset] = data[i]; offset++; @@ -468,7 +468,9 @@ void rarch_log_file_init( time_t cur_time = time(NULL); rtime_localtime(&cur_time, &tm_); - strftime(timestamped_log_file_name, sizeof(timestamped_log_file_name), "retroarch__%Y_%m_%d__%H_%M_%S.log", &tm_); + strftime(timestamped_log_file_name, + sizeof(timestamped_log_file_name), + "retroarch__%Y_%m_%d__%H_%M_%S.log", &tm_); } /* If nothing has changed, do nothing */ @@ -506,10 +508,10 @@ void rarch_log_file_init( if (last_slash) { char tmp_buf[PATH_MAX_LENGTH] = {0}; - size_t path_length = last_slash + 1 - override_path; + size_t _len = last_slash + 1 - override_path; - if ((path_length > 1) && (path_length < PATH_MAX_LENGTH)) - strlcpy(tmp_buf, override_path, path_length * sizeof(char)); + if ((_len > 1) && (_len < PATH_MAX_LENGTH)) + strlcpy(tmp_buf, override_path, _len * sizeof(char)); strlcpy(log_directory, tmp_buf, sizeof(log_directory)); } diff --git a/verbosity.h b/verbosity.h index 808e0fa5702b..d44748096fa3 100644 --- a/verbosity.h +++ b/verbosity.h @@ -227,7 +227,7 @@ void logger_send_v(const char *__format, va_list args); void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap); void RARCH_DBG(const char *fmt, ...); void RARCH_LOG(const char *fmt, ...); -void RARCH_LOG_BUFFER(uint8_t *buffer, size_t size); +void RARCH_LOG_BUFFER(uint8_t *buffer, size_t len); void RARCH_LOG_OUTPUT(const char *msg, ...); void RARCH_WARN(const char *fmt, ...); void RARCH_ERR(const char *fmt, ...);