aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/log.c4
-rw-r--r--util/os-compatibility.c45
2 files changed, 26 insertions, 23 deletions
diff --git a/util/log.c b/util/log.c
index 754ccfa9..3ef5f484 100644
--- a/util/log.c
+++ b/util/log.c
@@ -85,3 +85,7 @@ const char *_wlr_strip_path(const char *filepath) {
}
return filepath;
}
+
+enum wlr_log_importance wlr_log_get_verbosity(void) {
+ return log_importance;
+}
diff --git a/util/os-compatibility.c b/util/os-compatibility.c
index 38333605..bd39705d 100644
--- a/util/os-compatibility.c
+++ b/util/os-compatibility.c
@@ -23,7 +23,7 @@
* SOFTWARE.
*/
-#define _XOPEN_SOURCE 700
+#define _POSIX_C_SOURCE 200809L
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
@@ -32,20 +32,22 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
+#include <wlr/config.h>
#include "util/os-compatibility.h"
int os_fd_set_cloexec(int fd) {
- long flags;
-
- if (fd == -1)
+ if (fd == -1) {
return -1;
+ }
- flags = fcntl(fd, F_GETFD);
- if (flags == -1)
+ long flags = fcntl(fd, F_GETFD);
+ if (flags == -1) {
return -1;
+ }
- if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1)
+ if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) {
return -1;
+ }
return 0;
}
@@ -58,15 +60,14 @@ int set_cloexec_or_close(int fd) {
return fd;
}
-int create_tmpfile_cloexec(char *tmpname)
-{
+int create_tmpfile_cloexec(char *tmpname) {
int fd;
-
mode_t prev_umask = umask(0066);
#ifdef HAVE_MKOSTEMP
fd = mkostemp(tmpname, O_CLOEXEC);
- if (fd >= 0)
+ if (fd >= 0) {
unlink(tmpname);
+ }
#else
fd = mkstemp(tmpname);
if (fd >= 0) {
@@ -102,32 +103,29 @@ int create_tmpfile_cloexec(char *tmpname)
*/
int os_create_anonymous_file(off_t size) {
static const char template[] = "/wlroots-shared-XXXXXX";
- const char *path;
- char *name;
- int fd;
- int ret;
- path = getenv("XDG_RUNTIME_DIR");
+ const char *path = getenv("XDG_RUNTIME_DIR");
if (!path) {
errno = ENOENT;
return -1;
}
- name = malloc(strlen(path) + sizeof(template));
- if (!name)
+ char *name = malloc(strlen(path) + sizeof(template));
+ if (!name) {
return -1;
+ }
strcpy(name, path);
strcat(name, template);
- fd = create_tmpfile_cloexec(name);
-
+ int fd = create_tmpfile_cloexec(name);
free(name);
-
- if (fd < 0)
+ if (fd < 0) {
return -1;
+ }
-#ifdef HAVE_POSIX_FALLOCATE
+#ifdef WLR_HAS_POSIX_FALLOCATE
+ int ret;
do {
ret = posix_fallocate(fd, 0, size);
} while (ret == EINTR);
@@ -137,6 +135,7 @@ int os_create_anonymous_file(off_t size) {
return -1;
}
#else
+ int ret;
do {
ret = ftruncate(fd, size);
} while (ret < 0 && errno == EINTR);