[Xfce4-commits] <exo:jannis/validate-hal-udis> Squashme: Improve the code changes in exo_hal_udi_validate().

Jannis Pohlmann noreply at xfce.org
Mon Jan 11 13:08:01 CET 2010


Updating branch refs/heads/jannis/validate-hal-udis
         to 92a8ed3a8a7b81be18fbbad9f47b303797a9f7de (commit)
       from 4df75b6ff78d259635a2f084ef63741157dbd429 (commit)

commit 92a8ed3a8a7b81be18fbbad9f47b303797a9f7de
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Mon Jan 11 13:06:15 2010 +0100

    Squashme: Improve the code changes in exo_hal_udi_validate().

 exo-hal/exo-hal.c |   20 ++++++++------------
 1 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/exo-hal/exo-hal.c b/exo-hal/exo-hal.c
index aa77519..7cb356e 100644
--- a/exo-hal/exo-hal.c
+++ b/exo-hal/exo-hal.c
@@ -305,7 +305,6 @@ exo_hal_udi_validate (const gchar *udi,
                       gssize       len,
                       gchar      **end)
 {
-  const gchar *fixed_prefix = "/org/freedesktop/Hal/devices/";
   const gchar *last_slash;
   const gchar *e;
   const gchar *s;
@@ -329,6 +328,14 @@ exo_hal_udi_validate (const gchar *udi,
   if (G_UNLIKELY (*udi != '/'))
     return FALSE;
 
+  /* valid UDIs have to start with /org/freedesktop/Hal/devices/ */
+  if (!g_str_has_prefix (udi, "/org/freedesktop/Hal/devices/"))
+    {
+      if (G_UNLIKELY (end != NULL))
+        *end = (gchar *) udi + 29;
+      return FALSE;
+    }
+
   for (last_slash = udi, e = udi + len, s = udi + 1; s != e; ++s)
     {
       if (*s == '/')
@@ -359,17 +366,6 @@ exo_hal_udi_validate (const gchar *udi,
       return FALSE;
     }
 
-  /* check whether the UDI starts with /org/freedesktop/Hal/devices */
-  for (s = udi, e = fixed_prefix; s != NULL && *s != '\0' && e != NULL && *e != '\0'; ++s, ++e)
-    {
-      if (*s != *e)
-        {
-          if (G_UNLIKELY (end != NULL))
-            *end = (gchar *) s;
-          return FALSE;
-        }
-    }
-
   return TRUE;
 }
 



More information about the Xfce4-commits mailing list