# HG changeset patch
# Node ID 2273bd21ce2d
# Parent  984050b920b3
diff --git a/perl5/gplugin-perl5-loader.c b/perl5/gplugin-perl5-loader.c
--- a/perl5/gplugin-perl5-loader.c
+++ b/perl5/gplugin-perl5-loader.c
@@ -28,7 +28,7 @@
 G_DEFINE_DYNAMIC_TYPE(
 	GPluginPerlLoader,
 	gplugin_perl_loader,
-	GPLUGIN_TYPE_LOADER);
+	GPLUGIN_TYPE_LOADER)
 
 static PerlInterpreter *my_perl = NULL;
 
@@ -161,10 +161,15 @@
 	ret =
 		perl_parse(interpreter, gplugin_perl_loader_xs_init, argc, argv, NULL);
 	if(ret != 0) {
+		SV *err_tmp;
 		const gchar *errmsg = "unknown error";
 
-		if(SvTRUE(ERRSV)) {
-			errmsg = SvPVutf8_nolen(ERRSV);
+		/* ERRSV is a macro so we need to store its returned value so we don't
+		 * call it multiple times.
+		 */
+		err_tmp = ERRSV;
+		if(SvTRUE(err_tmp)) {
+			errmsg = SvPVutf8_nolen(err_tmp);
 		}
 
 		g_set_error_literal(error, GPLUGIN_DOMAIN, 0, errmsg);
@@ -177,10 +182,15 @@
 
 	ret = perl_run(interpreter);
 	if(ret != 0) {
+		SV *err_tmp;
 		const gchar *errmsg = "unknown error";
 
-		if(SvTRUE(ERRSV)) {
-			errmsg = SvPVutf8_nolen(ERRSV);
+		/* ERRSV is a macro so we need to store its returned value so we don't
+		 * call it multiple times.
+		 */
+		err_tmp = ERRSV;
+		if(SvTRUE(err_tmp)) {
+			errmsg = SvPVutf8_nolen(err_tmp);
 		}
 
 		g_set_error_literal(error, GPLUGIN_DOMAIN, 0, errmsg);
@@ -193,6 +203,9 @@
 
 	info = gplugin_perl_loader_call_gplugin_query(interpreter, error);
 	if(!GPLUGIN_IS_PLUGIN_INFO(info)) {
+		/* If the plugin's query method didn't set error, set it to a generic
+		 * message.
+		 */
 		if(error != NULL && *error == NULL) {
 			g_set_error_literal(error, GPLUGIN_DOMAIN, 0, "failed to query");
 		}
@@ -374,9 +387,9 @@
 gplugin_perl_loader_new(void)
 {
 	/* clang-format off */
-	return GPLUGIN_LOADER(g_object_new(
+	return g_object_new(
 		GPLUGIN_PERL_TYPE_LOADER,
 		"id", "gplugin-perl5",
-		NULL));
+		NULL);
 	/* clang-format on */
 }
diff --git a/perl5/gplugin-perl5-plugin.c b/perl5/gplugin-perl5-plugin.c
--- a/perl5/gplugin-perl5-plugin.c
+++ b/perl5/gplugin-perl5-plugin.c
@@ -59,7 +59,7 @@
 	gplugin_perl_plugin,
 	G_TYPE_OBJECT,
 	0,
-	G_IMPLEMENT_INTERFACE(GPLUGIN_TYPE_PLUGIN, gplugin_perl_plugin_iface_init));
+	G_IMPLEMENT_INTERFACE(GPLUGIN_TYPE_PLUGIN, gplugin_perl_plugin_iface_init))
 
 /******************************************************************************
  * GPluginPlugin Implementation
diff --git a/perl5/tests/plugins/basic.pl b/perl5/tests/plugins/basic.pl
--- a/perl5/tests/plugins/basic.pl
+++ b/perl5/tests/plugins/basic.pl
@@ -18,7 +18,8 @@
 use Glib::Object::Introspection;
 use Scalar::Util qw(blessed);
 
-Glib::Object::Introspection->setup(basename => "GPlugin", version => "1.0",
+Glib::Object::Introspection->setup(basename => "GPlugin",
+                                   version => "1.0",
                                    package => "GPlugin");
 
 sub gplugin_query {
diff --git a/perl5/tests/plugins/dependent.pl b/perl5/tests/plugins/dependent.pl
--- a/perl5/tests/plugins/dependent.pl
+++ b/perl5/tests/plugins/dependent.pl
@@ -17,7 +17,8 @@
 
 use Glib::Object::Introspection;
 
-Glib::Object::Introspection->setup(basename => "GPlugin", version => "1.0",
+Glib::Object::Introspection->setup(basename => "GPlugin",
+                                   version => "1.0",
                                    package => "GPlugin");
 
 sub gplugin_query {
diff --git a/perl5/tests/plugins/load-exception.pl b/perl5/tests/plugins/load-exception.pl
--- a/perl5/tests/plugins/load-exception.pl
+++ b/perl5/tests/plugins/load-exception.pl
@@ -17,7 +17,8 @@
 
 use Glib::Object::Introspection;
 
-Glib::Object::Introspection->setup(basename => "GPlugin", version => "1.0",
+Glib::Object::Introspection->setup(basename => "GPlugin",
+                                   version => "1.0",
                                    package => "GPlugin");
 
 sub gplugin_query {
diff --git a/perl5/tests/plugins/load-failed.pl b/perl5/tests/plugins/load-failed.pl
--- a/perl5/tests/plugins/load-failed.pl
+++ b/perl5/tests/plugins/load-failed.pl
@@ -17,7 +17,9 @@
 
 use Glib::Object::Introspection;
 
-Glib::Object::Introspection->setup(basename => "GPlugin", version => "1.0", package=> "GPlugin");
+Glib::Object::Introspection->setup(basename => "GPlugin",
+                                   version => "1.0",
+                                   package => "GPlugin");
 
 sub gplugin_query {
 	return GPlugin::PluginInfo->new(
diff --git a/perl5/tests/plugins/unload-failed.pl b/perl5/tests/plugins/unload-failed.pl
--- a/perl5/tests/plugins/unload-failed.pl
+++ b/perl5/tests/plugins/unload-failed.pl
@@ -17,7 +17,9 @@
 
 use Glib::Object::Introspection;
 
-Glib::Object::Introspection->setup(basename => "GPlugin", version => "1.0", package => "GPlugin");
+Glib::Object::Introspection->setup(basename => "GPlugin",
+                                   version => "1.0",
+                                   package => "GPlugin");
 
 sub gplugin_query() {
 	return GPlugin::PluginInfo->new(
diff --git a/perl5/tests/plugins/unload-shutdown.pl b/perl5/tests/plugins/unload-shutdown.pl
--- a/perl5/tests/plugins/unload-shutdown.pl
+++ b/perl5/tests/plugins/unload-shutdown.pl
@@ -17,7 +17,9 @@
 
 use Glib::Object::Introspection;
 
-Glib::Object::Introspection->setup(basename => "GPlugin", version => "1.0", package=> "GPlugin");
+Glib::Object::Introspection->setup(basename => "GPlugin",
+                                   version => "1.0",
+                                   package => "GPlugin");
 
 sub gplugin_query() {
 	return GPlugin::PluginInfo->new(
