]> git.meshlink.io Git - catta/blobdiff - avahi-daemon/static-hosts.c
hide "Bad probe size estimate" warning in probe code which was generated when assembl...
[catta] / avahi-daemon / static-hosts.c
index aba96f720e82e548a4680e54511fce29dc88f7bf..8e16d8428d1061d1feae89295bc9951cf7f03547 100644 (file)
@@ -171,54 +171,59 @@ void static_hosts_load(int in_chroot) {
 
         line++;
 
-               /* Find the start of the line, ignore whitespace */
-               s = ln + strspn(ln, " \t");
-               /* Set the end of the string to NULL */
-               s[strcspn(s, "#\r\n")] = 0;
-
-               /* Ignore comment (#) and blank lines (*/
-               if (*s == '#' || *s == 0)
-                       continue;
-
-               /* Read the first string (ip) up to the next whitespace */
-               len = strcspn(s, " \t");
-               ip = avahi_strndup(s, len);
-
-               /* Skip past it */
-               s += len;
-
-               /* Find the next token */
-               s += strspn(s, " \t");
-               len = strcspn(s, " \t");
-               host = avahi_strndup(s, len);
-
-               if (*host == 0)
-               {
-                       avahi_log_error ("%s:%d: Error, unexpected end of line!", filename, line);
-            break;
-               }
+        /* Find the start of the line, ignore whitespace */
+        s = ln + strspn(ln, " \t");
+        /* Set the end of the string to NULL */
+        s[strcspn(s, "#\r\n")] = 0;
+
+        /* Ignore blank lines */
+        if (*s == 0)
+            continue;
+
+        /* Read the first string (ip) up to the next whitespace */
+        len = strcspn(s, " \t");
+        ip = avahi_strndup(s, len);
+
+        /* Skip past it */
+        s += len;
+
+        /* Find the next token */
+        s += strspn(s, " \t");
+        len = strcspn(s, " \t");
+        host = avahi_strndup(s, len);
+
+        if (*host == 0)
+        {
+            avahi_log_error("%s:%d: Error, unexpected end of line!", filename, line);
+            avahi_free(host);
+            avahi_free(ip);
+           break;
+        }
+
+        /* Skip over the host */
+        s += len;
 
         /* Skip past any more spaces */
-               s += strspn(s+len, " \t");
+        s += strspn(s, " \t");
         
         /* Anything left? */
-               if (*(s+len) != 0) {
-                       avahi_log_error ("%s:%d: Junk on the end of the line!", filename, line);
+        if (*s != 0) {
+            avahi_log_error ("%s:%d: Junk on the end of the line!", filename, line);
+            avahi_free(host);
+            avahi_free(ip);
             break;
-               }
+        }
 
         h = static_host_new();
         h->host = host;
         h->ip = ip;
     }
+
+    fclose(f);
 }
 
 void static_hosts_free_all (void)
 {
-    StaticHost *h;
-
-    for (h = hosts; h; h = hosts->hosts_next)
-    {
-        static_host_free (h);
-    }
+    while(hosts)
+        static_host_free(hosts);
 }