Skip to content

Commit

Permalink
Merge pull request #3382 from candlepin/jhnidek/libdnf_small_fixes
Browse files Browse the repository at this point in the history
Small fixes of libdnf plugins
  • Loading branch information
ptoscano authored Mar 6, 2024
2 parents 9d3f9e9 + 01f65d2 commit 4ad1403
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
5 changes: 1 addition & 4 deletions src/plugins/libdnf/product-id.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@
#include <openssl/x509.h>
#include <openssl/err.h>

#include <json-c/json.h>

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <errno.h>
#include <zlib.h>
Expand Down Expand Up @@ -163,7 +160,7 @@ gchar *strHookId(PluginHookId id) {
}
}

RepoProductId *initRepoProductId() {
RepoProductId *initRepoProductId(void) {
RepoProductId *repoProductId = (RepoProductId*) malloc(sizeof(RepoProductId));
repoProductId->repo = NULL;
repoProductId->productIdPath = NULL;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/libdnf/product-id.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ typedef struct {
bool isInstalled;
} RepoProductId;

RepoProductId *initRepoProductId();
RepoProductId *initRepoProductId(void);
void freeRepoProductId(RepoProductId *repoProductId);
void printError(const char *msg, GError *err);
void getEnabled(const GPtrArray *repos, GPtrArray *enabledRepos);
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/libdnf/productdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ void readProductDb(ProductDb *productDb, GError **err) {
if (repoIds == NULL) {
*err = g_error_new_literal(quark, 0, error_string);
g_free(productId);
json_object_put(dbJson);
return;
}
GSList *repoList = NULL;
Expand All @@ -109,6 +110,7 @@ void readProductDb(ProductDb *productDb, GError **err) {
if (idArray == NULL) {
*err = g_error_new_literal(quark, 0, error_string);
g_free(productId);
json_object_put(dbJson);
return;
}
int len = array_list_length(idArray);
Expand All @@ -119,6 +121,7 @@ void readProductDb(ProductDb *productDb, GError **err) {
if (repoId == NULL) {
*err = g_error_new_literal(quark, 0, error_string);
g_free(productId);
json_object_put(dbJson);
return;
}
repoList = g_slist_prepend(repoList, (gpointer) repoId);
Expand Down
1 change: 0 additions & 1 deletion src/plugins/libdnf/test-product-id.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* in this software or its documentation.
*/

#include <stdlib.h>
#include <glib.h>
#include <stdio.h>
#include <gio/gio.h>
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/libdnf/test-productdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/

#include <glib.h>
#include <stdio.h>
#include <gio/gio.h>
#include <string.h>

Expand Down Expand Up @@ -180,6 +179,8 @@ void testReadCorruptedFile(dbFixture *fixture, gconstpointer ignored) {
g_assert_nonnull(err);
g_clear_error(&err);
g_assert_cmpint(g_hash_table_size(db->repoMap), ==, 0);
g_free(path);
g_object_unref(testJsonFile);
}

void testReadFileWrongData(dbFixture *fixture, gconstpointer ignored) {
Expand Down Expand Up @@ -223,6 +224,8 @@ void testReadFileWrongData(dbFixture *fixture, gconstpointer ignored) {
g_clear_error(&err);

g_io_stream_close((GIOStream*) ioStream, NULL, &err);
g_free(path);
g_object_unref(testJsonFile);
}

void testWriteFile(dbFixture *fixture, gconstpointer ignored) {
Expand Down

0 comments on commit 4ad1403

Please sign in to comment.