Silence some warnings and general cleanups

This commit is contained in:
libretroadmin 2023-08-16 22:08:01 +02:00
parent e5ef309b58
commit c5088ce2ca
4 changed files with 51 additions and 59 deletions

View File

@ -283,7 +283,6 @@ int libretrodb_find_entry(libretrodb_t *db, const char *index_name,
libretrodb_index_t idx; libretrodb_index_t idx;
int rv; int rv;
uint8_t *buff; uint8_t *buff;
int count;
uint64_t offset; uint64_t offset;
ssize_t bufflen, nread = 0; ssize_t bufflen, nread = 0;

View File

@ -5845,7 +5845,7 @@ static int action_ok_delete_entry(const char *path,
/* Thumbnail must be refreshed */ /* Thumbnail must be refreshed */
if (menu_st->driver_ctx && menu_st->driver_ctx->refresh_thumbnail_image) if (menu_st->driver_ctx && menu_st->driver_ctx->refresh_thumbnail_image)
menu_st->driver_ctx->refresh_thumbnail_image( menu_st->driver_ctx->refresh_thumbnail_image(
menu_st->userdata, new_selection_ptr); menu_st->userdata, (unsigned)new_selection_ptr);
return 0; return 0;
} }

View File

@ -410,7 +410,7 @@ static char *webdav_create_digest_auth_header(const char *method, const char *ur
} }
len += strlcpy(header + len, "\", response=\"", total - len); len += strlcpy(header + len, "\", response=\"", total - len);
len += strlcpy(header + len, response, total - len); len += strlcpy(header + len, response, total - len);
len += strlcpy(header + len, "\"\r\n", total - len); strlcpy(header + len, "\"\r\n", total - len);
free(response); free(response);

View File

