From: Michael Tremer Date: Wed, 31 Aug 2022 10:45:03 +0000 (+0000) Subject: file: Log an error message when setting path fails X-Git-Tag: 0.9.28~355 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12a327de71697fb666a06669a4ad1d4183479262;p=pakfire.git file: Log an error message when setting path fails Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/file.c b/src/libpakfire/file.c index 9470af704..0f9020ba5 100644 --- a/src/libpakfire/file.c +++ b/src/libpakfire/file.c @@ -381,27 +381,31 @@ PAKFIRE_EXPORT const char* pakfire_file_get_path(struct pakfire_file* file) { } PAKFIRE_EXPORT int pakfire_file_set_path(struct pakfire_file* file, const char* path) { - int r; + int r = 1; // Check if path is set and absolute if (!path || *path != '/') { errno = EINVAL; - return 1; + goto ERROR; } // Store path r = pakfire_string_set(file->path, path); if (r) - return r; + goto ERROR; // Set abspath if it isn't set, yet if (!*file->abspath) { - r = pakfire_path(file->pakfire, file->abspath, "%s", path); + r = pakfire_file_set_abspath(file, path); if (r) - return r; + goto ERROR; } return r; + +ERROR: + ERROR(file->pakfire, "Could not set path '%s': %m\n", path); + return r; } PAKFIRE_EXPORT const char* pakfire_file_get_hardlink(struct pakfire_file* file) {