From: Michael Tremer Date: Mon, 21 Jun 2021 18:12:32 +0000 (+0000) Subject: libpakfire: Use %m instead of strerror(errno) X-Git-Tag: 0.9.28~1203 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1772bfbf9ff93433ecdc4a935bfd3e12fef91d4;p=pakfire.git libpakfire: Use %m instead of strerror(errno) Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/archive.c b/src/libpakfire/archive.c index 44da6a027..ee43dfad0 100644 --- a/src/libpakfire/archive.c +++ b/src/libpakfire/archive.c @@ -19,7 +19,6 @@ #############################################################################*/ #include -#include #include #include #include @@ -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; } diff --git a/src/libpakfire/build.c b/src/libpakfire/build.c index ba4e9c8ba..f05fc743e 100644 --- a/src/libpakfire/build.c +++ b/src/libpakfire/build.c @@ -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; } diff --git a/src/libpakfire/cgroup.c b/src/libpakfire/cgroup.c index 9a66d20d3..555a75848 100644 --- a/src/libpakfire/cgroup.c +++ b/src/libpakfire/cgroup.c @@ -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; } diff --git a/src/libpakfire/dist.c b/src/libpakfire/dist.c index 80d9e7956..f5ea45a9a 100644 --- a/src/libpakfire/dist.c +++ b/src/libpakfire/dist.c @@ -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; } } diff --git a/src/libpakfire/downloader.c b/src/libpakfire/downloader.c index 9c56818d5..e31b12892 100644 --- a/src/libpakfire/downloader.c +++ b/src/libpakfire/downloader.c @@ -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, ×.modtime); r = utime(transfer->path, ×); - 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; } diff --git a/src/libpakfire/file.c b/src/libpakfire/file.c index 0d038d05e..4bc14f456 100644 --- a/src/libpakfire/file.c +++ b/src/libpakfire/file.c @@ -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 diff --git a/src/libpakfire/filelist.c b/src/libpakfire/filelist.c index 713418167..e9d1a6b50 100644 --- a/src/libpakfire/filelist.c +++ b/src/libpakfire/filelist.c @@ -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; } diff --git a/src/libpakfire/packager.c b/src/libpakfire/packager.c index 9b9e82556..5dd576bd2 100644 --- a/src/libpakfire/packager.c +++ b/src/libpakfire/packager.c @@ -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; } diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index 873ac0b5c..f62adca0d 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -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; } diff --git a/src/libpakfire/parser.c b/src/libpakfire/parser.c index ef44101c6..a0de70487 100644 --- a/src/libpakfire/parser.c +++ b/src/libpakfire/parser.c @@ -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; } diff --git a/src/libpakfire/repo.c b/src/libpakfire/repo.c index ef5126916..4c4528b00 100644 --- a/src/libpakfire/repo.c +++ b/src/libpakfire/repo.c @@ -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; } diff --git a/src/libpakfire/request.c b/src/libpakfire/request.c index 94334cf8e..cd07088b3 100644 --- a/src/libpakfire/request.c +++ b/src/libpakfire/request.c @@ -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; } diff --git a/src/libpakfire/snapshot.c b/src/libpakfire/snapshot.c index 0b9ff9761..e6942d5b9 100644 --- a/src/libpakfire/snapshot.c +++ b/src/libpakfire/snapshot.c @@ -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; } diff --git a/src/libpakfire/transaction.c b/src/libpakfire/transaction.c index bb0634516..f171ca3cd 100644 --- a/src/libpakfire/transaction.c +++ b/src/libpakfire/transaction.c @@ -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; } diff --git a/src/libpakfire/util.c b/src/libpakfire/util.c index eb14f2283..ec1ef369e 100644 --- a/src/libpakfire/util.c +++ b/src/libpakfire/util.c @@ -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; } diff --git a/tests/testsuite.c b/tests/testsuite.c index 29e61537b..37be2bb72 100644 --- a/tests/testsuite.c +++ b/tests/testsuite.c @@ -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); }