Skip to content

Commit

Permalink
Fix various warnings when -DCMAKE_BUILD_TYPE:STRING=DEBUG
Browse files Browse the repository at this point in the history
  • Loading branch information
kontura authored and Conan-Kudo committed Jun 12, 2019
1 parent f78b445 commit a2d34f7
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 198 deletions.
1 change: 0 additions & 1 deletion src/koji.c
Expand Up @@ -104,7 +104,6 @@ koji_stuff_prepare(struct KojiMergedReposStuff **koji_stuff_ptr,
GSList *element;
int repoid;
int result;
GError *tmp_err = NULL;

// Pointers to elements in the koji_stuff_ptr
GHashTable *include_srpms = NULL; // XXX
Expand Down
6 changes: 2 additions & 4 deletions src/misc.c
Expand Up @@ -999,15 +999,13 @@ cr_log_fn(const gchar *log_domain,
void
cr_slist_free_full(GSList *list, GDestroyNotify free_f)
{
g_slist_foreach(list, (GFunc) free_f, NULL);
g_slist_free(list);
g_slist_free_full(list, free_f);
}


void cr_queue_free_full(GQueue *queue, GDestroyNotify free_f)
{
g_queue_foreach(queue, (GFunc) free_f, NULL);
g_queue_free(queue);
g_queue_free_full(queue, free_f);
}


Expand Down
30 changes: 10 additions & 20 deletions src/package.c
Expand Up @@ -92,53 +92,43 @@ cr_package_free(cr_Package *package)
*/

if (package->requires) {
g_slist_foreach (package->requires, (GFunc) g_free, NULL);
g_slist_free (package->requires);
g_slist_free_full(package->requires, g_free);
}

if (package->provides) {
g_slist_foreach (package->provides, (GFunc) g_free, NULL);
g_slist_free (package->provides);
g_slist_free_full(package->provides, g_free);
}

if (package->conflicts) {
g_slist_foreach (package->conflicts, (GFunc) g_free, NULL);
g_slist_free (package->conflicts);
g_slist_free_full(package->conflicts, g_free);
}

if (package->obsoletes) {
g_slist_foreach (package->obsoletes, (GFunc) g_free, NULL);
g_slist_free (package->obsoletes);
g_slist_free_full(package->obsoletes, g_free);
}

if (package->suggests) {
g_slist_foreach (package->suggests, (GFunc) g_free, NULL);
g_slist_free (package->suggests);
g_slist_free_full(package->suggests, g_free);
}

if (package->enhances) {
g_slist_foreach (package->enhances, (GFunc) g_free, NULL);
g_slist_free (package->enhances);
g_slist_free_full(package->enhances, g_free);
}

if (package->recommends) {
g_slist_foreach (package->recommends, (GFunc) g_free, NULL);
g_slist_free (package->recommends);
g_slist_free_full(package->recommends, g_free);
}

if (package->supplements) {
g_slist_foreach (package->supplements, (GFunc) g_free, NULL);
g_slist_free (package->supplements);
g_slist_free_full(package->supplements, g_free);
}

if (package->files) {
g_slist_foreach (package->files, (GFunc) g_free, NULL);
g_slist_free (package->files);
g_slist_free_full(package->files, g_free);
}

if (package->changelogs) {
g_slist_foreach (package->changelogs, (GFunc) g_free, NULL);
g_slist_free (package->changelogs);
g_slist_free_full(package->changelogs, g_free);
}

g_free(package->siggpg);
Expand Down
2 changes: 0 additions & 2 deletions src/xml_parser_updateinfo.c
Expand Up @@ -354,7 +354,6 @@ cr_start_handler(void *pdata, const char *element, const char **attr)
assert(pd->updateinfo);
assert(pd->updaterecord);
assert(pd->updatecollection);
assert(pd->updatecollectionmodule);
assert(pd->updatecollectionpackage);
val = cr_find_attr("type", attr);
if (val)
Expand All @@ -365,7 +364,6 @@ cr_start_handler(void *pdata, const char *element, const char **attr)
assert(pd->updateinfo);
assert(pd->updaterecord);
assert(pd->updatecollection);
assert(pd->updatecollectionmodule);
assert(pd->updatecollectionpackage);
package->reboot_suggested = TRUE;
break;
Expand Down
1 change: 0 additions & 1 deletion tests/test_load_metadata.c
Expand Up @@ -178,7 +178,6 @@ static void test_cr_metadata_locate_and_load_modulemd(void)
{
int ret;
guint size;
cr_Package *pkg;
cr_Metadata *metadata;

metadata = cr_metadata_new(CR_HT_KEY_NAME, 0, NULL);
Expand Down
2 changes: 1 addition & 1 deletion tests/test_locate_metadata.c
Expand Up @@ -146,7 +146,7 @@ static void test_cr_copy_metadatum(void)
static void test_cr_insert_additional_metadatum(void)
{
//add to not allocated GSList
GSList *d;
GSList *d = NULL;
cr_Metadatum *m;

d = cr_insert_additional_metadatum("./test_path.xml", "group", d);
Expand Down
91 changes: 11 additions & 80 deletions tests/test_misc.c
Expand Up @@ -387,6 +387,7 @@ test_cr_get_filename(void)
g_assert_cmpstr(filename, ==, NULL);
}


static int
read_file(char *f, cr_CompressionType compression, char* buffer, int amount)
{
Expand All @@ -398,8 +399,7 @@ read_file(char *f, cr_CompressionType compression, char* buffer, int amount)
ret = tmp_err->code;
return ret;
}
int readed;
readed = cr_read(orig, buffer, amount, &tmp_err);
cr_read(orig, buffer, amount, &tmp_err);
if (orig)
cr_close(orig, NULL);
return ret;
Expand Down Expand Up @@ -559,6 +559,7 @@ compressfile_test_text_file(Copyfiletest *copyfiletest,
g_free(checksum);
}


static void
compressfile_with_stat_test_text_file(Copyfiletest *copyfiletest,
G_GNUC_UNUSED gconstpointer test_data)
Expand All @@ -585,6 +586,7 @@ compressfile_with_stat_test_text_file(Copyfiletest *copyfiletest,
g_assert(!tmp_err);
}


static void
compressfile_with_stat_test_gz_file_gz_output(Copyfiletest *copyfiletest,
G_GNUC_UNUSED gconstpointer test_data)
Expand Down Expand Up @@ -617,6 +619,7 @@ compressfile_with_stat_test_gz_file_gz_output(Copyfiletest *copyfiletest,
g_assert(!tmp_err);
}


static void
compressfile_test_gz_file_xz_output(Copyfiletest *copyfiletest,
G_GNUC_UNUSED gconstpointer test_data)
Expand All @@ -639,6 +642,7 @@ compressfile_test_gz_file_xz_output(Copyfiletest *copyfiletest,
g_assert(!tmp_err);
}


static void
compressfile_test_xz_file_gz_output(Copyfiletest *copyfiletest,
G_GNUC_UNUSED gconstpointer test_data)
Expand Down Expand Up @@ -704,55 +708,6 @@ decompressfile_with_stat_test_text_file(Copyfiletest *copyfiletest,
}



static void
test_cr_download_valid_url_1(Copyfiletest *copyfiletest,
G_GNUC_UNUSED gconstpointer test_data)
{
CURL *handle = curl_easy_init();

g_assert(!g_file_test(copyfiletest->dst_file, G_FILE_TEST_EXISTS));
cr_download(handle, VALID_URL_01, copyfiletest->dst_file, NULL);
curl_easy_cleanup(handle);
g_assert(g_file_test(copyfiletest->dst_file, G_FILE_TEST_EXISTS));
}



static void
test_cr_download_valid_url_2(Copyfiletest *copyfiletest,
G_GNUC_UNUSED gconstpointer test_data)
{
CURL *handle = curl_easy_init();
GError *tmp_err = NULL;

g_assert(!g_file_test(copyfiletest->dst_file, G_FILE_TEST_EXISTS));
cr_download(handle, VALID_URL_01, copyfiletest->tmp_dir, &tmp_err);
curl_easy_cleanup(handle);
g_assert(!tmp_err);
char *dst = g_strconcat(copyfiletest->tmp_dir, "/", URL_FILENAME_01, NULL);
g_assert(g_file_test(dst, G_FILE_TEST_EXISTS));
g_free(dst);
}


static void
test_cr_download_invalid_url(Copyfiletest *copyfiletest,
G_GNUC_UNUSED gconstpointer test_data)
{
CURL *handle = curl_easy_init();
GError *tmp_err = NULL;

g_assert(!g_file_test(copyfiletest->dst_file, G_FILE_TEST_EXISTS));
cr_download(handle, INVALID_URL, copyfiletest->dst_file, &tmp_err);
curl_easy_cleanup(handle);
g_assert(tmp_err);
g_error_free(tmp_err);
g_assert(!g_file_test(copyfiletest->dst_file, G_FILE_TEST_EXISTS));
}



static void
test_cr_better_copy_file_local(Copyfiletest *copyfiletest,
G_GNUC_UNUSED gconstpointer test_data)
Expand All @@ -772,23 +727,6 @@ test_cr_better_copy_file_local(Copyfiletest *copyfiletest,
}



static void
test_cr_better_copy_file_url(Copyfiletest *copyfiletest,
G_GNUC_UNUSED gconstpointer test_data)
{
gboolean ret;
GError *tmp_err = NULL;

g_assert(!g_file_test(copyfiletest->dst_file, G_FILE_TEST_EXISTS));
ret = cr_better_copy_file(VALID_URL_01, copyfiletest->dst_file, &tmp_err);
g_assert(!tmp_err);
g_assert(ret);
g_assert(g_file_test(copyfiletest->dst_file, G_FILE_TEST_IS_REGULAR));
}



static void
test_cr_remove_dir(void)
{
Expand Down Expand Up @@ -1061,6 +999,7 @@ test_cr_cmp_version_str(void)
g_assert_cmpint(ret, ==, 2);
}


static void
test_cr_split_rpm_filename(void)
{
Expand Down Expand Up @@ -1191,6 +1130,7 @@ test_cr_str_to_nevr(void)
cr_nevr_free(res);
}


static void
test_cr_str_to_nevra(void)
{
Expand Down Expand Up @@ -1254,6 +1194,7 @@ test_cr_str_to_nevra(void)
cr_nevra_free(res);
}


static void
test_cr_cmp_evr(void)
{
Expand Down Expand Up @@ -1292,6 +1233,7 @@ test_cr_cmp_evr(void)
g_assert_cmpint(res, ==, 1);
}


static void
test_cr_cut_dirs(void)
{
Expand Down Expand Up @@ -1343,6 +1285,7 @@ test_cr_cut_dirs(void)
g_assert_cmpstr(res, ==, "foo.rpm");
}


int
main(int argc, char *argv[])
{
Expand Down Expand Up @@ -1394,21 +1337,9 @@ main(int argc, char *argv[])
g_test_add("/misc/decompressfile_with_stat_test_text_file",
Copyfiletest, NULL, copyfiletest_setup,
decompressfile_with_stat_test_text_file, copyfiletest_teardown);
// g_test_add("/misc/test_cr_download_valid_url_1",
// Copyfiletest, NULL, copyfiletest_setup,
// test_cr_download_valid_url_1, copyfiletest_teardown);
// g_test_add("/misc/test_cr_download_valid_url_2",
// Copyfiletest, NULL, copyfiletest_setup,
// test_cr_download_valid_url_2, copyfiletest_teardown);
// g_test_add("/misc/test_cr_download_invalid_url",
// Copyfiletest, NULL, copyfiletest_setup,
// test_cr_download_invalid_url, copyfiletest_teardown);
g_test_add("/misc/test_cr_better_copy_file_local",
Copyfiletest, NULL, copyfiletest_setup,
test_cr_better_copy_file_local, copyfiletest_teardown);
// g_test_add("/misc/test_cr_better_copy_file_url",
// Copyfiletest, NULL, copyfiletest_setup,
// test_cr_better_copy_file_url, copyfiletest_teardown);
g_test_add_func("/misc/test_cr_normalize_dir_path",
test_cr_normalize_dir_path);
g_test_add_func("/misc/test_cr_remove_dir",
Expand Down
10 changes: 0 additions & 10 deletions tests/test_sqlite.c
Expand Up @@ -111,15 +111,12 @@ test_cr_db_add_primary_pkg(TestData *testdata,
cr_Package *pkg;

GTimer *timer = g_timer_new();
gdouble topen, tadd, tclean, tmp;

// Create new db

path = g_strconcat(testdata->tmp_dir, "/", TMP_PRIMARY_NAME, NULL);

g_timer_start(timer);
db = cr_db_open_primary(path, &err);
topen = g_timer_elapsed(timer, NULL);
g_assert(db);
g_assert(!err);
g_assert(g_file_test(path, G_FILE_TEST_EXISTS));
Expand All @@ -130,17 +127,10 @@ test_cr_db_add_primary_pkg(TestData *testdata,

// Add package

tmp = g_timer_elapsed(timer, NULL);
cr_db_add_pkg(db, pkg, &err);
tadd = g_timer_elapsed(timer, NULL) - tmp;
g_assert(!err);

tmp = g_timer_elapsed(timer, NULL);
cr_db_close(db, &err);
tclean = g_timer_elapsed(timer, NULL) - tmp;

//printf("Stats:\nOpen: %f\nAdd: %f\nCleanup: %f\nSum: %f\n",
// topen, tadd, tclean, (tadd + tclean));

// Cleanup

Expand Down

0 comments on commit a2d34f7

Please sign in to comment.