Do not try to fdopen() if open() failed

This commit is contained in:
Andreas Öman 2008-04-29 06:57:42 +00:00
parent e3cd6c5836
commit 49db6a02ee

5
main.c
View file

@ -387,12 +387,13 @@ FILE *
settings_open_for_write(const char *name)
{
FILE *fp;
int fd;
if((fd = open(name, O_CREAT | O_TRUNC | O_RDWR, 0600)) < 0)
if((fd = open(name, O_CREAT | O_TRUNC | O_RDWR, 0600)) < 0) {
syslog(LOG_ALERT, "Unable to open settings file \"%s\" -- %s",
name, strerror(errno));
return NULL;
}
if((fp = fdopen(fd, "w+")) == NULL)
syslog(LOG_ALERT, "Unable to open settings file \"%s\" -- %s",