[glib: 2/13] gdbusaddress: Simplify address validation in is_valid_unix()



commit 7f9e76d2bcdd73711d868156f92115990fe8dad6
Author: Philip Withnall <withnall endlessm com>
Date:   Fri Mar 15 14:18:55 2019 +0000

    gdbusaddress: Simplify address validation in is_valid_unix()
    
    No need for the `meaningless` label and some unreachable if-branches.
    This introduces no functional changes.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>

 gio/gdbusaddress.c | 35 +++++++++++------------------------
 1 file changed, 11 insertions(+), 24 deletions(-)
---
diff --git a/gio/gdbusaddress.c b/gio/gdbusaddress.c
index 024e93b43..d84490ff8 100644
--- a/gio/gdbusaddress.c
+++ b/gio/gdbusaddress.c
@@ -158,22 +158,18 @@ is_valid_unix (const gchar  *address_entry,
         }
     }
 
-  if (path != NULL)
+  if ((path != NULL && tmpdir != NULL) ||
+      (tmpdir != NULL && abstract != NULL) ||
+      (abstract != NULL && path != NULL))
     {
-      if (tmpdir != NULL || abstract != NULL)
-        goto meaningless;
-    }
-  else if (tmpdir != NULL)
-    {
-      if (path != NULL || abstract != NULL)
-        goto meaningless;
-    }
-  else if (abstract != NULL)
-    {
-      if (path != NULL || tmpdir != NULL)
-        goto meaningless;
+      g_set_error (error,
+             G_IO_ERROR,
+             G_IO_ERROR_INVALID_ARGUMENT,
+             _("Meaningless key/value pair combination in address entry ā€œ%sā€"),
+             address_entry);
+      goto out;
     }
-  else
+  else if (path == NULL && tmpdir == NULL && abstract == NULL)
     {
       g_set_error (error,
                    G_IO_ERROR,
@@ -183,16 +179,7 @@ is_valid_unix (const gchar  *address_entry,
       goto out;
     }
 
-
-  ret= TRUE;
-  goto out;
-
- meaningless:
-  g_set_error (error,
-               G_IO_ERROR,
-               G_IO_ERROR_INVALID_ARGUMENT,
-               _("Meaningless key/value pair combination in address entry ā€œ%sā€"),
-               address_entry);
+  ret = TRUE;
 
  out:
   g_list_free (keys);


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