solaris-fixes branch: Applied the swap-patch by Christophe Kalt.
[collectd.git] / src / common.c
index a4b718c..78be3af 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * collectd - src/common.c
- * Copyright (C) 2005  Florian octo Forster
+ * Copyright (C) 2005,2006  Florian octo Forster
  *
  * This program is free software; you can redistribute it and/
  * or modify it under the terms of the GNU General Public Li-
@@ -363,7 +363,8 @@ static int check_create_dir (const char *file_orig)
 /* * * * *
  * Magic *
  * * * * */
-int rra_get (char ***ret)
+#if HAVE_LIBRRD
+static int rra_get (char ***ret)
 {
        static char **rra_def = NULL;
        static int rra_num = 0;
@@ -440,12 +441,16 @@ int rra_get (char ***ret)
        *ret = rra_def;
        return (rra_num);
 }
+#endif /* HAVE_LIBRRD */
 
 static int log_create_file (char *filename, char **ds_def, int ds_num)
 {
        FILE *log;
        int i;
 
+       if (check_create_dir (filename))
+               return (-1);
+
        log = fopen (filename, "w");
        if (log == NULL)
        {
@@ -483,7 +488,7 @@ static int log_create_file (char *filename, char **ds_def, int ds_num)
 
                /* The `%.*s' is needed because there is no null-byte behind
                 * the name. */
-               fprintf(log, ",%.*s", (tmp - name), name);
+               fprintf(log, ",%.*s", (int) (tmp - name), name);
        }
        fprintf(log, "\n");
        fclose(log);
@@ -517,7 +522,7 @@ static int log_update_file (char *host, char *file, char *values,
        strncpy (full_file, file, 1024);
 
        tmp = full_file + strlen (full_file) - 4;
-       assert (tmp > 0);
+       assert ((tmp != NULL) && (tmp > full_file));
 
        /* Change the filename for logfiles. */
        if (strncmp (tmp, ".rrd", 4) == 0)