Cleanup some variable names and some other cleanups
This commit is contained in:
parent
d8725d77bb
commit
cc826c4ca6
|
@ -184,12 +184,12 @@ int system_property_get(const char *command,
|
||||||
{
|
{
|
||||||
if (fgets(buffer, sizeof(buffer), pipe))
|
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;
|
curpos += _len;
|
||||||
length += curlen;
|
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"))
|
else if (string_is_equal(key, "remaining capacity"))
|
||||||
{
|
{
|
||||||
char *endptr = NULL;
|
char *endptr = NULL;
|
||||||
|
|
||||||
if (endptr && *endptr == ' ')
|
if (endptr && *endptr == ' ')
|
||||||
remaining = (int)strtol(val, &endptr, 10);
|
remaining = (int)strtol(val, &endptr, 10);
|
||||||
}
|
}
|
||||||
|
|
|
@ -619,7 +619,6 @@ static bool win32_drag_query_file(HWND hwnd, WPARAM wparam)
|
||||||
{
|
{
|
||||||
char szFilename[1024];
|
char szFilename[1024];
|
||||||
szFilename[0] = '\0';
|
szFilename[0] = '\0';
|
||||||
|
|
||||||
DragQueryFile((HDROP)wparam, 0, szFilename, sizeof(szFilename));
|
DragQueryFile((HDROP)wparam, 0, szFilename, sizeof(szFilename));
|
||||||
return win32_load_content_from_gui(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);
|
label_enum = menu_id_to_label_enum(menu_item_info.wID);
|
||||||
if (label_enum != MSG_UNKNOWN)
|
if (label_enum != MSG_UNKNOWN)
|
||||||
{
|
{
|
||||||
int len;
|
size_t ___len;
|
||||||
size_t __len;
|
size_t __len;
|
||||||
#ifndef LEGACY_WIN32
|
#ifndef LEGACY_WIN32
|
||||||
wchar_t* new_label_unicode = NULL;
|
wchar_t* new_label_unicode = NULL;
|
||||||
|
@ -2221,15 +2220,15 @@ static void win32_localize_menu(HMENU menu)
|
||||||
#ifndef LEGACY_WIN32
|
#ifndef LEGACY_WIN32
|
||||||
/* Convert string from UTF-8, then assign menu text */
|
/* Convert string from UTF-8, then assign menu text */
|
||||||
new_label_unicode = utf8_to_utf16_string_alloc(new_label2);
|
new_label_unicode = utf8_to_utf16_string_alloc(new_label2);
|
||||||
len = wcslen(new_label_unicode);
|
___len = wcslen(new_label_unicode);
|
||||||
menu_item_info.cch = len;
|
menu_item_info.cch = ___len;
|
||||||
menu_item_info.dwTypeData = new_label_unicode;
|
menu_item_info.dwTypeData = new_label_unicode;
|
||||||
SetMenuItemInfoW(menu, index, true, &menu_item_info);
|
SetMenuItemInfoW(menu, index, true, &menu_item_info);
|
||||||
free(new_label_unicode);
|
free(new_label_unicode);
|
||||||
#else
|
#else
|
||||||
new_label_ansi = utf8_to_local_string_alloc(new_label2);
|
new_label_ansi = utf8_to_local_string_alloc(new_label2);
|
||||||
len = strlen(new_label_ansi);
|
___len = strlen(new_label_ansi);
|
||||||
menu_item_info.cch = len;
|
menu_item_info.cch = ___len;
|
||||||
menu_item_info.dwTypeData = new_label_ansi;
|
menu_item_info.dwTypeData = new_label_ansi;
|
||||||
SetMenuItemInfoA(menu, index, true, &menu_item_info);
|
SetMenuItemInfoA(menu, index, true, &menu_item_info);
|
||||||
free(new_label_ansi);
|
free(new_label_ansi);
|
||||||
|
@ -2775,7 +2774,7 @@ bool win32_get_video_output(DEVMODE *dm, int mode, size_t len)
|
||||||
return true;
|
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;
|
DEVMODE dm;
|
||||||
if (win32_get_video_output(&dm, -1, sizeof(dm)))
|
if (win32_get_video_output(&dm, -1, sizeof(dm)))
|
||||||
|
|
|
@ -817,14 +817,14 @@ static bool ffmpeg_init_config(struct ff_config_param *params,
|
||||||
static bool ffmpeg_init_muxer_pre(ffmpeg_t *handle)
|
static bool ffmpeg_init_muxer_pre(ffmpeg_t *handle)
|
||||||
{
|
{
|
||||||
#if !FFMPEG3
|
#if !FFMPEG3
|
||||||
unsigned short int len;
|
size_t _len;
|
||||||
#endif
|
#endif
|
||||||
ctx = avformat_alloc_context();
|
ctx = avformat_alloc_context();
|
||||||
handle->muxer.ctx = ctx;
|
handle->muxer.ctx = ctx;
|
||||||
#if !FFMPEG3
|
#if !FFMPEG3
|
||||||
len = MIN(strlen(handle->params.filename) + 1, PATH_MAX_LENGTH);
|
_len = MIN(strlen(handle->params.filename) + 1, PATH_MAX_LENGTH);
|
||||||
ctx->url = (char*)av_malloc(len);
|
ctx->url = (char*)av_malloc(_len);
|
||||||
av_strlcpy(ctx->url, handle->params.filename, len);
|
av_strlcpy(ctx->url, handle->params.filename, _len);
|
||||||
#else
|
#else
|
||||||
av_strlcpy(ctx->filename, handle->params.filename, sizeof(ctx->filename));
|
av_strlcpy(ctx->filename, handle->params.filename, sizeof(ctx->filename));
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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;
|
retro_task_t *task = (retro_task_t *)t_ptr;
|
||||||
http_handle_t *http = (http_handle_t*)task->state;
|
http_handle_t *http = (http_handle_t*)task->state;
|
||||||
http_transfer_data_t *resp;
|
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;
|
http->handle = -1;
|
||||||
return;
|
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;
|
retro_task_t *task = (retro_task_t *)t_ptr;
|
||||||
http_handle_t *http = (http_handle_t*)task->state;
|
http_handle_t *http = (http_handle_t*)task->state;
|
||||||
bool mute = ((task->flags & RETRO_TASK_FLG_MUTE) > 0);
|
bool mute = ((task->flags & RETRO_TASK_FLG_MUTE) > 0);
|
||||||
if (!mute)
|
if (!mute)
|
||||||
task_set_error(task, strldup("Download failed.",
|
task_set_error(task, strldup("Download failed.",
|
||||||
sizeof("Download failed.")));
|
sizeof("Download failed.")));
|
||||||
http->handle = -1;
|
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;
|
retro_task_t *task = (retro_task_t *)t_ptr;
|
||||||
if (tot == 0)
|
if (tot == 0)
|
||||||
task_set_progress(task, -1);
|
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(
|
static void *task_push_http_transfer_generic(
|
||||||
const char *url, const char *method,
|
const char *url, const char *method,
|
||||||
const char *data, const char *user_agent,
|
const char *data, const char *user_agent,
|
||||||
const char *headers,
|
const char *headers, bool mute,
|
||||||
bool mute,
|
|
||||||
retro_task_callback_t cb, void *user_data)
|
retro_task_callback_t cb, void *user_data)
|
||||||
{
|
{
|
||||||
retro_task_t *t = NULL;
|
retro_task_t *t = NULL;
|
||||||
|
@ -158,15 +160,12 @@ static void *task_push_http_transfer_generic(
|
||||||
if (!url)
|
if (!url)
|
||||||
return NULL;
|
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
|
||||||
/* POST requests usually mutate the server, so assume multiple calls are
|
* only by the POST data, and task_http_finder doesn't look at that, so
|
||||||
* intended, even if they're duplicated. Additionally, they may differ
|
* unique requests could be misclassified as duplicates.
|
||||||
* 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"))
|
||||||
*/
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
task_finder_data_t find_data;
|
task_finder_data_t find_data;
|
||||||
find_data.func = task_http_finder;
|
find_data.func = task_http_finder;
|
||||||
|
@ -189,7 +188,6 @@ static void *task_push_http_transfer_generic(
|
||||||
if (!(t = task_init()))
|
if (!(t = task_init()))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
|
||||||
t->handler = task_http_transfer_handler;
|
t->handler = task_http_transfer_handler;
|
||||||
t->state = http;
|
t->state = http;
|
||||||
t->callback = cb;
|
t->callback = cb;
|
||||||
|
@ -202,7 +200,9 @@ static void *task_push_http_transfer_generic(
|
||||||
else
|
else
|
||||||
t->flags &= ~RETRO_TASK_FLG_MUTE;
|
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;
|
http->handle = wget_handle;
|
||||||
|
|
||||||
|
@ -223,14 +223,16 @@ void* task_push_http_transfer(const char *url, bool mute,
|
||||||
const char *type,
|
const char *type,
|
||||||
retro_task_callback_t cb, void *user_data)
|
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,
|
void *task_push_webdav_stat(const char *url, bool mute, const char *headers,
|
||||||
retro_task_callback_t cb, void *user_data)
|
retro_task_callback_t cb, void *user_data)
|
||||||
{
|
{
|
||||||
RARCH_ERR("[HTTP] Response headers not supported, webdav won't work.\n");
|
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,
|
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)
|
retro_task_callback_t cb, void *user_data)
|
||||||
{
|
{
|
||||||
RARCH_ERR("[HTTP] Response headers not supported, webdav won't work.\n");
|
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,
|
void* task_push_webdav_put(const char *url,
|
||||||
const void *put_data, size_t len, bool mute,
|
const void *put_data, size_t len, bool mute,
|
||||||
const char *headers, retro_task_callback_t cb, void *user_data)
|
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");
|
RARCH_ERR("[HTTP] Response headers not supported, webdav won't work.\n");
|
||||||
|
|
||||||
_len = strlcpy(expect, "Expect: 100-continue\r\n", sizeof(expect));
|
_len = strlcpy(expect, "Expect: 100-continue\r\n", sizeof(expect));
|
||||||
if (headers)
|
if (headers)
|
||||||
{
|
|
||||||
strlcpy(expect + _len, headers, sizeof(expect) - _len);
|
strlcpy(expect + _len, headers, sizeof(expect) - _len);
|
||||||
}
|
|
||||||
|
|
||||||
return task_push_http_transfer_generic(url, "PUT", put_data, NULL, expect, mute, cb, user_data);
|
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)
|
retro_task_callback_t cb, void *user_data)
|
||||||
{
|
{
|
||||||
RARCH_ERR("[HTTP] Response headers not supported, webdav won't work.\n");
|
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,
|
void *task_push_webdav_move(const char *url,
|
||||||
|
@ -281,7 +281,8 @@ void *task_push_webdav_move(const char *url,
|
||||||
if (headers)
|
if (headers)
|
||||||
strlcpy(dest_header + _len, headers, sizeof(dest_header) - _len);
|
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,
|
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",
|
if (string_ends_with_size(s, ".index",
|
||||||
strlen(s), STRLEN_CONST(".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);
|
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,
|
const char *type, const char *user_agent,
|
||||||
retro_task_callback_t cb, void *user_data)
|
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,
|
void* task_push_http_transfer_with_headers(const char *url, bool mute,
|
||||||
const char *type, const char *headers,
|
const char *type, const char *headers,
|
||||||
retro_task_callback_t cb, void *user_data)
|
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,
|
void* task_push_http_post_transfer(const char *url,
|
||||||
const char *post_data, bool mute,
|
const char *post_data, bool mute,
|
||||||
const char *type, retro_task_callback_t cb, void *user_data)
|
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,
|
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,
|
const char *type, const char *user_agent,
|
||||||
retro_task_callback_t cb, void *user_data)
|
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,
|
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,
|
const char *type, const char *headers,
|
||||||
retro_task_callback_t cb, void *user_data)
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
static void ups_target_write(struct ups_data *data, uint8_t n)
|
||||||
{
|
{
|
||||||
|
if (data->target_offset < data->target_length)
|
||||||
if (data && data->target_offset < data->target_length)
|
|
||||||
{
|
{
|
||||||
data->target_data[data->target_offset] = n;
|
data->target_data[data->target_offset] = n;
|
||||||
data->target_checksum =
|
data->target_checksum =
|
||||||
~(encoding_crc32(~data->target_checksum, &n, 1));
|
~(encoding_crc32(~data->target_checksum, &n, 1));
|
||||||
}
|
}
|
||||||
|
data->target_offset++;
|
||||||
if (data)
|
|
||||||
data->target_offset++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t ups_decode(struct ups_data *data)
|
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)
|
while (data.patch_offset < data.patch_length - 12)
|
||||||
{
|
{
|
||||||
unsigned length = (unsigned)ups_decode(&data);
|
unsigned __len = (unsigned)ups_decode(&data);
|
||||||
while (length--)
|
while (__len--)
|
||||||
ups_target_write(&data, ups_source_read(&data));
|
ups_target_write(&data, ups_source_read(&data));
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
|
@ -464,7 +461,7 @@ static enum patch_error ips_alloc_targetdata(
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
uint32_t address;
|
uint32_t address;
|
||||||
unsigned length;
|
size_t _len;
|
||||||
|
|
||||||
if (offset > patchlen - 3)
|
if (offset > patchlen - 3)
|
||||||
break;
|
break;
|
||||||
|
@ -477,7 +474,7 @@ static enum patch_error ips_alloc_targetdata(
|
||||||
{
|
{
|
||||||
if (offset == patchlen)
|
if (offset == patchlen)
|
||||||
{
|
{
|
||||||
prov_alloc = (uint8_t*)malloc((size_t)*targetlength);
|
prov_alloc = (uint8_t*)malloc((size_t) * targetlength);
|
||||||
if (!prov_alloc)
|
if (!prov_alloc)
|
||||||
return PATCH_TARGET_ALLOC_FAILED;
|
return PATCH_TARGET_ALLOC_FAILED;
|
||||||
free(*targetdata);
|
free(*targetdata);
|
||||||
|
@ -490,7 +487,7 @@ static enum patch_error ips_alloc_targetdata(
|
||||||
size |= patchdata[offset++] << 8;
|
size |= patchdata[offset++] << 8;
|
||||||
size |= patchdata[offset++] << 0;
|
size |= patchdata[offset++] << 0;
|
||||||
*targetlength = size;
|
*targetlength = size;
|
||||||
prov_alloc = (uint8_t*)malloc((size_t)*targetlength);
|
prov_alloc = (uint8_t*)malloc((size_t) * targetlength);
|
||||||
|
|
||||||
if (!prov_alloc)
|
if (!prov_alloc)
|
||||||
return PATCH_TARGET_ALLOC_FAILED;
|
return PATCH_TARGET_ALLOC_FAILED;
|
||||||
|
@ -503,15 +500,15 @@ static enum patch_error ips_alloc_targetdata(
|
||||||
if (offset > patchlen - 2)
|
if (offset > patchlen - 2)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
length = patchdata[offset++] << 8;
|
_len = patchdata[offset++] << 8;
|
||||||
length |= patchdata[offset++] << 0;
|
_len |= patchdata[offset++] << 0;
|
||||||
|
|
||||||
if (length) /* Copy */
|
if (_len) /* Copy */
|
||||||
{
|
{
|
||||||
if (offset > patchlen - length)
|
if (offset > patchlen - _len)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
while (length--)
|
while (_len--)
|
||||||
{
|
{
|
||||||
address++;
|
address++;
|
||||||
offset++;
|
offset++;
|
||||||
|
@ -522,13 +519,13 @@ static enum patch_error ips_alloc_targetdata(
|
||||||
if (offset > patchlen - 3)
|
if (offset > patchlen - 3)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
length = patchdata[offset++] << 8;
|
_len = patchdata[offset++] << 8;
|
||||||
length |= patchdata[offset++] << 0;
|
_len |= patchdata[offset++] << 0;
|
||||||
|
|
||||||
if (length == 0) /* Illegal */
|
if (_len == 0) /* Illegal */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
while (length--)
|
while (_len--)
|
||||||
address++;
|
address++;
|
||||||
|
|
||||||
offset++;
|
offset++;
|
||||||
|
@ -566,7 +563,7 @@ static enum patch_error ips_apply_patch(
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
uint32_t address;
|
uint32_t address;
|
||||||
unsigned length;
|
size_t _len;
|
||||||
|
|
||||||
if (offset > patchlen - 3)
|
if (offset > patchlen - 3)
|
||||||
break;
|
break;
|
||||||
|
@ -594,15 +591,15 @@ static enum patch_error ips_apply_patch(
|
||||||
if (offset > patchlen - 2)
|
if (offset > patchlen - 2)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
length = patchdata[offset++] << 8;
|
_len = patchdata[offset++] << 8;
|
||||||
length |= patchdata[offset++] << 0;
|
_len |= patchdata[offset++] << 0;
|
||||||
|
|
||||||
if (length) /* Copy */
|
if (_len) /* Copy */
|
||||||
{
|
{
|
||||||
if (offset > patchlen - length)
|
if (offset > patchlen - _len)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
while (length--)
|
while (_len--)
|
||||||
(*targetdata)[address++] = patchdata[offset++];
|
(*targetdata)[address++] = patchdata[offset++];
|
||||||
}
|
}
|
||||||
else /* RLE */
|
else /* RLE */
|
||||||
|
@ -610,13 +607,13 @@ static enum patch_error ips_apply_patch(
|
||||||
if (offset > patchlen - 3)
|
if (offset > patchlen - 3)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
length = patchdata[offset++] << 8;
|
_len = patchdata[offset++] << 8;
|
||||||
length |= patchdata[offset++] << 0;
|
_len |= patchdata[offset++] << 0;
|
||||||
|
|
||||||
if (length == 0) /* Illegal */
|
if (_len == 0) /* Illegal */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
while (length--)
|
while (_len--)
|
||||||
(*targetdata)[address++] = patchdata[offset];
|
(*targetdata)[address++] = patchdata[offset];
|
||||||
|
|
||||||
offset++;
|
offset++;
|
||||||
|
|
Loading…
Reference in New Issue