]> git.proxmox.com Git - mirror_lxcfs.git/blobdiff - bindings.c
Merge pull request #255 from brauner/2018-08-26/fix_makedev
[mirror_lxcfs.git] / bindings.c
index e0832a4439c19c2836d716fe7ba55fe5c4b8e908..70386fc75f2804b91d9dd77d4d006421b35ab1c6 100644 (file)
@@ -97,7 +97,7 @@ struct cpuacct_usage {
 #define EXP_15         2037            /* 1/exp(5sec/15min) */
 #define LOAD_INT(x) ((x) >> FSHIFT)
 #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
-/* 
+/*
  * This parameter is used for proc_loadavg_read().
  * 1 means use loadavg, 0 means not use.
  */
@@ -584,19 +584,24 @@ static bool write_string(const char *fnam, const char *string, int fd)
        FILE *f;
        size_t len, ret;
 
-       if (!(f = fdopen(fd, "w")))
+       f = fdopen(fd, "w");
+       if (!f)
                return false;
+
        len = strlen(string);
        ret = fwrite(string, 1, len, f);
        if (ret != len) {
-               lxcfs_error("Error writing to file: %s\n", strerror(errno));
+               lxcfs_error("%s - Error writing \"%s\" to \"%s\"\n",
+                           strerror(errno), string, fnam);
                fclose(f);
                return false;
        }
+
        if (fclose(f) < 0) {
-               lxcfs_error("Error writing to file: %s\n", strerror(errno));
+               lxcfs_error("%s - Failed to close \"%s\"\n", strerror(errno), fnam);
                return false;
        }
+
        return true;
 }
 
@@ -2049,6 +2054,7 @@ static void do_release_file_info(struct fuse_file_info *fi)
        free(f->buf);
        f->buf = NULL;
        free(f);
+       f = NULL;
 }
 
 int cg_releasedir(const char *path, struct fuse_file_info *fi)
@@ -4643,7 +4649,7 @@ static int refresh_load(struct load_node *p, char *path)
        p->last_pid = last_pid;
 
        free(line);
-err_out:       
+err_out:
        for (; i > 0; i--)
                free(idbuf[i-1]);
 out: