diff --git a/frontend/drivers/platform_unix.c b/frontend/drivers/platform_unix.c index bee5fa415b..d6cd146560 100644 --- a/frontend/drivers/platform_unix.c +++ b/frontend/drivers/platform_unix.c @@ -184,12 +184,12 @@ int system_property_get(const char *command, { if (fgets(buffer, sizeof(buffer), pipe)) { - size_t curlen = strlen(buffer); + size_t _len = strlen(buffer); - memcpy(curpos, buffer, curlen); + memcpy(curpos, buffer, _len); - curpos += curlen; - length += curlen; + curpos += _len; + length += _len; } } @@ -702,7 +702,6 @@ static void check_proc_acpi_battery(const char * node, bool * have_battery, else if (string_is_equal(key, "remaining capacity")) { char *endptr = NULL; - if (endptr && *endptr == ' ') remaining = (int)strtol(val, &endptr, 10); } diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index b8fc4adb70..da56ba6d29 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -619,7 +619,6 @@ static bool win32_drag_query_file(HWND hwnd, WPARAM wparam) { char szFilename[1024]; szFilename[0] = '\0'; - DragQueryFile((HDROP)wparam, 0, szFilename, sizeof(szFilename)); return win32_load_content_from_gui(szFilename); } @@ -2163,7 +2162,7 @@ static void win32_localize_menu(HMENU menu) label_enum = menu_id_to_label_enum(menu_item_info.wID); if (label_enum != MSG_UNKNOWN) { - int len; + size_t ___len; size_t __len; #ifndef LEGACY_WIN32 wchar_t* new_label_unicode = NULL; @@ -2221,15 +2220,15 @@ static void win32_localize_menu(HMENU menu) #ifndef LEGACY_WIN32 /* Convert string from UTF-8, then assign menu text */ new_label_unicode = utf8_to_utf16_string_alloc(new_label2); - len = wcslen(new_label_unicode); - menu_item_info.cch = len; + ___len = wcslen(new_label_unicode); + menu_item_info.cch = ___len; menu_item_info.dwTypeData = new_label_unicode; SetMenuItemInfoW(menu, index, true, &menu_item_info); free(new_label_unicode); #else new_label_ansi = utf8_to_local_string_alloc(new_label2); - len = strlen(new_label_ansi); - menu_item_info.cch = len; + ___len = strlen(new_label_ansi); + menu_item_info.cch = ___len; menu_item_info.dwTypeData = new_label_ansi; SetMenuItemInfoA(menu, index, true, &menu_item_info); free(new_label_ansi); @@ -2775,7 +2774,7 @@ bool win32_get_video_output(DEVMODE *dm, int mode, size_t len) return true; } -void win32_get_video_output_size(void *data, unsigned *width, unsigned *height, char *desc, size_t desc_len) +void win32_get_video_output_size(void *data, unsigned *width, unsigned *height, char *desc, size_t len) { DEVMODE dm; if (win32_get_video_output(&dm, -1, sizeof(dm))) diff --git a/record/drivers/record_ffmpeg.c b/record/drivers/record_ffmpeg.c index be04f7fde0..4f03643a67 100644 --- a/record/drivers/record_ffmpeg.c +++ b/record/drivers/record_ffmpeg.c @@ -817,14 +817,14 @@ static bool ffmpeg_init_config(struct ff_config_param *params, static bool ffmpeg_init_muxer_pre(ffmpeg_t *handle) { #if !FFMPEG3 - unsigned short int len; + size_t _len; #endif ctx = avformat_alloc_context(); handle->muxer.ctx = ctx; #if !FFMPEG3 - len = MIN(strlen(handle->params.filename) + 1, PATH_MAX_LENGTH); - ctx->url = (char*)av_malloc(len); - av_strlcpy(ctx->url, handle->params.filename, len); + _len = MIN(strlen(handle->params.filename) + 1, PATH_MAX_LENGTH); + ctx->url = (char*)av_malloc(_len); + av_strlcpy(ctx->url, handle->params.filename, _len); #else av_strlcpy(ctx->filename, handle->params.filename, sizeof(ctx->filename)); #endif diff --git a/tasks/task_http_emscripten.c b/tasks/task_http_emscripten.c index b0e1d5d2cd..c79ced9e07 100644 --- a/tasks/task_http_emscripten.c +++ b/tasks/task_http_emscripten.c @@ -107,33 +107,36 @@ static void task_http_transfer_cleanup(retro_task_t *task) } } -void wget_onload_cb(unsigned handle, void *t_ptr, void *data, unsigned len) { +void wget_onload_cb(unsigned handle, void *t_ptr, void *data, unsigned len) +{ retro_task_t *task = (retro_task_t *)t_ptr; http_handle_t *http = (http_handle_t*)task->state; http_transfer_data_t *resp; - if (!(resp = (http_transfer_data_t*)malloc(sizeof(*resp)))) { + if (!(resp = (http_transfer_data_t*)malloc(sizeof(*resp)))) + { http->handle = -1; return; - } else { - resp->data = data; - resp->len = len; - resp->status = 200; - resp->headers = NULL; // sorry webdav - http->response = resp; } + resp->data = data; + resp->len = len; + resp->status = 200; + resp->headers = NULL; /* sorry webdav */ + http->response = resp; } -void wget_onerror_cb(unsigned handle, void *t_ptr, int status, const char *err) { +void wget_onerror_cb(unsigned handle, void *t_ptr, int status, const char *err) +{ retro_task_t *task = (retro_task_t *)t_ptr; http_handle_t *http = (http_handle_t*)task->state; bool mute = ((task->flags & RETRO_TASK_FLG_MUTE) > 0); if (!mute) task_set_error(task, strldup("Download failed.", - sizeof("Download failed."))); + sizeof("Download failed."))); http->handle = -1; } -void wget_onprogress_cb(unsigned handle, void *t_ptr, int pos, int tot) { +void wget_onprogress_cb(unsigned handle, void *t_ptr, int pos, int tot) +{ retro_task_t *task = (retro_task_t *)t_ptr; if (tot == 0) task_set_progress(task, -1); @@ -148,8 +151,7 @@ void wget_onprogress_cb(unsigned handle, void *t_ptr, int pos, int tot) { static void *task_push_http_transfer_generic( const char *url, const char *method, const char *data, const char *user_agent, - const char *headers, - bool mute, + const char *headers, bool mute, retro_task_callback_t cb, void *user_data) { retro_task_t *t = NULL; @@ -158,15 +160,12 @@ static void *task_push_http_transfer_generic( if (!url) return NULL; - if (!string_is_equal(method, "GET")) - { - /* POST requests usually mutate the server, so assume multiple calls are - * intended, even if they're duplicated. Additionally, they may differ - * only by the POST data, and task_http_finder doesn't look at that, so - * unique requests could be misclassified as duplicates. - */ - } - else + /* POST requests usually mutate the server, so assume multiple calls are + * intended, even if they're duplicated. Additionally, they may differ + * only by the POST data, and task_http_finder doesn't look at that, so + * unique requests could be misclassified as duplicates. + */ + if (string_is_equal(method, "GET")) { task_finder_data_t find_data; find_data.func = task_http_finder; @@ -189,7 +188,6 @@ static void *task_push_http_transfer_generic( if (!(t = task_init())) goto error; - t->handler = task_http_transfer_handler; t->state = http; t->callback = cb; @@ -202,7 +200,9 @@ static void *task_push_http_transfer_generic( else t->flags &= ~RETRO_TASK_FLG_MUTE; - wget_handle = emscripten_async_wget2_data(url, method, data, t, false, wget_onload_cb, wget_onerror_cb, wget_onprogress_cb); + wget_handle = emscripten_async_wget2_data(url, method, data, + t, false, wget_onload_cb, wget_onerror_cb, + wget_onprogress_cb); http->handle = wget_handle; @@ -223,14 +223,16 @@ void* task_push_http_transfer(const char *url, bool mute, const char *type, retro_task_callback_t cb, void *user_data) { - return task_push_http_transfer_generic(url, type ? type : "GET", NULL, NULL, NULL, mute, cb, user_data); + return task_push_http_transfer_generic(url, type ? type : "GET", + NULL, NULL, NULL, mute, cb, user_data); } void *task_push_webdav_stat(const char *url, bool mute, const char *headers, retro_task_callback_t cb, void *user_data) { RARCH_ERR("[HTTP] Response headers not supported, webdav won't work.\n"); - return task_push_http_transfer_generic(url, "OPTIONS", NULL, NULL, headers, mute, cb, user_data); + return task_push_http_transfer_generic(url, "OPTIONS", NULL, NULL, + headers, mute, cb, user_data); } void* task_push_webdav_mkdir(const char *url, bool mute, @@ -238,23 +240,20 @@ void* task_push_webdav_mkdir(const char *url, bool mute, retro_task_callback_t cb, void *user_data) { RARCH_ERR("[HTTP] Response headers not supported, webdav won't work.\n"); - return task_push_http_transfer_generic(url, "MKCOL", NULL, NULL, headers, mute, cb, user_data); + return task_push_http_transfer_generic(url, "MKCOL", NULL, NULL, + headers, mute, cb, user_data); } void* task_push_webdav_put(const char *url, const void *put_data, size_t len, bool mute, const char *headers, retro_task_callback_t cb, void *user_data) { - char expect[1024]; /* TODO/FIXME - check size */ - size_t _len; + size_t _len; + char expect[1024]; /* TODO/FIXME - check size */ RARCH_ERR("[HTTP] Response headers not supported, webdav won't work.\n"); - _len = strlcpy(expect, "Expect: 100-continue\r\n", sizeof(expect)); if (headers) - { strlcpy(expect + _len, headers, sizeof(expect) - _len); - } - return task_push_http_transfer_generic(url, "PUT", put_data, NULL, expect, mute, cb, user_data); } @@ -263,7 +262,8 @@ void* task_push_webdav_delete(const char *url, bool mute, retro_task_callback_t cb, void *user_data) { RARCH_ERR("[HTTP] Response headers not supported, webdav won't work.\n"); - return task_push_http_transfer_generic(url, "DELETE", NULL, NULL, headers, mute, cb, user_data); + return task_push_http_transfer_generic(url, "DELETE", NULL, NULL, + headers, mute, cb, user_data); } void *task_push_webdav_move(const char *url, @@ -281,7 +281,8 @@ void *task_push_webdav_move(const char *url, if (headers) strlcpy(dest_header + _len, headers, sizeof(dest_header) - _len); - return task_push_http_transfer_generic(url, "MOVE", NULL, NULL, dest_header, mute, cb, user_data); + return task_push_http_transfer_generic(url, "MOVE", NULL, NULL, + dest_header, mute, cb, user_data); } void* task_push_http_transfer_file(const char* url, bool mute, @@ -314,7 +315,7 @@ void* task_push_http_transfer_file(const char* url, bool mute, if (string_ends_with_size(s, ".index", strlen(s), STRLEN_CONST(".index"))) - s = msg_hash_to_str(MSG_INDEX_FILE); + s = msg_hash_to_str(MSG_INDEX_FILE); strlcpy(tmp + _len, s, sizeof(tmp) - _len); @@ -326,21 +327,24 @@ void* task_push_http_transfer_with_user_agent(const char *url, bool mute, const char *type, const char *user_agent, retro_task_callback_t cb, void *user_data) { - return task_push_http_transfer_generic(url, type ? type : "GET", NULL, user_agent, NULL, mute, cb, user_data); + return task_push_http_transfer_generic(url, type ? type : "GET", NULL, + user_agent, NULL, mute, cb, user_data); } void* task_push_http_transfer_with_headers(const char *url, bool mute, const char *type, const char *headers, retro_task_callback_t cb, void *user_data) { - return task_push_http_transfer_generic(url, type ? type : "GET", NULL, NULL, headers, mute, cb, user_data); + return task_push_http_transfer_generic(url, type ? type : "GET", NULL, NULL, + headers, mute, cb, user_data); } void* task_push_http_post_transfer(const char *url, const char *post_data, bool mute, const char *type, retro_task_callback_t cb, void *user_data) { - return task_push_http_transfer_generic(url, type ? type : "POST", post_data, NULL, NULL, mute, cb, user_data); + return task_push_http_transfer_generic(url, type ? type : "POST", post_data, + NULL, NULL, mute, cb, user_data); } void* task_push_http_post_transfer_with_user_agent(const char *url, @@ -348,7 +352,8 @@ void* task_push_http_post_transfer_with_user_agent(const char *url, const char *type, const char *user_agent, retro_task_callback_t cb, void *user_data) { - return task_push_http_transfer_generic(url, type ? type : "POST", post_data, user_agent, NULL, mute, cb, user_data); + return task_push_http_transfer_generic(url, type ? type : "POST", + post_data, user_agent, NULL, mute, cb, user_data); } void* task_push_http_post_transfer_with_headers(const char *url, @@ -356,5 +361,6 @@ void* task_push_http_post_transfer_with_headers(const char *url, const char *type, const char *headers, retro_task_callback_t cb, void *user_data) { - return task_push_http_transfer_generic(url, type ? type : "POST", post_data, NULL, headers, mute, cb, user_data); + return task_push_http_transfer_generic(url, type ? type : "POST", post_data, + NULL, headers, mute, cb, user_data); } diff --git a/tasks/task_patch.c b/tasks/task_patch.c index ee87824ddc..2c21871075 100644 --- a/tasks/task_patch.c +++ b/tasks/task_patch.c @@ -308,16 +308,13 @@ static uint8_t ups_source_read(struct ups_data *data) static void ups_target_write(struct ups_data *data, uint8_t n) { - - if (data && data->target_offset < data->target_length) + if (data->target_offset < data->target_length) { data->target_data[data->target_offset] = n; data->target_checksum = ~(encoding_crc32(~data->target_checksum, &n, 1)); } - - if (data) - data->target_offset++; + data->target_offset++; } static uint64_t ups_decode(struct ups_data *data) @@ -399,8 +396,8 @@ static enum patch_error ups_apply_patch( while (data.patch_offset < data.patch_length - 12) { - unsigned length = (unsigned)ups_decode(&data); - while (length--) + unsigned __len = (unsigned)ups_decode(&data); + while (__len--) ups_target_write(&data, ups_source_read(&data)); for (;;) @@ -464,7 +461,7 @@ static enum patch_error ips_alloc_targetdata( for (;;) { uint32_t address; - unsigned length; + size_t _len; if (offset > patchlen - 3) break; @@ -477,7 +474,7 @@ static enum patch_error ips_alloc_targetdata( { if (offset == patchlen) { - prov_alloc = (uint8_t*)malloc((size_t)*targetlength); + prov_alloc = (uint8_t*)malloc((size_t) * targetlength); if (!prov_alloc) return PATCH_TARGET_ALLOC_FAILED; free(*targetdata); @@ -490,7 +487,7 @@ static enum patch_error ips_alloc_targetdata( size |= patchdata[offset++] << 8; size |= patchdata[offset++] << 0; *targetlength = size; - prov_alloc = (uint8_t*)malloc((size_t)*targetlength); + prov_alloc = (uint8_t*)malloc((size_t) * targetlength); if (!prov_alloc) return PATCH_TARGET_ALLOC_FAILED; @@ -503,15 +500,15 @@ static enum patch_error ips_alloc_targetdata( if (offset > patchlen - 2) break; - length = patchdata[offset++] << 8; - length |= patchdata[offset++] << 0; + _len = patchdata[offset++] << 8; + _len |= patchdata[offset++] << 0; - if (length) /* Copy */ + if (_len) /* Copy */ { - if (offset > patchlen - length) + if (offset > patchlen - _len) break; - while (length--) + while (_len--) { address++; offset++; @@ -522,13 +519,13 @@ static enum patch_error ips_alloc_targetdata( if (offset > patchlen - 3) break; - length = patchdata[offset++] << 8; - length |= patchdata[offset++] << 0; + _len = patchdata[offset++] << 8; + _len |= patchdata[offset++] << 0; - if (length == 0) /* Illegal */ + if (_len == 0) /* Illegal */ break; - while (length--) + while (_len--) address++; offset++; @@ -566,7 +563,7 @@ static enum patch_error ips_apply_patch( for (;;) { uint32_t address; - unsigned length; + size_t _len; if (offset > patchlen - 3) break; @@ -594,15 +591,15 @@ static enum patch_error ips_apply_patch( if (offset > patchlen - 2) break; - length = patchdata[offset++] << 8; - length |= patchdata[offset++] << 0; + _len = patchdata[offset++] << 8; + _len |= patchdata[offset++] << 0; - if (length) /* Copy */ + if (_len) /* Copy */ { - if (offset > patchlen - length) + if (offset > patchlen - _len) break; - while (length--) + while (_len--) (*targetdata)[address++] = patchdata[offset++]; } else /* RLE */ @@ -610,13 +607,13 @@ static enum patch_error ips_apply_patch( if (offset > patchlen - 3) break; - length = patchdata[offset++] << 8; - length |= patchdata[offset++] << 0; + _len = patchdata[offset++] << 8; + _len |= patchdata[offset++] << 0; - if (length == 0) /* Illegal */ + if (_len == 0) /* Illegal */ break; - while (length--) + while (_len--) (*targetdata)[address++] = patchdata[offset]; offset++;