This function added recently in commit 7df09064a4 ("server: Explain what to do if plugin/filter loading fails") was rather hard to follow.
Document and simplify the parameters. This is just refactoring, it should have no effect on what the code prints. Updates: commit 7df09064a4e993a74d2d4421b70b272e7121c929 --- server/main.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/server/main.c b/server/main.c index c354f3bf36..7c9dc27626 100644 --- a/server/main.c +++ b/server/main.c @@ -982,19 +982,32 @@ make_uri (void) return r; } +/* Common error handling for dlopen failures in open_plugin_so or + * open_filter_so. + * + * The error message is held implicitly in dlerror(). + * + * 'what' is the string "plugin" or "filter". + * + * 'filename' is the file we were trying to dlopen. + * + * 'short_name' is the original short name that was passed to nbdkit, + * or NULL if no short name was used. + */ static void failed_to_load_error (const char *what, - const char *orig_name, const char *name, int short_name) + const char *filename, + const char *short_name) { fprintf (stderr, "%s: error: cannot open %s '%s': %s\n", - program_name, what, name, dlerror ()); + program_name, what, filename, dlerror ()); if (short_name) fprintf (stderr, "\n" "To add this functionality you might need to install a separate\n" "%s package such as nbdkit-%s-%s (Fedora) or\n" "nbdkit-%s-%s (Debian).\n", - what, orig_name, what, what, orig_name); + what, short_name, what, what, short_name); fprintf (stderr, "\n" "Use '%s --help' or " @@ -1026,7 +1039,7 @@ open_plugin_so (size_t i, const char *name, int short_name) dl = dlopen (filename, RTLD_NOW|RTLD_GLOBAL); if (dl == NULL) - failed_to_load_error ("plugin", orig_name, name, short_name); + failed_to_load_error ("plugin", filename, short_name ? orig_name : NULL); /* Initialize the plugin. See dlopen(3) to understand C weirdness. */ dlerror (); @@ -1073,7 +1086,7 @@ open_filter_so (struct backend *next, size_t i, dl = dlopen (filename, RTLD_NOW|RTLD_GLOBAL); if (dl == NULL) - failed_to_load_error ("filter", orig_name, name, short_name); + failed_to_load_error ("filter", filename, short_name ? orig_name : NULL); /* Initialize the filter. See dlopen(3) to understand C weirdness. */ dlerror (); -- 2.44.0 _______________________________________________ Libguestfs mailing list -- guestfs@lists.libguestfs.org To unsubscribe send an email to guestfs-le...@lists.libguestfs.org