summaryrefslogtreecommitdiff
path: root/sfeed_frames.c
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2016-03-04 12:14:29 +0100
committerHiltjo Posthuma <hiltjo@codemadness.org>2016-03-04 12:14:29 +0100
commitfc51ac87a52f859af5084e1abf3ab7d346f0cc20 (patch)
tree299be967fae12d386ff3a97a3e61dc1d54ac278c /sfeed_frames.c
parent9e979da3399e46e243a5dc9023a0c77e0f6377a2 (diff)
sfeed_frames: use mkdir and check errno EEXIST
no need to stat and then mkdir, this is a (theoretical) race-condition too.
Diffstat (limited to 'sfeed_frames.c')
-rw-r--r--sfeed_frames.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/sfeed_frames.c b/sfeed_frames.c
index 6edf3c9..06d2c0d 100644
--- a/sfeed_frames.c
+++ b/sfeed_frames.c
@@ -106,7 +106,6 @@ printfeed(FILE *fpitems, FILE *fpin, struct feed *f)
char dirpath[PATH_MAX], filepath[PATH_MAX];
char *fields[FieldLast], *feedname, name[128];
ssize_t linelen;
- struct stat st;
FILE *fpcontent = NULL;
unsigned int isnew;
time_t parsedtime;
@@ -123,8 +122,8 @@ printfeed(FILE *fpitems, FILE *fpin, struct feed *f)
strlcpy(dirpath, name, sizeof(dirpath));
- /* directory doesn't exist: try to create it. */
- if (stat(dirpath, &st) == -1 && mkdir(dirpath, S_IRWXU) == -1)
+ /* error creating directory and it doesn't exist. */
+ if (mkdir(dirpath, S_IRWXU | S_IRWXG | S_IRWXO) == -1 && errno != EEXIST)
err(1, "mkdir: %s", dirpath);
/* menu if not unnamed */