]> git.ipfire.org Git - pakfire.git/commitdiff
archive: Drop own errno implmenetation
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 6 Apr 2021 17:17:40 +0000 (17:17 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 6 Apr 2021 17:17:40 +0000 (17:17 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/archive.c
src/libpakfire/include/pakfire/errno.h

index baf362e6c2ee44abd42c02655d24ed52b09ba2fb..43b18f926d06f3534c65a9274a0b060140e2eed4 100644 (file)
@@ -38,7 +38,6 @@
 #include <openssl/evp.h>
 
 #include <pakfire/archive.h>
-#include <pakfire/errno.h>
 #include <pakfire/file.h>
 #include <pakfire/filelist.h>
 #include <pakfire/i18n.h>
@@ -602,10 +601,10 @@ static int pakfire_archive_read_metadata_entry(PakfireArchive archive, struct ar
                if (strcmp(PAKFIRE_ARCHIVE_FN_FORMAT, entry_name) == 0) {
                        ret = pakfire_archive_parse_entry_format(archive, a, e);
                        if (ret)
-                               return PAKFIRE_E_PKG_INVALID;
+                               return EINVAL;
 
                } else {
-                       return PAKFIRE_E_PKG_INVALID;
+                       return EINVAL;
                }
 
        // If the format is set, we can go on...
@@ -614,25 +613,25 @@ static int pakfire_archive_read_metadata_entry(PakfireArchive archive, struct ar
                if (strcmp(PAKFIRE_ARCHIVE_FN_METADATA, entry_name) == 0) {
                        ret = pakfire_archive_parse_entry_metadata(archive, a, e);
                        if (ret)
-                               return PAKFIRE_E_PKG_INVALID;
+                               return EINVAL;
 
                // Parse the filelist
                } else if (strcmp(PAKFIRE_ARCHIVE_FN_FILELIST, entry_name) == 0) {
                        ret = pakfire_archive_parse_entry_filelist(archive, a, e);
                        if (ret)
-                               return PAKFIRE_E_PKG_INVALID;
+                               return EINVAL;
 
                // Parse the checksums
                } else if (strcmp(PAKFIRE_ARCHIVE_FN_CHECKSUMS, entry_name) == 0) {
                        ret = pakfire_archive_parse_entry_checksums(archive, a, e);
                        if (ret)
-                               return PAKFIRE_E_PKG_INVALID;
+                               return EINVAL;
 
                // Parse the scriptlets
                } else if (pakfire_string_startswith(entry_name, "scriptlets/")) {
                        ret = pakfire_archive_parse_entry_scriptlet(archive, a, e, entry_name);
                        if (ret)
-                               return PAKFIRE_E_PKG_INVALID;
+                               return EINVAL;
                }
        }
 
@@ -895,10 +894,8 @@ PAKFIRE_EXPORT PakfireArchive pakfire_archive_open(Pakfire pakfire, const char*
        // Stat the file and store the result
        int r = stat(archive->path, &archive->stat);
        if (r) {
-               pakfire_errno = errno;
-
                ERROR(pakfire, "Could not stat %s: %s\n",
-                       archive->path, strerror(pakfire_errno));
+                       archive->path, strerror(errno));
 
                goto error;
        }
@@ -906,17 +903,13 @@ PAKFIRE_EXPORT PakfireArchive pakfire_archive_open(Pakfire pakfire, const char*
        // Open the archive file for reading.
        struct archive* a;
        r = archive_open(archive, &a);
-       if (r) {
-               pakfire_errno = PAKFIRE_E_PKG_INVALID;
+       if (r)
                goto error;
-       }
 
        // Parse all entries in the archive.
        r = pakfire_archive_read_metadata(archive, a);
        if (r) {
                ERROR(pakfire, "Could not read metadata from %s\n", archive->path);
-
-               pakfire_errno = PAKFIRE_E_PKG_INVALID;
                goto error;
        }
 
@@ -939,17 +932,13 @@ static struct archive* archive_open_payload(struct archive* a) {
        int r;
 
        r = find_archive_entry(&entry, a, PAKFIRE_ARCHIVE_FN_PAYLOAD);
-       if (r) {
-               pakfire_errno = r;
+       if (r)
                return NULL;
-       }
 
        struct archive* payload_archive;
        r = payload_archive_open(&payload_archive, a);
-       if (r) {
-               pakfire_errno = r;
+       if (r)
                return NULL;
-       }
 
        return payload_archive;
 }
@@ -961,10 +950,8 @@ PAKFIRE_EXPORT int pakfire_archive_read(PakfireArchive archive, const char* file
        struct archive_entry* entry;
 
        int r = archive_open(archive, &a);
-       if (r) {
-               pakfire_errno = r;
+       if (r)
                goto out;
-       }
 
        int use_payload = (flags & PAKFIRE_ARCHIVE_USE_PAYLOAD);
 
@@ -1028,10 +1015,8 @@ PAKFIRE_EXPORT int pakfire_archive_extract(PakfireArchive archive, const char* p
        struct archive* pa = NULL;
 
        int r = archive_open(archive, &a);
-       if (r) {
-               pakfire_errno = r;
+       if (r)
                return 1;
-       }
 
        int use_payload = (flags & PAKFIRE_ARCHIVE_USE_PAYLOAD);
 
@@ -1112,7 +1097,7 @@ static int pakfire_archive_read_signature_entry(PakfireArchive archive, struct a
        if (strncmp(PAKFIRE_ARCHIVE_FN_SIGNATURES, entry_name, strlen(PAKFIRE_ARCHIVE_FN_SIGNATURES)) == 0) {
                int ret = pakfire_archive_parse_entry_signature(archive, a, e);
                if (ret)
-                       return PAKFIRE_E_PKG_INVALID;
+                       return EINVAL;
        }
 
        return 0;
@@ -1277,7 +1262,6 @@ static pakfire_archive_verify_status_t pakfire_archive_verify_file(Pakfire pakfi
                        break;
 
                if (r != ARCHIVE_OK) {
-                       pakfire_errno = r;
                        status = PAKFIRE_ARCHIVE_VERIFY_ERROR;
                        goto ERROR;
                }
@@ -1328,10 +1312,8 @@ PAKFIRE_EXPORT pakfire_archive_verify_status_t pakfire_archive_verify(PakfireArc
        // Open the archive file
        struct archive* a;
        int r = archive_open(archive, &a);
-       if (r) {
-               pakfire_errno = r;
+       if (r)
                return PAKFIRE_ARCHIVE_VERIFY_ERROR;
-       }
 
        struct archive_entry* entry;
        while ((r = archive_read_next_header(a, &entry)) == ARCHIVE_OK) {
index f112d81291d6406427b76599093f7e002125272d..cff789fa9e1373fa80dd86a70901ac0466c59a6b 100644 (file)
@@ -28,7 +28,6 @@ enum _pakfire_errors {
        PAKFIRE_E_IO,                                                   // I/O error
        PAKFIRE_E_ARCH,
        PAKFIRE_E_SELECTOR,
-       PAKFIRE_E_PKG_INVALID,                                  // when a package is not in the pakfire format
        PAKFIRE_E_EOF,
        PAKFIRE_E_SOLV_NOT_SOLV,                                // SOLV file in not in SOLV format
        PAKFIRE_E_SOLV_UNSUPPORTED,                             // SOLV file is in an unsupported format