]> git.ipfire.org Git - pakfire.git/commitdiff
libpakfire: Use %m instead of strerror(errno)
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 21 Jun 2021 18:12:32 +0000 (18:12 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 21 Jun 2021 18:12:32 +0000 (18:12 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
16 files changed:
src/libpakfire/archive.c
src/libpakfire/build.c
src/libpakfire/cgroup.c
src/libpakfire/dist.c
src/libpakfire/downloader.c
src/libpakfire/file.c
src/libpakfire/filelist.c
src/libpakfire/packager.c
src/libpakfire/pakfire.c
src/libpakfire/parser.c
src/libpakfire/repo.c
src/libpakfire/request.c
src/libpakfire/snapshot.c
src/libpakfire/transaction.c
src/libpakfire/util.c
tests/testsuite.c

index 44da6a0277149c8113d05c75f0aaea3093624734..ee43dfad0bb9f5dd18feaf9a3fbf20c093bd8957 100644 (file)
@@ -19,7 +19,6 @@
 #############################################################################*/
 
 #include <ctype.h>
-#include <errno.h>
 #include <fcntl.h>
 #include <gpgme.h>
 #include <stdlib.h>
@@ -1122,7 +1121,7 @@ static int pakfire_archive_load_filelist_legacy(PakfireArchive archive) {
        r = pakfire_filelist_create_from_file(&archive->filelist,
                archive->pakfire, data, archive->format);
        if (r)
-               ERROR(archive->pakfire, "Could not parse filelist: %s\n", strerror(errno));
+               ERROR(archive->pakfire, "Could not parse filelist: %m\n");
 
        if (data)
                free(data);
@@ -1477,8 +1476,7 @@ PAKFIRE_EXPORT size_t pakfire_archive_get_size(PakfireArchive archive) {
 
        int r = stat(archive->path, &buf);
        if (r) {
-               ERROR(archive->pakfire, "Could not stat %s: %s\n",
-                       archive->path, strerror(errno));
+               ERROR(archive->pakfire, "Could not stat %s: %m\n", archive->path);
 
                return -1;
        }
index ba4e9c8ba0dc985a55de1a444816826bdceea58d..f05fc743e35ca4ad7c56cc5d3f236ecfb9a0bc75 100644 (file)
@@ -189,14 +189,14 @@ static int pakfire_build_run_script(Pakfire pakfire, const char* filename, const
        // Open the source script
        FILE* f = fopen(path, "r");
        if (!f) {
-               ERROR(pakfire, "Could not open %s: %s\n", path, strerror(errno));
+               ERROR(pakfire, "Could not open %s: %m\n", path);
                return 1;
        }
 
        // Read the script into memory
        int r = pakfire_read_file_into_buffer(f, &script, &size);
        if (r) {
-               ERROR(pakfire, "Could not read script into memory: %s\n", strerror(errno));
+               ERROR(pakfire, "Could not read script into memory: %m\n");
                goto ERROR;
        }
 
@@ -250,7 +250,7 @@ static int pakfire_build_find_dependencies(Pakfire pakfire,
        r = pakfire_filelist_export(filelist, f);
        fclose(f);
        if (r) {
-               ERROR(pakfire, "Could not export filelist: %s\n", strerror(errno));
+               ERROR(pakfire, "Could not export filelist: %m\n");
                goto ERROR;
        }
 
@@ -388,7 +388,7 @@ static int pakfire_build_package_add_files(Pakfire pakfire, PakfireParser makefi
        // Find dependencies
        r = pakfire_build_find_dependencies(pakfire, pkg, filelist, buildroot);
        if (r) {
-               ERROR(pakfire, "Finding dependencies failed: %s\n", strerror(errno));
+               ERROR(pakfire, "Finding dependencies failed: %m\n");
                goto ERROR;
        }
 
@@ -523,7 +523,7 @@ static int pakfire_build_package_add_scriptlet(Pakfire pakfire, PakfirePackage p
        // Add scriptlet requirements
        r = pakfire_build_add_scriptlet_requires(pakfire, pkg, scriptlet);
        if (r) {
-               ERROR(pakfire, "Could not add scriptlet requirements: %s\n", strerror(errno));
+               ERROR(pakfire, "Could not add scriptlet requirements: %m\n");
                goto ERROR;
        }
 
@@ -578,7 +578,7 @@ static int pakfire_build_package(Pakfire pakfire, PakfireParser makefile,
        // Expand the handle into the package name
        char* name = pakfire_parser_expand(makefile, "packages", namespace);
        if (!name) {
-               ERROR(pakfire, "Could not get package name: %s\n", strerror(errno));
+               ERROR(pakfire, "Could not get package name: %m\n");
                goto ERROR;
        }
 
@@ -597,7 +597,7 @@ static int pakfire_build_package(Pakfire pakfire, PakfireParser makefile,
        // Fetch package from makefile
        r = pakfire_parser_create_package(makefile, &pkg, repo, namespace, arch);
        if (r) {
-               ERROR(pakfire, "Could not create package from makefile: %s\n", strerror(errno));
+               ERROR(pakfire, "Could not create package from makefile: %m\n");
                goto ERROR;
        }
 
@@ -624,7 +624,7 @@ static int pakfire_build_package(Pakfire pakfire, PakfireParser makefile,
        // Write the finished package
        r = pakfire_packager_finish_to_directory(packager, target);
        if (r) {
-               ERROR(pakfire, "pakfire_packager_finish() failed: %s\n", strerror(errno));
+               ERROR(pakfire, "pakfire_packager_finish() failed: %m\n");
                goto ERROR;
        }
 
@@ -660,7 +660,7 @@ static int pakfire_build_packages(Pakfire pakfire, PakfireParser makefile,
        // Fetch a list all all packages
        char** packages = pakfire_parser_list_namespaces(makefile, "packages.package:*");
        if (!packages) {
-               ERROR(pakfire, "Could not find any packages: %s\n", strerror(errno));
+               ERROR(pakfire, "Could not find any packages: %m\n");
                goto ERROR;
        }
 
@@ -704,8 +704,7 @@ static int pakfire_build_stage(Pakfire pakfire, PakfireParser makefile, const ch
        // Create the build script
        char* script = pakfire_parser_expand(makefile, "build", template);
        if (!script) {
-               ERROR(pakfire, "Could not generate the build script for stage '%s': %s\n",
-                       stage, strerror(errno));
+               ERROR(pakfire, "Could not generate the build script for stage '%s': %m\n", stage);
                goto ERROR;
        }
 
@@ -789,8 +788,7 @@ static int pakfire_build_makefile(Pakfire pakfire, const char* path, const char*
                                pakfire_parser_error_get_message(error));
                        pakfire_parser_error_unref(error);
                } else {
-                       ERROR(pakfire, "Could not parse makefile %s: %s\n", path,
-                               strerror(errno));
+                       ERROR(pakfire, "Could not parse makefile %s: %m\n", path);
                }
 
                goto ERROR;
@@ -819,7 +817,7 @@ static int pakfire_build_makefile(Pakfire pakfire, const char* path, const char*
        // Create the packages
        r = pakfire_build_packages(pakfire, makefile, id, buildroot_rel, target);
        if (r) {
-               ERROR(pakfire, "Could not create packages: %s\n", strerror(errno));
+               ERROR(pakfire, "Could not create packages: %m\n");
                goto ERROR;
        }
 
index 9a66d20d32b9f9088d7de0e12907752c16e12566..555a75848ad2b6e2c841d7b0746ce1992f4e14f6 100644 (file)
@@ -117,7 +117,7 @@ static int pakfire_cgroup_supported(Pakfire pakfire) {
                                pakfire_cgroups_supported = 0;
                        }
                } else if (r < 0) {
-                       ERROR(pakfire, "Could not stat %s: %s\n", CGROUP_ROOT, strerror(errno));
+                       ERROR(pakfire, "Could not stat %s: %m\n", CGROUP_ROOT);
                        pakfire_cgroups_supported = 0;
                }
        }
@@ -173,7 +173,7 @@ static FILE* pakfire_cgroup_fopen(Pakfire pakfire,
 
        FILE* f = fopen(path, mode);
        if (!f) {
-               ERROR(pakfire, "Could not open %s: %s\n", path, strerror(errno));
+               ERROR(pakfire, "Could not open %s: %m\n", path);
                return NULL;
        }
 
@@ -294,7 +294,7 @@ int pakfire_cgroup_create(Pakfire pakfire, const char* group) {
                                return 0;
 
                        default:
-                               ERROR(pakfire, "Could not create cgroup %s: %s\n", group, strerror(errno));
+                               ERROR(pakfire, "Could not create cgroup %s: %m\n", group);
                                return r;
                }
        }
@@ -318,7 +318,7 @@ int pakfire_cgroup_destroy(Pakfire pakfire, const char* group) {
        // Remove the directory
        r = rmdir(path);
        if (r) {
-               ERROR(pakfire, "Could not destroy cgroup %s: %s\n", group, strerror(errno));
+               ERROR(pakfire, "Could not destroy cgroup %s: %m\n", group);
                return r;
        }
 
@@ -338,8 +338,7 @@ DIR* pakfire_cgroup_opendir(Pakfire pakfire, const char* group) {
 int pakfire_cgroup_attach(Pakfire pakfire, const char* group, pid_t pid) {
        int r = pakfire_cgroup_fprintf(pakfire, group, "cgroup.procs", "%d", pid);
        if (r < 0) {
-               ERROR(pakfire, "Could not attach process %d to cgroup %s: %s\n",
-                       pid, group, strerror(errno));
+               ERROR(pakfire, "Could not attach process %d to cgroup %s: %m\n", pid, group);
                return r;
        }
 
@@ -421,8 +420,7 @@ static int send_signal(Pakfire pakfire, pid_t pid, void* data) {
 
        int r = kill(pid, *signum);
        if (r < 0 && errno != ESRCH) {
-               ERROR(pakfire, "Could not send signal %d to PID %d: %s\n",
-                       *signum, pid, strerror(errno));
+               ERROR(pakfire, "Could not send signal %d to PID %d: %m\n", *signum, pid);
                return r;
        }
 
@@ -502,8 +500,7 @@ int pakfire_cgroup_set_nice(Pakfire pakfire, const char* group, int level) {
 
        int r = pakfire_cgroup_fprintf(pakfire, group, "cpu.weight.nice", "%d", level);
        if (r) {
-               ERROR(pakfire, "Could not change nice level of cgroup %s: %s\n",
-                       group, strerror(errno));
+               ERROR(pakfire, "Could not change nice level of cgroup %s: %m\n", group);
                return r;
        }
 
index 80d9e795647cf808b4a6a8d10f90abcece21657c..f5ea45a9ae555cb6b27aeb9e4632a0ff2e5b35a2 100644 (file)
@@ -287,7 +287,7 @@ static int pakfire_dist_add_sources(Pakfire pakfire, struct pakfire_packager* pa
 
                r = pakfire_dist_add_source(pakfire, packager, pkg, downloader, mirrorlist, *source);
                if (r) {
-                       ERROR(pakfire, "Could not add '%s' to package: %s\n", *source, strerror(errno));
+                       ERROR(pakfire, "Could not add '%s' to package: %m\n", *source);
                        goto ERROR;
                }
        }
index 9c56818d55190727bd1b7db9763859d076893bbd..e31b1289241d14fb8e2fce0005d2a6c54275bf12 100644 (file)
@@ -424,8 +424,8 @@ static int pakfire_transfer_save(struct pakfire_downloader* downloader,
                // Move the temporary file to its destination
                r = link(transfer->tempfile, transfer->path);
                if (r) {
-                       ERROR(downloader->pakfire, "Could not link destination file %s: %s\n",
-                               transfer->path, strerror(errno));
+                       ERROR(downloader->pakfire, "Could not link destination file %s: %m\n",
+                               transfer->path);
                        return r;
                }
        }
@@ -433,10 +433,8 @@ static int pakfire_transfer_save(struct pakfire_downloader* downloader,
        // Filetime
        curl_easy_getinfo(transfer->handle, CURLINFO_FILETIME_T, &times.modtime);
        r = utime(transfer->path, &times);
-       if (r) {
-               ERROR(downloader->pakfire, "Could not set mtime of %s: %s\n",
-                       transfer->path, strerror(errno));
-       }
+       if (r)
+               ERROR(downloader->pakfire, "Could not set mtime of %s: %m\n", transfer->path);
 
        return 0;
 }
@@ -580,8 +578,7 @@ static int pakfire_downloader_prepare_transfer(struct pakfire_downloader* downlo
 
                char* url = pakfire_url_join(transfer->mirror->url, transfer->url);
                if (!url) {
-                       ERROR(downloader->pakfire, "Error composing download URL: %s\n",
-                               strerror(errno));
+                       ERROR(downloader->pakfire, "Error composing download URL: %m\n");
                        return 1;
                }
 
@@ -592,8 +589,7 @@ static int pakfire_downloader_prepare_transfer(struct pakfire_downloader* downlo
        } else if (*transfer->baseurl) {
                char* url = pakfire_url_join(transfer->baseurl, transfer->url);
                if (!url) {
-                       ERROR(downloader->pakfire, "Error composing download URL: %s\n",
-                               strerror(errno));
+                       ERROR(downloader->pakfire, "Error composing download URL: %m\n");
                        return 1;
                }
 
@@ -615,8 +611,8 @@ static int pakfire_downloader_prepare_transfer(struct pakfire_downloader* downlo
 
                transfer->f = pakfire_mktemp(transfer->tempfile);
                if (!transfer->f) {
-                       ERROR(downloader->pakfire, "Could not create temporary file for download %s: %s\n",
-                               transfer->tempfile, strerror(errno));
+                       ERROR(downloader->pakfire, "Could not create temporary file for download %s: %m\n",
+                               transfer->tempfile);
                        return 1;
                }
        }
@@ -919,8 +915,7 @@ int pakfire_mirrorlist_read(struct pakfire_mirrorlist* ml, const char* path) {
 
        struct json_object* json = pakfire_json_parse_from_file(ml->pakfire, path);
        if (!json) {
-               ERROR(ml->pakfire, "Could not parse mirrorlist from %s: %s\n",
-                       path, strerror(errno));
+               ERROR(ml->pakfire, "Could not parse mirrorlist from %s: %m\n", path);
                return 1;
        }
 
@@ -960,8 +955,7 @@ int pakfire_mirrorlist_read(struct pakfire_mirrorlist* ml, const char* path) {
                // Add the mirror to the downloader
                r = pakfire_mirrorlist_add_mirror(ml, url);
                if (r) {
-                       ERROR(ml->pakfire, "Could not add mirror %s: %s\n",
-                               url, strerror(errno));
+                       ERROR(ml->pakfire, "Could not add mirror %s: %m\n", url);
                        goto NEXT;
                }
 
index 0d038d05ed77760dd34ba3a933782001f29883bf..4bc14f4568d7cdd5ac7d2ac4e2b90355f3809655 100644 (file)
@@ -295,8 +295,7 @@ int pakfire_file_cleanup(struct pakfire_file* file) {
                if (errno == ENOTEMPTY)
                        return 0;
 
-               ERROR(file->pakfire, "Could not remove %s (%s): %s\n",
-                       file->path, file->abspath, strerror(errno));
+               ERROR(file->pakfire, "Could not remove %s (%s): %m\n", file->path, file->abspath);
        }
 
        // Create a working copy of abspath
index 713418167bdc164d163919dd9a180f29a53e9abc..e9d1a6b507ae338f95b44000214fc08a8e39cd8d 100644 (file)
@@ -444,8 +444,7 @@ int pakfire_filelist_scan(PakfireFilelist list, const char* root,
 
                r = archive_read_disk_entry_from_file(reader, entry, -1, node->fts_statp);
                if (r) {
-                       ERROR(list->pakfire, "Could not read from %s: %s\n",
-                               node->fts_path, strerror(errno));
+                       ERROR(list->pakfire, "Could not read from %s: %m\n", node->fts_path);
                        goto ERROR;
                }
 
index 9b9e82556ed42fb71fc4432dbd20fb97daab61e8..5dd576bd2352d40b1e326d6b7885881384293bad 100644 (file)
@@ -338,7 +338,7 @@ static int pakfire_packager_copy_data(struct pakfire_packager* packager,
 
                // Check if any error occured
                if (ferror(f)) {
-                       ERROR(packager->pakfire, "Error reading from file: %s\n", strerror(errno));
+                       ERROR(packager->pakfire, "Error reading from file: %m\n");
                        return 1;
                }
 
@@ -684,7 +684,7 @@ static int pakfire_packager_write_archive(struct pakfire_packager* packager,
        // Stat the payload file
        int r = fstat(fd, &st);
        if (r) {
-               ERROR(packager->pakfire, "stat() on fd %d failed: %s\n", fd, strerror(errno));
+               ERROR(packager->pakfire, "stat() on fd %d failed: %m\n", fd);
                return 1;
        }
 
@@ -856,8 +856,7 @@ int pakfire_packager_finish(struct pakfire_packager* packager, FILE* f) {
        for (unsigned int i = 0; i < packager->num_scriptlets; i++) {
                r = pakfire_packager_write_scriptlet(packager, a, mtree, packager->scriptlets[i]);
                if (r) {
-                       ERROR(packager->pakfire, "Could not add scriptlet to the archive: %s\n",
-                               strerror(errno));
+                       ERROR(packager->pakfire, "Could not add scriptlet to the archive: %m\n");
                        goto ERROR;
                }
        }
@@ -908,8 +907,7 @@ int pakfire_packager_finish_to_directory(struct pakfire_packager* packager,
        // Get the filename of the package
        const char* filename = pakfire_packager_filename(packager);
        if (!filename) {
-               ERROR(packager->pakfire, "Could not generate filename for package: %s\n",
-                       strerror(errno));
+               ERROR(packager->pakfire, "Could not generate filename for package: %m\n");
                r = 1;
                goto ERROR;
        }
@@ -939,16 +937,14 @@ int pakfire_packager_finish_to_directory(struct pakfire_packager* packager,
        fclose(f);
 
        if (r) {
-               ERROR(packager->pakfire, "pakfire_packager_finish() failed: %s\n",
-                       strerror(errno));
+               ERROR(packager->pakfire, "pakfire_packager_finish() failed: %m\n");
                goto ERROR;
        }
 
        // Move the temporary file to destination
        r = rename(tmppath, path);
        if (r) {
-               ERROR(packager->pakfire, "Could not move %s to %s: %s\n",
-                       tmppath, path, strerror(errno));
+               ERROR(packager->pakfire, "Could not move %s to %s: %m\n", tmppath, path);
                goto ERROR;
        }
 
@@ -1001,8 +997,7 @@ int pakfire_packager_add(struct pakfire_packager* packager,
        // Read all attributes from file
        int r = archive_read_disk_entry_from_file(packager->reader, entry, -1, NULL);
        if (r) {
-               ERROR(packager->pakfire, "Could not read attributes from %s: %s\n",
-                       path, strerror(errno));
+               ERROR(packager->pakfire, "Could not read attributes from %s: %m\n", path);
                goto ERROR;
        }
 
@@ -1018,7 +1013,7 @@ int pakfire_packager_add(struct pakfire_packager* packager,
        if (archive_entry_filetype(entry) == AE_IFREG) {
                f = fopen(sourcepath, "r");
                if (!f) {
-                       ERROR(packager->pakfire, "Could not open %s: %s\n", sourcepath, strerror(errno));
+                       ERROR(packager->pakfire, "Could not open %s: %m\n", sourcepath);
                        r = errno;
                        goto ERROR;
                }
index 873ac0b5c56c1843c877764878cd698fd98954dc..f62adca0df921c9ae73fbf17a70bd173af0e865c 100644 (file)
@@ -207,7 +207,7 @@ RETRY:
                                goto RETRY;
                        }
 
-                       ERROR(pakfire, "Could not mount /%s: %s\n", mp->target, strerror(errno));
+                       ERROR(pakfire, "Could not mount /%s: %m\n", mp->target);
                        return r;
                }
        }
@@ -243,7 +243,7 @@ RETRY:
                                goto RETRY;
                        }
 
-                       ERROR(pakfire, "Could not umount %s: %s\n", mp->path, strerror(errno));
+                       ERROR(pakfire, "Could not umount %s: %m\n", mp->path);
                }
 
                free(mp);
@@ -310,7 +310,7 @@ static int pakfire_populate_dev(Pakfire pakfire) {
 
                r = mknod(path, devnode->mode, dev);
                if (r) {
-                       ERROR(pakfire, "Could not create %s: %s\n", devnode->path, strerror(errno));
+                       ERROR(pakfire, "Could not create %s: %m\n", devnode->path);
                        return r;
                }
        }
@@ -325,7 +325,7 @@ static int pakfire_populate_dev(Pakfire pakfire) {
 
                r = symlink(s->target, path);
                if (r) {
-                       ERROR(pakfire, "Could not create symlink %s: %s\n", s->path, strerror(errno));
+                       ERROR(pakfire, "Could not create symlink %s: %m\n", s->path);
                        return r;
                }
        }
@@ -480,8 +480,7 @@ static int pakfire_mount_interpreter(Pakfire pakfire) {
 
        r = __mount(pakfire, interpreter, target, NULL, MS_BIND|MS_RDONLY, NULL);
        if (r)
-               ERROR(pakfire, "Could not mount interpreter %s to %s: %s\n",
-                       interpreter, target, strerror(errno));
+               ERROR(pakfire, "Could not mount interpreter %s to %s: %m\n", interpreter, target);
 
        return r;
 }
@@ -683,14 +682,14 @@ static int pakfire_read_config(Pakfire pakfire, const char* path) {
                if (*default_path && errno == ENOENT)
                        return 0;
 
-               ERROR(pakfire, "Could not open configuration file %s: %s\n", path, strerror(errno));
+               ERROR(pakfire, "Could not open configuration file %s: %m\n", path);
                return 1;
        }
 
        // Read configuration from file
        int r = pakfire_config_read(pakfire->config, f);
        if (r) {
-               ERROR(pakfire, "Could not parse configuration file %s: %s\n", path, strerror(errno));
+               ERROR(pakfire, "Could not parse configuration file %s: %m\n", path);
                goto ERROR;
        }
 
@@ -729,7 +728,7 @@ static int pakfire_read_os_release(Pakfire pakfire) {
                        goto ERROR;
                }
 
-               ERROR(pakfire, "Could not open %s: %s\n", path, strerror(errno));
+               ERROR(pakfire, "Could not open %s: %m\n", path);
                goto ERROR;
        }
 
@@ -931,7 +930,7 @@ PAKFIRE_EXPORT int pakfire_create(Pakfire* pakfire, const char* path, const char
        // Make sure that our private directory exists
        r = pakfire_mkdir(private_dir, 0);
        if (r && errno != EEXIST) {
-               ERROR(p, "Could not create private directory %s: %s\n", private_dir, strerror(errno));
+               ERROR(p, "Could not create private directory %s: %m\n", private_dir);
                goto ERROR;
        }
 
@@ -1018,7 +1017,7 @@ PAKFIRE_EXPORT int pakfire_bind(Pakfire pakfire, const char* src, const char* ds
 
        r = stat(src, &st);
        if (r < 0) {
-               ERROR(pakfire, "Could not stat %s: %s\n", src, strerror(errno));
+               ERROR(pakfire, "Could not stat %s: %m\n", src);
                return 1;
        }
 
@@ -1122,7 +1121,7 @@ static int pakfire_copy(Pakfire pakfire, const char* src, const char* dst) {
        // Read everything from source file
        r = archive_read_disk_entry_from_file(reader, entry, -1, NULL);
        if (r) {
-               ERROR(pakfire, "Could not read from %s: %s", src, strerror(errno));
+               ERROR(pakfire, "Could not read from %s: %m", src);
                goto ERROR;
        }
 
@@ -1132,7 +1131,7 @@ static int pakfire_copy(Pakfire pakfire, const char* src, const char* dst) {
        // Write file to destination
        r = archive_write_header(writer, entry);
        if (r) {
-               ERROR(pakfire, "Could not write %s: %s\n", dst, strerror(errno));
+               ERROR(pakfire, "Could not write %s: %m\n", dst);
                goto ERROR;
        }
 
@@ -1147,7 +1146,7 @@ static int pakfire_copy(Pakfire pakfire, const char* src, const char* dst) {
 
                        // Check if any error occured
                        if (ferror(f)) {
-                               ERROR(pakfire, "Error reading from file: %s\n", strerror(errno));
+                               ERROR(pakfire, "Error reading from file: %m\n");
                                goto ERROR;
                        }
 
@@ -1484,7 +1483,7 @@ static const char* pakfire_user_lookup(void* data, la_int64_t uid) {
        // Find a matching entry in /etc/passwd
        struct passwd* entry = pakfire_getpwuid(pakfire, uid);
        if (!entry) {
-               ERROR(pakfire, "Could not retrieve uname for %ld: %s\n", uid, strerror(errno));
+               ERROR(pakfire, "Could not retrieve uname for %ld: %m\n", uid);
                return 0;
        }
 
@@ -1503,7 +1502,7 @@ static const char* pakfire_group_lookup(void* data, la_int64_t gid) {
        // Find a matching entry in /etc/group
        struct group* entry = pakfire_getgrgid(pakfire, gid);
        if (!entry) {
-               ERROR(pakfire, "Could not retrieve gname for %ld: %s\n", gid, strerror(errno));
+               ERROR(pakfire, "Could not retrieve gname for %ld: %m\n", gid);
                return 0;
        }
 
@@ -1547,7 +1546,7 @@ static la_int64_t pakfire_uid_lookup(void* data, const char* name, la_int64_t ui
        // Find a matching entry in /etc/passwd
        struct passwd* entry = pakfire_getpwnam(pakfire, name);
        if (!entry) {
-               ERROR(pakfire, "Could not retrieve UID for '%s': %s\n", name, strerror(errno));
+               ERROR(pakfire, "Could not retrieve UID for '%s': %m\n", name);
                return 0;
        }
 
@@ -1566,7 +1565,7 @@ static la_int64_t pakfire_gid_lookup(void* data, const char* name, la_int64_t ui
        // Find a matching entry in /etc/group
        struct group* entry = pakfire_getgrnam(pakfire, name);
        if (!entry) {
-               ERROR(pakfire, "Could not retrieve GID for '%s': %s\n", name, strerror(errno));
+               ERROR(pakfire, "Could not retrieve GID for '%s': %m\n", name);
                return 0;
        }
 
index ef44101c691466d3011b78a5bfd4c75177fe7281..a0de7048741fc507c274a1e2a801be0216b58132 100644 (file)
@@ -679,7 +679,7 @@ PAKFIRE_EXPORT char** pakfire_parser_list_namespaces(PakfireParser parser,
 
                        // Check for any errors
                        else if (r > 0) {
-                               ERROR(parser->pakfire, "fnmatch failed: %s\n", strerror(errno));
+                               ERROR(parser->pakfire, "fnmatch failed: %m\n");
                                if (namespaces)
                                        free(namespaces);
 
@@ -939,7 +939,7 @@ PAKFIRE_EXPORT int pakfire_parser_create_package(PakfireParser parser,
        // Assign a new UUID to this package
        char* uuid = pakfire_generate_uuid();
        if (!uuid) {
-               ERROR(parser->pakfire, "Generating a UUID failed: %s\n", strerror(errno));
+               ERROR(parser->pakfire, "Generating a UUID failed: %m\n");
                goto CLEANUP;
        }
 
@@ -950,7 +950,7 @@ PAKFIRE_EXPORT int pakfire_parser_create_package(PakfireParser parser,
        char hostname[HOST_NAME_MAX + 1];
        r = gethostname(hostname, HOST_NAME_MAX + 1);
        if (r) {
-               ERROR(parser->pakfire, "gethostname() failed: %s\n", strerror(errno));
+               ERROR(parser->pakfire, "gethostname() failed: %m\n");
                goto CLEANUP;
        }
 
index ef51269166ce169db4a63dd9145909a9630f67f2..4c4528b00156693ddf2a5defdeae890868ea9681 100644 (file)
@@ -109,7 +109,7 @@ int pakfire_repo_import(Pakfire pakfire, struct pakfire_config* config) {
                // Create a new repository
                PakfireRepo repo = pakfire_repo_create(pakfire, name);
                if (!repo) {
-                       ERROR(pakfire, "Could not create repository '%s': %s\n", name, strerror(errno));
+                       ERROR(pakfire, "Could not create repository '%s': %m\n", name);
                        r = 1;
                        goto ERROR;
                }
@@ -161,15 +161,15 @@ struct pakfire_mirrorlist* pakfire_repo_get_mirrorlist(PakfireRepo repo) {
 
                int r = pakfire_mirrorlist_create(&repo->mirrorlist, repo->pakfire);
                if (r) {
-                       ERROR(repo->pakfire, "Could not create mirrorlist: %s\n", strerror(errno));
+                       ERROR(repo->pakfire, "Could not create mirrorlist: %m\n");
                        return NULL;
                }
 
                // Read the mirrorlist
                r = pakfire_mirrorlist_read(repo->mirrorlist, repo->appdata->mirrorlist);
                if (r) {
-                       ERROR(repo->pakfire, "Could not read mirrorlist %s: %s\n",
-                               repo->appdata->mirrorlist, strerror(errno));
+                       ERROR(repo->pakfire, "Could not read mirrorlist %s: %m\n",
+                               repo->appdata->mirrorlist);
 
                        // Destroy what we have created
                        pakfire_mirrorlist_unref(repo->mirrorlist);
@@ -234,7 +234,7 @@ static int pakfire_repo_read_metadata(PakfireRepo repo, const char* path, int re
                if (!refresh && errno == ENOENT)
                        return 0;
 
-               ERROR(repo->pakfire, "Could not parse metadata from %s: %s\n", path, strerror(errno));
+               ERROR(repo->pakfire, "Could not parse metadata from %s: %m\n", path);
                return 1;
        }
 
@@ -274,8 +274,7 @@ static int pakfire_repo_read_metadata(PakfireRepo repo, const char* path, int re
                        if (!refresh && errno == ENOENT)
                                goto NOERROR;
 
-                       ERROR(repo->pakfire, "Could not read SOLV file %s: %s\n",
-                               database_cache_path, strerror(errno));
+                       ERROR(repo->pakfire, "Could not read SOLV file %s: %m\n", database_cache_path);
                        goto ERROR;
                }
        }
@@ -399,7 +398,7 @@ PAKFIRE_EXPORT PakfireRepo pakfire_repo_create(Pakfire pakfire, const char* name
        // Allocate a libsolv repository
        repo->repo = repo_create(pool, name);
        if (!repo->repo) {
-               ERROR(repo->pakfire, "Could not allocate repo: %s\n", strerror(errno));
+               ERROR(repo->pakfire, "Could not allocate repo: %m\n");
                goto ERROR;
        }
 
@@ -434,8 +433,7 @@ PAKFIRE_EXPORT PakfireRepo pakfire_repo_create(Pakfire pakfire, const char* name
        // Try loading metadata
        r = pakfire_repo_read_metadata(repo, repo->appdata->metadata, 0);
        if (r) {
-               ERROR(repo->pakfire, "Could not initialize repository metadata: %s\n",
-                       strerror(errno));
+               ERROR(repo->pakfire, "Could not initialize repository metadata: %m\n");
                goto ERROR;
        }
 
index 94334cf8ea4c6de3805095aededfe93f8641c358..cd07088b3cd338b012d0226de651c4afbd03bab7 100644 (file)
@@ -195,7 +195,7 @@ static int solve(struct pakfire_request* request, Queue* queue) {
 PAKFIRE_EXPORT int pakfire_request_solve(struct pakfire_request* request, int flags) {
        int r = init_solver(request, flags);
        if (r) {
-               ERROR(request->pakfire, "Could not initialize the solver: %s\n", strerror(errno));
+               ERROR(request->pakfire, "Could not initialize the solver: %m\n");
                return r;
        }
 
index 0b9ff97616a837cd6aac247205e18f5b89301191..e6942d5b924ad43a6b8fb5414f355a639279423a 100644 (file)
@@ -219,7 +219,7 @@ static int pakfire_snapshot_extract(Pakfire pakfire, FILE* f) {
        // Stat the input file
        r = fstat(fileno(f), &st);
        if (r) {
-               ERROR(pakfire, "Could not stat snapshot: %s\n", strerror(errno));
+               ERROR(pakfire, "Could not stat snapshot: %m\n");
                return 1;
        }
 
index bb0634516486907ca9a7380f83ed41612b4f33fc..f171ca3cdddb906d3768d887fc770836415c3460 100644 (file)
@@ -484,8 +484,8 @@ static int pakfire_transaction_extract(struct pakfire_transaction* transaction,
        // Extract payload to the root of the Pakfire instance
        int r = pakfire_archive_extract(archive, NULL);
        if (r) {
-               ERROR(transaction->pakfire, "Could not extract package %s: %s\n",
-                       pakfire_package_get_nevra(pkg), strerror(errno));
+               ERROR(transaction->pakfire, "Could not extract package %s: %m\n",
+                       pakfire_package_get_nevra(pkg));
                return r;
        }
 
@@ -698,7 +698,7 @@ static int pakfire_transaction_run_steps(struct pakfire_transaction* transaction
 
                // End loop if action was unsuccessful
                if (r) {
-                       DEBUG(transaction->pakfire, "Step %d failed: %s\n", i, strerror(errno));
+                       DEBUG(transaction->pakfire, "Step %d failed: %m\n", i);
                        break;
                }
        }
@@ -729,8 +729,8 @@ static int pakfire_transaction_open_archives(struct pakfire_transaction* transac
 
                transaction->archives[i] = pakfire_package_get_archive(pkg);
                if (!transaction->archives[i]) {
-                       ERROR(transaction->pakfire, "Could not open archive for %s: %s\n",
-                               pakfire_package_get_nevra(pkg), strerror(errno));
+                       ERROR(transaction->pakfire, "Could not open archive for %s: %m\n",
+                               pakfire_package_get_nevra(pkg));
                        return 1;
                }
        }
@@ -876,8 +876,7 @@ PAKFIRE_EXPORT int pakfire_transaction_download(struct pakfire_transaction* tran
        // Initialize the downloader
        r = pakfire_downloader_create(&downloader, transaction->pakfire);
        if (r) {
-               ERROR(transaction->pakfire, "Could not initialize downloader: %s\n",
-                       strerror(errno));
+               ERROR(transaction->pakfire, "Could not initialize downloader: %m\n");
                return 1;
        }
 
index eb14f2283e9c94339616e1b92d6f668572485eb4..ec1ef369e41bc6e9bcae2c3006a5bf3996f070be 100644 (file)
@@ -779,7 +779,7 @@ static struct json_object* pakfire_json_parse(Pakfire pakfire, FILE* f) {
        // Create tokener
        tokener = json_tokener_new();
        if (!tokener) {
-               ERROR(pakfire, "Could not allocate JSON tokener: %s\n", strerror(errno));
+               ERROR(pakfire, "Could not allocate JSON tokener: %m\n");
                goto ERROR;
        }
 
@@ -874,7 +874,7 @@ int pakfire_rlimit_set(Pakfire pakfire, int limit) {
 
        // Fetch current configuration
        if (getrlimit(RLIMIT_NOFILE, &rl) < 0) {
-               ERROR(pakfire, "Could not read RLIMIT_NOFILE: %s\n", strerror(errno));
+               ERROR(pakfire, "Could not read RLIMIT_NOFILE: %m\n");
                return 1;
        }
 
@@ -886,8 +886,7 @@ int pakfire_rlimit_set(Pakfire pakfire, int limit) {
 
        // Set the new limit
        if (setrlimit(RLIMIT_NOFILE, &rl) < 0) {
-               ERROR(pakfire, "Could not set RLIMIT_NOFILE to %lu: %s\n",
-                       rl.rlim_cur, strerror(errno));
+               ERROR(pakfire, "Could not set RLIMIT_NOFILE to %lu: %m\n", rl.rlim_cur);
                return 1;
        }
 
index 29e61537b74c47bfbe6d921f068a82e4e50800d7..37be2bb727a964f0957c870f99323729ce5075c8 100644 (file)
@@ -48,7 +48,7 @@ static int test_run(int i, struct test* t) {
        r = pakfire_create(&t->pakfire, root, NULL, TEST_SRC_PATH "/pakfire.conf", 0,
                pakfire_log_stderr, NULL);
        if (r) {
-               LOG("ERROR: Could not initialize Pakfire: %s\n", strerror(errno));
+               LOG("ERROR: Could not initialize Pakfire: %m\n");
                exit(1);
        }