tests/ecore: replace all bespoke strcats with snprintf

Summary:
CID 1400812
Depends on D10413

Reviewers: devilhorns

Reviewed By: devilhorns

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D10414
This commit is contained in:
Mike Blumenkrantz 2019-10-24 18:23:11 +02:00 committed by Xavi Artigas
parent e05311a99a
commit 30f6c12cbf
1 changed files with 8 additions and 23 deletions

View File

@ -196,9 +196,7 @@ EFL_START_TEST(ecore_test_ecore_file_operations)
src_dir = get_tmp_dir();
fail_if(!src_dir);
strcat(dir, src_dir);
strcat(dir, "/");
strcat(dir, dirs[2]);
snprintf(dir, sizeof(dir), "%s/%s", src_dir, dirs[2]);
res = ecore_file_mkpath(dir);
fail_if(res != EINA_TRUE);
res = ecore_file_recursive_rm(src_dir);
@ -265,18 +263,14 @@ EFL_START_TEST(ecore_test_ecore_file_operations)
src_dir = get_tmp_dir();
fail_if(!src_dir);
strcpy(dir, src_dir);
strcat(dir, "/");
strcat(dir, dirs[0]);
snprintf(dir, sizeof(dir), "%s/%s", src_dir, dirs[0]);
fail_if(ecore_file_mkdir(dir) != EINA_TRUE);
fail_if(ecore_file_mkdirs(NULL) != -1);
for (i = 0; i < 3; i++)
{
char tmp[PATH_MAX];
strcpy(tmp, src_dir);
strcat(tmp, "/");
strcat(tmp, dirs2[i]);
snprintf(tmp, sizeof(tmp), "%s/%s", src_dir, dirs2[i]);
dirs2[i] = strdup(tmp);
}
fail_if(ecore_file_mkdirs((const char **)dirs2) != 3);
@ -403,11 +397,8 @@ EFL_START_TEST(ecore_test_ecore_file_path)
src_dir = getenv("PATH");
fail_if(!src_dir);
path = malloc(strlen(src_dir) + strlen(dup_dir) + 1);
*path = '\0';
strcat(path, src_dir);
strcat(path, ":");
strcat(path, dirname(dup_dir));
path = malloc(strlen(src_dir) + strlen(dup_dir) + 2);
snprintf(path, strlen(src_dir) + strlen(dup_dir) + 2, "%s:%s", src_dir, dirname(dup_dir));
ret = setenv("PATH", path, 1);
fail_if(ret != 0);
free(dup_dir);
@ -468,9 +459,7 @@ EFL_START_TEST(ecore_test_ecore_file_monitor)
mon = ecore_file_monitor_add(realp, file_monitor_cb, NULL);
fail_if(mon == NULL);
strcat(file_name, src_dir);
strcat(file_name, "/");
strcat(file_name, file);
snprintf(file_name, sizeof(file_name), "%s/%s", src_dir, file);
_writeToFile(file_name, random_text);
_writeToFile(file_name, random_text);
@ -483,9 +472,7 @@ EFL_START_TEST(ecore_test_ecore_file_monitor)
res = ecore_file_remove(file_name);
fail_if(res != EINA_TRUE);
strcat(dir_name, src_dir);
strcat(dir_name, "/");
strcat(dir_name, sub_dir[0]);
snprintf(dir_name, sizeof(dir_name), "%s/%s", src_dir, sub_dir[0]);
res = ecore_file_rmdir(dir_name);
fail_if(res != EINA_TRUE);
@ -519,9 +506,7 @@ EFL_START_TEST(ecore_test_ecore_file_download)
download_file = ecore_file_file_get(download_url); //example.com
fail_if(!download_file);
fail_if(!ecore_file_download_protocol_available("http://"));
strcat(dest_name, download_dir);
strcat(dest_name, "/");
strcat(dest_name, download_file);
snprintf(dest_name, sizeof(dest_name), "%s/%s", download_dir, download_file);
res = ecore_file_download("xxyyzz", dest_name, completion_cb,
progress_cb, NULL, &job);