[Libosinfo] [libosinfo PATCH v2 5/6] media: Add set_non_bootable_media_error()

Fabiano Fidêncio fidencio at redhat.com
Thu Dec 20 07:46:46 UTC 2018


This is a helper to set the "non bootable" error for a media. It'll
become really handy in the next few patches in the series in order to
avoid code duplication.

Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange at redhat.com>
---
 osinfo/osinfo_media.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/osinfo/osinfo_media.c b/osinfo/osinfo_media.c
index 0531c47..ffa0aa2 100644
--- a/osinfo/osinfo_media.c
+++ b/osinfo/osinfo_media.c
@@ -723,6 +723,14 @@ static gboolean is_str_empty(const gchar *str) {
     return ret;
 }
 
+static void set_non_bootable_media_error(GError **error)
+{
+    g_set_error(error,
+                OSINFO_MEDIA_ERROR,
+                OSINFO_MEDIA_ERROR_NOT_BOOTABLE,
+                _("Install media is not bootable"));
+}
+
 static OsinfoMedia *
 create_from_location_async_data(CreateFromLocationAsyncData *data)
 {
@@ -811,10 +819,7 @@ static void on_svd_read(GObject *source,
     g_strchomp(data->svd.system);
 
     if (strncmp(BOOTABLE_TAG, data->svd.system, sizeof(BOOTABLE_TAG)) != 0) {
-        g_set_error(&error,
-                    OSINFO_MEDIA_ERROR,
-                    OSINFO_MEDIA_ERROR_NOT_BOOTABLE,
-                    _("Install media is not bootable"));
+        set_non_bootable_media_error(&error);
 
         goto cleanup;
     }
-- 
2.19.1




More information about the Libosinfo mailing list