[glib: 4/5] gio: fix set_selinux_context coding style




commit 3f18b77fb346a5e49a1815978c39da7a4009cb29
Author: Marc-André Lureau <marcandre lureau redhat com>
Date:   Tue Dec 1 13:20:11 2020 +0400

    gio: fix set_selinux_context coding style
    
    Mostly for cosmetic and readability, follow more closely the glib-style.
    
    Signed-off-by: Marc-André Lureau <marcandre lureau redhat com>

 gio/glocalfileinfo.c | 47 ++++++++++++++++++++++++-----------------------
 1 file changed, 24 insertions(+), 23 deletions(-)
---
diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c
index 987ed280e..4228d3457 100644
--- a/gio/glocalfileinfo.c
+++ b/gio/glocalfileinfo.c
@@ -2699,8 +2699,8 @@ set_mtime_atime (char                       *filename,
 #ifdef HAVE_SELINUX
 static gboolean
 set_selinux_context (char                       *filename,
-                const GFileAttributeValue  *value,
-                GError                    **error)
+                     const GFileAttributeValue  *value,
+                     GError                    **error)
 {
   const char *val;
 
@@ -2708,29 +2708,30 @@ set_selinux_context (char                       *filename,
     return FALSE;
 
   if (val == NULL)
-  {
-    g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
-                         _("SELinux context must be non-NULL"));
-    return FALSE;
-  }
+    {
+      g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
+                           _("SELinux context must be non-NULL"));
+      return FALSE;
+    }
 
-  if (is_selinux_enabled ()) {
-       if (setfilecon_raw (filename, val) < 0)
-       {
-            int errsv = errno;
+  if (!is_selinux_enabled ())
+    {
+      g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
+                           _("SELinux is not enabled on this system"));
+      return FALSE;
+    }
+
+  if (setfilecon_raw (filename, val) < 0)
+    {
+      int errsv = errno;
             
-            g_set_error (error, G_IO_ERROR,
-                         g_io_error_from_errno (errsv),
-                       _("Error setting SELinux context: %s"),
-                         g_strerror (errsv));
-            return FALSE;
-        }
-  } else {
-    g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
-                         _("SELinux is not enabled on this system"));
-    return FALSE;
-  }
-                                                     
+      g_set_error (error, G_IO_ERROR,
+                   g_io_error_from_errno (errsv),
+                   _("Error setting SELinux context: %s"),
+                   g_strerror (errsv));
+      return FALSE;
+    }
+
   return TRUE;
 }
 #endif 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]