processes plugin: Fixed the config callback to return the right values.
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Tue, 27 May 2008 15:21:42 +0000 (17:21 +0200)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Tue, 27 May 2008 15:21:42 +0000 (17:21 +0200)
src/processes.c

index 6747134..79451d3 100644 (file)
@@ -426,33 +426,35 @@ static void ps_list_reset (void)
 /* put all pre-defined 'Process' names from config to list_head_g tree */
 static int ps_config (const char *key, const char *value)
 {
-       char *new_val;  
-       char *fields[2];
-       int fields_num;
-
        if (strcasecmp (key, "Process") == 0)
        {
                ps_list_register (value, NULL);
-               return (0);
        }
-
-       if (strcasecmp (key, "ProcessMatch") == 0)
+       else if (strcasecmp (key, "ProcessMatch") == 0)
        {
+               char *new_val;  
+               char *fields[3];
+               int fields_num;
+
                new_val = strdup (value);
                if (new_val == NULL)
-                       return (-1);
-               fields_num = strsplit (new_val, fields, 2);
+                       return (1);
+               fields_num = strsplit (new_val, fields,
+                               STATIC_ARRAY_SIZE (fields));
                if (fields_num != 2)
                {
                        sfree (new_val);
-                       return (-1);
+                       return (1);
                }
                ps_list_register (fields[0], fields[1]);
                sfree (new_val);
-               return (0);
+       }
+       else
+       {
+               return (-1);
        }
 
-       return (-1);
+       return (0);
 }
 
 static int ps_init (void)