On Wed, May 27, 2015 at 09:33:32PM +0800, Paul Tan wrote:
+/**
+ * xfopen() is the same as fopen(), but it die()s if the fopen() fails.
+ */
+FILE *xfopen(const char *path, const char *mode)
+{
+ FILE *fp;
+
+ assert(path);
+ assert(mode);
+ fp = fopen(path, mode);
+ if (!fp) {
+ if (*mode == 'w' || *mode == 'a')
+ die_errno(_("could not open '%s' for writing"), path);
This misses "r+". I don't think we use that in our code currently, but
if we're going to introduce a wrapper like this, I think it makes sense
to cover all cases.
-Peff