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 <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
---
 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

_______________________________________________
Libosinfo mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libosinfo

Reply via email to