shm: reindent shm_tmpfile to follow our standards.

Signed-off-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
Eric Anholt 2018-09-19 13:20:12 -07:00 committed by Peter Hutterer
parent b8b64cd627
commit 804a9b4f57

View File

@ -1195,34 +1195,34 @@ static int
shm_tmpfile(void) shm_tmpfile(void)
{ {
#ifdef SHMDIR #ifdef SHMDIR
int fd; int fd;
char template[] = SHMDIR "/shmfd-XXXXXX"; char template[] = SHMDIR "/shmfd-XXXXXX";
#ifdef O_TMPFILE #ifdef O_TMPFILE
fd = open(SHMDIR, O_TMPFILE|O_RDWR|O_CLOEXEC|O_EXCL, 0666); fd = open(SHMDIR, O_TMPFILE|O_RDWR|O_CLOEXEC|O_EXCL, 0666);
if (fd >= 0) { if (fd >= 0) {
DebugF ("Using O_TMPFILE\n"); DebugF ("Using O_TMPFILE\n");
return fd; return fd;
} }
ErrorF ("Not using O_TMPFILE\n"); ErrorF ("Not using O_TMPFILE\n");
#endif #endif
#ifdef HAVE_MKOSTEMP #ifdef HAVE_MKOSTEMP
fd = mkostemp(template, O_CLOEXEC); fd = mkostemp(template, O_CLOEXEC);
#else #else
fd = mkstemp(template); fd = mkstemp(template);
#endif #endif
if (fd < 0) if (fd < 0)
return -1;
unlink(template);
#ifndef HAVE_MKOSTEMP
int flags = fcntl(fd, F_GETFD);
if (flags != -1) {
flags |= FD_CLOEXEC;
(void) fcntl(fd, F_SETFD, &flags);
}
#endif
return fd;
#else
return -1; return -1;
unlink(template);
#ifndef HAVE_MKOSTEMP
int flags = fcntl(fd, F_GETFD);
if (flags != -1) {
flags |= FD_CLOEXEC;
(void) fcntl(fd, F_SETFD, &flags);
}
#endif
return fd;
#else
return -1;
#endif #endif
} }