On Tue, 20 Aug 2013 14:15:26 -0500 Serge Hallyn <serge.hal...@ubuntu.com> wrote:
[...] > +static bool mod_rdep(struct lxc_container *c, bool inc) > +{ > + char path[MAXPATHLEN]; > + int ret, v = 0; > + FILE *f; > + bool bret = false; > + > + if (container_disk_lock(c)) > + return false; > + ret = snprintf(path, MAXPATHLEN, "%s/%s/lxc_snapshots", > c->config_path, > + c->name); > + if (ret < 0 || ret > MAXPATHLEN) > + goto out; > + f = fopen(path, "r"); > + if (f) { > + ret = fscanf(f, "%d", &v); > + fclose(f); > + if (ret != 1) { > + ERROR("Corrupted file %s", path); > + goto out; > + } > + } > + v += inc ? 1 : -1; > + f = fopen(path, "w"); > + if (!f) > + goto out; > + fprintf(f, "%d\n", v); > + fclose(f); Should we check the return value of fclose()? ie. it could fail ENOSPC? [...] > +static bool add_rdepends(struct lxc_container *c, struct > lxc_container *c0) +{ > + int ret; > + char path[MAXPATHLEN]; > + FILE *f; > + > + ret = snprintf(path, MAXPATHLEN, "%s/%s/lxc_rdepends", > c->config_path, > + c->name); > + if (ret < 0 || ret >= MAXPATHLEN) > + return false; > + f = fopen(path, "a"); > + if (!f) > + return false; > + fprintf(f, "%s\n%s\n", c0->config_path, c0->name); > + fclose(f); and here, otherwise Acked-by: Dwight Engen <dwight.en...@oracle.com> ------------------------------------------------------------------------------ Introducing Performance Central, a new site from SourceForge and AppDynamics. Performance Central is your source for news, insights, analysis and resources for efficient Application Performance Management. Visit us today! http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk _______________________________________________ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel