[Libosinfo] [libosinfo PATCH 3/4] media: Add set_non_bootable_media_error()

Fabiano Fidêncio fidencio at redhat.com
Fri Dec 14 09:21:03 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>
---
 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 fb7f279..de8125c 100644
--- a/osinfo/osinfo_media.c
+++ b/osinfo/osinfo_media.c
@@ -696,6 +696,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)
 {
@@ -784,10 +792,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 EXIT;
     }
-- 
2.19.1




More information about the Libosinfo mailing list