Code

check_host: Allocate a large-enough buffer for the host table.
[nagiosplug.git] / lib / utils_disk.c
index c92b85069ea43e9c6b5c089c19cac94d0a772d5f..5be2b2c07bd498e991b8f6519d7348bb31d8f7a9 100644 (file)
@@ -3,9 +3,7 @@
 * Library for check_disk
 * 
 * License: GPL
-* Copyright (c) 1999-2007 nagios-plugins team
-* 
-* Last Modified: $Date$
+* Copyright (c) 1999-2007 Nagios Plugins Development Team
 * 
 * Description:
 * 
@@ -25,7 +23,6 @@
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
-* $Id$
 * 
 *****************************************************************************/
 
@@ -61,6 +58,19 @@ np_add_parameter(struct parameter_list **list, const char *name)
   new_path->usedinodes_percent = NULL;
   new_path->freeinodes_percent = NULL;
   new_path->group = NULL;
+  new_path->dfree_pct = -1;
+  new_path->dused_pct = -1; 
+  new_path->total = 0;
+  new_path->available = 0;
+  new_path->available_to_root = 0;
+  new_path->used = 0;
+  new_path->dused_units = 0;
+  new_path->dfree_units = 0;
+  new_path->dtotal_units = 0;
+  new_path->inodes_total = 0;
+  new_path->inodes_free = 0;
+  new_path->dused_inodes_percent = 0;
+  new_path->dfree_inodes_percent = 0;
 
   if (current == NULL) {
     *list = new_path;
@@ -77,22 +87,21 @@ np_add_parameter(struct parameter_list **list, const char *name)
 struct parameter_list *
 np_del_parameter(struct parameter_list *item, struct parameter_list *prev)
 {
-       struct parameter_list *next;
-       if (item->name_next)
-               next = item->name_next;
-       else
-               next = NULL;
+  struct parameter_list *next;
 
-       
-       free(item);
-       if (prev)
-         prev->name_next = next;
+  if (item->name_next)
+    next = item->name_next;
+  else
+    next = NULL;
 
-       return next;
+  free(item);
+  if (prev)
+    prev->name_next = next;
 
+  return next;
 }
 
-  
+
 /* returns a pointer to the struct found in the list */
 struct parameter_list *
 np_find_parameter(struct parameter_list *list, const char *name)
@@ -102,7 +111,7 @@ np_find_parameter(struct parameter_list *list, const char *name)
     if (! strcmp(temp_list->name, name))
         return temp_list;
   }
-        
+
   return NULL;
 }
 
@@ -127,7 +136,7 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list
       if (! best_match) {
         for (me = mount_list; me; me = me->me_next) {
           size_t len = strlen (me->me_mountdir);
-          if ((exact == FALSE && (best_match_len <= len && len <= name_len && 
+          if ((exact == FALSE && (best_match_len <= len && len <= name_len &&
              (len == 1 || strncmp (me->me_mountdir, d->name, len) == 0)))
              || (exact == TRUE && strcmp(me->me_mountdir, d->name)==0))
           {
@@ -176,7 +185,7 @@ np_seen_name(struct name_list *list, const char *name)
 }
 
 int
-np_regex_match_mount_entry (struct mount_entry* me, regex_t* re) 
+np_regex_match_mount_entry (struct mount_entry* me, regex_t* re)
 {
   if (regexec(re, me->me_devname, (size_t) 0, NULL, 0) == 0 ||
       regexec(re, me->me_mountdir, (size_t) 0, NULL, 0) == 0 ) {