@ -138,12 +138,10 @@ static file_list_t *task_cloud_sync_create_manifest(RFILE *file)
file_list_t *list = NULL; file_list_t *list = NULL;
rjson_t *json = NULL; rjson_t *json = NULL;
list = (file_list_t *)calloc(1, sizeof(file_list_t)); if (!(list = (file_list_t *)calloc(1, sizeof(file_list_t))))
if (!list)
return NULL; return NULL;
json = rjson_open_rfile(file); if (!(json = rjson_open_rfile(file)))
if (!json)
return NULL; return NULL;
rjson_parse(json, list, rjson_parse(json, list,
@ -244,9 +242,9 @@ static void task_cloud_sync_read_local_manifest(task_cloud_sync_state_t *sync_st
static void task_cloud_sync_manifest_append_dir(file_list_t *manifest, static void task_cloud_sync_manifest_append_dir(file_list_t *manifest,
const char *dir_fullpath, char *dir_name) const char *dir_fullpath, char *dir_name)
{ {
int i;
struct string_list *dir_list; struct string_list *dir_list;
char dir_fullpath_slash[PATH_MAX_LENGTH]; char dir_fullpath_slash[PATH_MAX_LENGTH];
int i;
bool is_config = string_is_equal(dir_name, "config"); bool is_config = string_is_equal(dir_name, "config");
strlcpy(dir_fullpath_slash, dir_fullpath, sizeof(dir_fullpath_slash)); strlcpy(dir_fullpath_slash, dir_fullpath, sizeof(dir_fullpath_slash));
@ -302,20 +300,19 @@ static void task_cloud_sync_build_current_manifest(task_cloud_sync_state_t *sync
struct string_list *dirlist = task_cloud_sync_directory_map(); struct string_list *dirlist = task_cloud_sync_directory_map();
int i; int i;
sync_state->current_manifest = (file_list_t *)calloc(1, sizeof(file_list_t)); if (!(sync_state->current_manifest = (file_list_t *)calloc(1, sizeof(file_list_t))))
if (!sync_state->current_manifest)
{ {
sync_state->phase = CLOUD_SYNC_PHASE_END; sync_state->phase = CLOUD_SYNC_PHASE_END;
return; return;
} }
sync_state->updated_server_manifest = (file_list_t *)calloc(1, sizeof(file_list_t));
if (!sync_state->updated_server_manifest) if (!(sync_state->updated_server_manifest = (file_list_t *)calloc(1, sizeof(file_list_t))))
{ {
sync_state->phase = CLOUD_SYNC_PHASE_END; sync_state->phase = CLOUD_SYNC_PHASE_END;
return; return;
} }
sync_state->updated_local_manifest = (file_list_t *)calloc(1, sizeof(file_list_t));
if (!sync_state->updated_local_manifest) if (!(sync_state->updated_local_manifest = (file_list_t *)calloc(1, sizeof(file_list_t))))
{ {
sync_state->phase = CLOUD_SYNC_PHASE_END; sync_state->phase = CLOUD_SYNC_PHASE_END;
return; return;
@ -357,8 +354,7 @@ static void task_cloud_sync_update_progress(retro_task_t *task)
static void task_cloud_sync_add_to_updated_manifest(task_cloud_sync_state_t *sync_state, const char *key, char *hash, bool server) static void task_cloud_sync_add_to_updated_manifest(task_cloud_sync_state_t *sync_state, const char *key, char *hash, bool server)
{ {
file_list_t *list = server ? sync_state->updated_server_manifest : sync_state->updated_local_manifest; file_list_t *list = server ? sync_state->updated_server_manifest : sync_state->updated_local_manifest;
size_t idx; size_t idx = list->size;
idx = list->size;
file_list_append(list, NULL, NULL, 0, 0, 0); file_list_append(list, NULL, NULL, 0, 0, 0);
file_list_set_alt_at_offset(list, idx, key); file_list_set_alt_at_offset(list, idx, key);
list->list[idx].userdata = hash; list->list[idx].userdata = hash;
@ -412,13 +408,13 @@ static char *task_cloud_sync_md5_rfile(RFILE *file)
/* don't pass a server/local item_file to this, only current has ->path set */ /* don't pass a server/local item_file to this, only current has ->path set */
static void task_cloud_sync_backup_file(struct item_file *file) static void task_cloud_sync_backup_file(struct item_file *file)
{ {
settings_t *settings = config_get_ptr(); struct tm tm_;
const char *path_dir_core_assets = settings->paths.directory_core_assets; size_t len;
char backup_dir[PATH_MAX_LENGTH]; char backup_dir[PATH_MAX_LENGTH];
char new_path[PATH_MAX_LENGTH]; char new_path[PATH_MAX_LENGTH];
char new_dir[PATH_MAX_LENGTH]; char new_dir[PATH_MAX_LENGTH];
size_t len; settings_t *settings = config_get_ptr();
struct tm tm_; const char *path_dir_core_assets = settings->paths.directory_core_assets;
time_t cur_time = time(NULL); time_t cur_time = time(NULL);
rtime_localtime(&cur_time, &tm_); rtime_localtime(&cur_time, &tm_);
@ -617,14 +613,13 @@ static void task_cloud_sync_delete_current_file(task_cloud_sync_state_t *sync_st
static void task_cloud_sync_check_server_current(task_cloud_sync_state_t *sync_state, bool include_local) static void task_cloud_sync_check_server_current(task_cloud_sync_state_t *sync_state, bool include_local)
{ {
bool server_changed, current_changed;
struct item_file *server_file = &sync_state->server_manifest->list[sync_state->server_idx]; struct item_file *server_file = &sync_state->server_manifest->list[sync_state->server_idx];
struct item_file *local_file; struct item_file *local_file = NULL;
struct item_file *current_file = &sync_state->current_manifest->list[sync_state->current_idx]; struct item_file *current_file = &sync_state->current_manifest->list[sync_state->current_idx];
const char *filename = current_file->path; const char *filename = current_file->path;
RFILE *file = filestream_open(filename, RFILE *file = filestream_open(filename,
RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE); RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE);
bool server_changed;
bool current_changed;
if (!file) if (!file)
return; return;
@ -636,7 +631,7 @@ static void task_cloud_sync_check_server_current(task_cloud_sync_state_t *sync_s
{ {
task_cloud_sync_add_to_updated_manifest(sync_state, CS_FILE_KEY(current_file), CS_FILE_HASH(current_file), true); task_cloud_sync_add_to_updated_manifest(sync_state, CS_FILE_KEY(current_file), CS_FILE_HASH(current_file), true);
task_cloud_sync_add_to_updated_manifest(sync_state, CS_FILE_KEY(current_file), CS_FILE_HASH(current_file), false); task_cloud_sync_add_to_updated_manifest(sync_state, CS_FILE_KEY(current_file), CS_FILE_HASH(current_file), false);
/* no need to mark need_manifest_uploaded, nothing changed */ /* No need to mark need_manifest_uploaded, nothing changed */
return; return;
} }
@ -717,18 +712,21 @@ static void task_cloud_sync_delete_server_file(task_cloud_sync_state_t *sync_sta
static void task_cloud_sync_diff_next(task_cloud_sync_state_t *sync_state) static void task_cloud_sync_diff_next(task_cloud_sync_state_t *sync_state)
{ {
int server_local_key_cmp;
int server_current_key_cmp;
int current_local_key_cmp;
struct item_file *server_file = NULL; struct item_file *server_file = NULL;
struct item_file *local_file = NULL; struct item_file *local_file = NULL;
struct item_file *current_file = NULL; struct item_file *current_file = NULL;
if (sync_state->server_manifest && if ( sync_state->server_manifest
sync_state->server_idx < sync_state->server_manifest->size) && sync_state->server_idx < sync_state->server_manifest->size)
server_file = &sync_state->server_manifest->list[sync_state->server_idx]; server_file = &sync_state->server_manifest->list[sync_state->server_idx];
if (sync_state->local_manifest && if ( sync_state->local_manifest
sync_state->local_idx < sync_state->local_manifest->size) && sync_state->local_idx < sync_state->local_manifest->size)
local_file = &sync_state->local_manifest->list[sync_state->local_idx]; local_file = &sync_state->local_manifest->list[sync_state->local_idx];
if (sync_state->current_manifest && if ( sync_state->current_manifest
sync_state->current_idx < sync_state->current_manifest->size) && sync_state->current_idx < sync_state->current_manifest->size)
current_file = &sync_state->current_manifest->list[sync_state->current_idx]; current_file = &sync_state->current_manifest->list[sync_state->current_idx];
if (!server_file && !local_file && !current_file) if (!server_file && !local_file && !current_file)
@ -738,12 +736,9 @@ static void task_cloud_sync_diff_next(task_cloud_sync_state_t *sync_state)
return; return;
} }
/* doing a three-way diff of sorted lists of files. grab the first one from /* Doing a three-way diff of sorted lists of files. grab the first one from
* each, resolve any difference, move on. */ * each, resolve any difference, move on. */
server_local_key_cmp = task_cloud_sync_key_cmp(server_file, local_file);
int server_local_key_cmp = task_cloud_sync_key_cmp(server_file, local_file);
int server_current_key_cmp;
int current_local_key_cmp;
if (server_local_key_cmp < 0) if (server_local_key_cmp < 0)
{ {
@ -852,16 +847,14 @@ static void task_cloud_sync_update_manifest_cb(void *user_data, const char *path
static RFILE *task_cloud_sync_write_updated_manifest(file_list_t *manifest, char *path) static RFILE *task_cloud_sync_write_updated_manifest(file_list_t *manifest, char *path)
{ {
RFILE *file = NULL;
rjsonwriter_t *writer = NULL; rjsonwriter_t *writer = NULL;
size_t idx = 0; size_t idx = 0;
RFILE *file = filestream_open(path,
file = filestream_open(path, RETRO_VFS_FILE_ACCESS_READ_WRITE, RETRO_VFS_FILE_ACCESS_HINT_NONE); RETRO_VFS_FILE_ACCESS_READ_WRITE, RETRO_VFS_FILE_ACCESS_HINT_NONE);
if (!file) if (!file)
return NULL; return NULL;
writer = rjsonwriter_open_rfile(file); if (!(writer = rjsonwriter_open_rfile(file)))
if (!writer)
{ {
filestream_close(file); filestream_close(file);
return NULL; return NULL;
@ -938,15 +931,14 @@ static void task_cloud_sync_end_handler(void *user_data, const char *path, bool
{ {
retro_task_t *task = (retro_task_t *)user_data; retro_task_t *task = (retro_task_t *)user_data;
task_cloud_sync_state_t *sync_state = NULL; task_cloud_sync_state_t *sync_state = NULL;
char title[512];
size_t len = 0;
if (!task) if (!task)
return; return;
if ((sync_state = (task_cloud_sync_state_t *)task->state)) if ((sync_state = (task_cloud_sync_state_t *)task->state))
{ {
len = strlcpy(title + len, "Cloud Sync finished", sizeof(title) - len); char title[512];
size_t len = strlcpy(title + len, "Cloud Sync finished", sizeof(title) - len);
if (sync_state->failures || sync_state->conflicts) if (sync_state->failures || sync_state->conflicts)
len += strlcpy(title + len, " with ", sizeof(title) - len); len += strlcpy(title + len, " with ", sizeof(title) - len);
if (sync_state->failures) if (sync_state->failures)
@ -954,7 +946,7 @@ static void task_cloud_sync_end_handler(void *user_data, const char *path, bool
if (sync_state->failures && sync_state->conflicts) if (sync_state->failures && sync_state->conflicts)
len += strlcpy(title + len, " and ", sizeof(title) - len); len += strlcpy(title + len, " and ", sizeof(title) - len);
if (sync_state->conflicts) if (sync_state->conflicts)
len += strlcpy(title + len, "conflicts", sizeof(title) - len); strlcpy(title + len, "conflicts", sizeof(title) - len);
task_set_title(task, strdup(title)); task_set_title(task, strdup(title));
} }
@ -1066,7 +1058,8 @@ void task_push_cloud_sync(void)
return; return;
find_data.func = task_cloud_sync_task_finder; find_data.func = task_cloud_sync_task_finder;
if (task_queue_find(&find_data)) { if (task_queue_find(&find_data))
{
RARCH_LOG(CSPFX "already in progress\n"); RARCH_LOG(CSPFX "already in progress\n");
return; return;
} }
@ -1075,8 +1068,8 @@ void task_push_cloud_sync(void)
if (!sync_state) if (!sync_state)
return; return;
task = task_init(); if (!(task = task_init()))
if (!task) { {
free(sync_state); free(sync_state);
return; return;
} }