summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Borneo <borneo.antonio@gmail.com>2019-04-26 23:57:31 +0200
committerSimon Ser <contact@emersion.fr>2019-06-19 07:44:51 +0000
commit611fe36d24402a82ff0f7520eb31fed1efaab90f (patch)
tree47418812cc9778b4b9d557c4aac5d65b311d548a
parent45720b34e2037cb82600a0e21d8f17eae170060f (diff)
downloadweston-611fe36d24402a82ff0f7520eb31fed1efaab90f.tar.gz
log: remove "%m" from format strings by using strerror(errno)
The printf() format specifier "%m" is a glibc extension to print the string returned by strerror(errno). While supported by other libraries (e.g. uClibc and musl), it is not widely portable. In Weston code the format string is often passed to a logging function that calls other syscalls before the conversion of "%m" takes place. If one of such syscall modifies the value in errno, the conversion of "%m" will incorrectly report the error string corresponding to the new value of errno. Remove all the occurrences of the specifier "%m" in Weston code by using directly the string returned by strerror(errno). While there, fix some minor indentation issue. Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> (cherry picked from commit 3957863667c15bc5f1984ddc6c5967a323f41e7a)
-rw-r--r--clients/calibrator.c4
-rw-r--r--clients/clickdot.c4
-rw-r--r--clients/cliptest.c4
-rw-r--r--clients/confine.c4
-rw-r--r--clients/desktop-shell.c8
-rw-r--r--clients/dnd.c4
-rw-r--r--clients/editor.c8
-rw-r--r--clients/eventdemo.c8
-rw-r--r--clients/flower.c4
-rw-r--r--clients/fullscreen.c4
-rw-r--r--clients/gears.c4
-rw-r--r--clients/image.c4
-rw-r--r--clients/ivi-shell-user-interface.c10
-rw-r--r--clients/keyboard.c4
-rw-r--r--clients/multi-resource.c4
-rw-r--r--clients/nested.c18
-rw-r--r--clients/presentation-shm.c9
-rw-r--r--clients/resizor.c4
-rw-r--r--clients/scaler.c4
-rw-r--r--clients/screenshot.c9
-rw-r--r--clients/simple-damage.c7
-rw-r--r--clients/simple-im.c6
-rw-r--r--clients/simple-shm.c7
-rw-r--r--clients/simple-touch.c7
-rw-r--r--clients/smoke.c4
-rw-r--r--clients/stacking.c4
-rw-r--r--clients/subsurfaces.c4
-rw-r--r--clients/terminal.c8
-rw-r--r--clients/transformed.c4
-rw-r--r--clients/weston-debug.c10
-rw-r--r--clients/weston-info.c3
-rw-r--r--clients/window.c20
-rw-r--r--compositor/main.c24
-rw-r--r--compositor/screen-share.c27
-rw-r--r--compositor/xwayland.c7
-rw-r--r--libweston/compositor-drm.c44
-rw-r--r--libweston/compositor-wayland.c15
-rw-r--r--libweston/compositor.c5
-rw-r--r--libweston/input.c6
-rw-r--r--libweston/launcher-direct.c24
-rw-r--r--libweston/launcher-logind.c2
-rw-r--r--libweston/launcher-weston-launch.c6
-rw-r--r--libweston/screenshooter.c4
-rw-r--r--libweston/weston-launch.c16
-rw-r--r--tests/ivi-layout-test-plugin.c8
-rw-r--r--tests/weston-test-runner.c2
-rw-r--r--tests/weston-test.c4
-rw-r--r--xwayland/launcher.c6
-rw-r--r--xwayland/selection.c8
49 files changed, 265 insertions, 149 deletions
diff --git a/clients/calibrator.c b/clients/calibrator.c
index 778c23cf..aa213c28 100644
--- a/clients/calibrator.c
+++ b/clients/calibrator.c
@@ -32,6 +32,7 @@
#include <math.h>
#include <assert.h>
#include <getopt.h>
+#include <errno.h>
#include <linux/input.h>
#include <wayland-client.h>
@@ -290,7 +291,8 @@ main(int argc, char *argv[])
display = display_create(&argc, argv);
if (display == NULL) {
- fprintf(stderr, "failed to create display: %m\n");
+ fprintf(stderr, "failed to create display: %s\n",
+ strerror(errno));
return -1;
}
diff --git a/clients/clickdot.c b/clients/clickdot.c
index f9e6e640..4e8a945e 100644
--- a/clients/clickdot.c
+++ b/clients/clickdot.c
@@ -34,6 +34,7 @@
#include <assert.h>
#include <unistd.h>
#include <time.h>
+#include <errno.h>
#include <linux/input.h>
#include <wayland-client.h>
@@ -328,7 +329,8 @@ main(int argc, char *argv[])
display = display_create(&argc, argv);
if (display == NULL) {
- fprintf(stderr, "failed to create display: %m\n");
+ fprintf(stderr, "failed to create display: %s\n",
+ strerror(errno));
return -1;
}
diff --git a/clients/cliptest.c b/clients/cliptest.c
index 57aefdab..89983850 100644
--- a/clients/cliptest.c
+++ b/clients/cliptest.c
@@ -45,6 +45,7 @@
#include <cairo.h>
#include <float.h>
#include <assert.h>
+#include <errno.h>
#include <linux/input.h>
#include <wayland-client.h>
@@ -621,7 +622,8 @@ main(int argc, char *argv[])
d = display_create(&argc, argv);
if (d == NULL) {
- fprintf(stderr, "failed to create display: %m\n");
+ fprintf(stderr, "failed to create display: %s\n",
+ strerror(errno));
return -1;
}
diff --git a/clients/confine.c b/clients/confine.c
index 255236a3..01caae07 100644
--- a/clients/confine.c
+++ b/clients/confine.c
@@ -34,6 +34,7 @@
#include <math.h>
#include <assert.h>
#include <unistd.h>
+#include <errno.h>
#include <linux/input.h>
#include <wayland-client.h>
@@ -490,7 +491,8 @@ main(int argc, char *argv[])
display = display_create(&argc, argv);
if (display == NULL) {
- fprintf(stderr, "failed to create display: %m\n");
+ fprintf(stderr, "failed to create display: %s\n",
+ strerror(errno));
return -1;
}
diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index 0dc0f0ba..4e4cd207 100644
--- a/clients/desktop-shell.c
+++ b/clients/desktop-shell.c
@@ -212,7 +212,7 @@ panel_launcher_activate(struct panel_launcher *widget)
pid = fork();
if (pid < 0) {
- fprintf(stderr, "fork failed: %m\n");
+ fprintf(stderr, "fork failed: %s\n", strerror(errno));
return;
}
@@ -225,7 +225,8 @@ panel_launcher_activate(struct panel_launcher *widget)
exit(EXIT_FAILURE);
if (execve(argv[0], argv, widget->envp.data) < 0) {
- fprintf(stderr, "execl '%s' failed: %m\n", argv[0]);
+ fprintf(stderr, "execl '%s' failed: %s\n", argv[0],
+ strerror(errno));
exit(1);
}
}
@@ -1519,7 +1520,8 @@ int main(int argc, char *argv[])
desktop.display = display_create(&argc, argv);
if (desktop.display == NULL) {
- fprintf(stderr, "failed to create display: %m\n");
+ fprintf(stderr, "failed to create display: %s\n",
+ strerror(errno));
return -1;
}
diff --git a/clients/dnd.c b/clients/dnd.c
index ec706bff..8323f4fd 100644
--- a/clients/dnd.c
+++ b/clients/dnd.c
@@ -35,6 +35,7 @@
#include <cairo.h>
#include <sys/epoll.h>
#include <stdbool.h>
+#include <errno.h>
#include <wayland-client.h>
#include <wayland-cursor.h>
@@ -848,7 +849,8 @@ main(int argc, char *argv[])
d = display_create(&argc, argv);
if (d == NULL) {
- fprintf(stderr, "failed to create display: %m\n");
+ fprintf(stderr, "failed to create display: %s\n",
+ strerror(errno));
return -1;
}
diff --git a/clients/editor.c b/clients/editor.c
index 8f9eb632..7b309b27 100644
--- a/clients/editor.c
+++ b/clients/editor.c
@@ -580,7 +580,7 @@ data_source_send(void *data,
struct editor *editor = data;
if (write(fd, editor->selected_text, strlen(editor->selected_text) + 1) < 0)
- fprintf(stderr, "write failed: %m\n");
+ fprintf(stderr, "write failed: %s\n", strerror(errno));
close(fd);
}
@@ -1609,7 +1609,8 @@ main(int argc, char *argv[])
text_buffer = read_file(argv[1]);
if (text_buffer == NULL) {
- fprintf(stderr, "could not read file '%s': %m\n", argv[1]);
+ fprintf(stderr, "could not read file '%s': %s\n",
+ argv[1], strerror(errno));
return -1;
}
}
@@ -1618,7 +1619,8 @@ main(int argc, char *argv[])
editor.display = display_create(&argc, argv);
if (editor.display == NULL) {
- fprintf(stderr, "failed to create display: %m\n");
+ fprintf(stderr, "failed to create display: %s\n",
+ strerror(errno));
free(text_buffer);
return -1;
}
diff --git a/clients/eventdemo.c b/clients/eventdemo.c
index d8eef5b5..57b67be7 100644
--- a/clients/eventdemo.c
+++ b/clients/eventdemo.c
@@ -37,6 +37,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
+#include <string.h>
+#include <errno.h>
#include <cairo.h>
@@ -515,14 +517,16 @@ main(int argc, char *argv[])
/* Connect to the display and have the arguments parsed */
d = display_create(&argc, argv);
if (d == NULL) {
- fprintf(stderr, "failed to create display: %m\n");
+ fprintf(stderr, "failed to create display: %s\n",
+ strerror(errno));
return -1;
}
/* Create new eventdemo window */
e = eventdemo_create(d);
if (e == NULL) {
- fprintf(stderr, "failed to create eventdemo: %m\n");
+ fprintf(stderr, "failed to create eventdemo: %s\n",
+ strerror(errno));
return -1;
}
diff --git a/clients/flower.c b/clients/flower.c
index 34287fd8..e3471ce7 100644
--- a/clients/flower.c
+++ b/clients/flower.c
@@ -30,6 +30,7 @@
#include <time.h>
#include <math.h>
#include <cairo.h>
+#include <errno.h>
#include <sys/time.h>
#include <linux/input.h>
@@ -172,7 +173,8 @@ int main(int argc, char *argv[])
d = display_create(&argc, argv);
if (d == NULL) {
- fprintf(stderr, "failed to create display: %m\n");
+ fprintf(stderr, "failed to create display: %s\n",
+ strerror(errno));
return -1;
}
diff --git a/clients/fullscreen.c b/clients/fullscreen.c
index e2e6477f..d437e1d4 100644
--- a/clients/fullscreen.c
+++ b/clients/fullscreen.c
@@ -30,6 +30,7 @@
#include <stdarg.h>
#include <string.h>
#include <math.h>
+#include <errno.h>
#include <cairo.h>
#include <linux/input.h>
@@ -518,7 +519,8 @@ int main(int argc, char *argv[])
d = display_create(&argc, argv);
if (d == NULL) {
- fprintf(stderr, "failed to create display: %m\n");
+ fprintf(stderr, "failed to create display: %s\n",
+ strerror(errno));
return -1;
}
diff --git a/clients/gears.c b/clients/gears.c
index 3c57c4a7..6090a850 100644
--- a/clients/gears.c
+++ b/clients/gears.c
@@ -30,6 +30,7 @@
#include <string.h>
#include <math.h>
#include <time.h>
+#include <errno.h>
#include <GL/gl.h>
#include <EGL/egl.h>
@@ -488,7 +489,8 @@ int main(int argc, char *argv[])
d = display_create(&argc, argv);
if (d == NULL) {
- fprintf(stderr, "failed to create display: %m\n");
+ fprintf(stderr, "failed to create display: %s\n",
+ strerror(errno));
return -1;
}
gears = gears_create(d);
diff --git a/clients/image.c b/clients/image.c
index db9ccd64..0a8fb5b5 100644
--- a/clients/image.c
+++ b/clients/image.c
@@ -36,6 +36,7 @@
#include <time.h>
#include <cairo.h>
#include <assert.h>
+#include <errno.h>
#include <linux/input.h>
#include <wayland-client.h>
@@ -419,7 +420,8 @@ main(int argc, char *argv[])
d = display_create(&argc, argv);
if (d == NULL) {
- fprintf(stderr, "failed to create display: %m\n");
+ fprintf(stderr, "failed to create display: %s\n",
+ strerror(errno));
return -1;
}
diff --git a/clients/ivi-shell-user-interface.c b/clients/ivi-shell-user-interface.c
index a38d6af8..656a5ab4 100644
--- a/clients/ivi-shell-user-interface.c
+++ b/clients/ivi-shell-user-interface.c
@@ -35,6 +35,7 @@
#include <signal.h>
#include <sys/mman.h>
#include <getopt.h>
+#include <errno.h>
#include <wayland-cursor.h>
#include <wayland-client-protocol.h>
#include "shared/cairo-util.h"
@@ -806,8 +807,8 @@ createShmBuffer(struct wlContextStruct *p_wlCtx)
fd = os_create_anonymous_file(size);
if (fd < 0) {
- fprintf(stderr, "creating a buffer file for %d B failed: %m\n",
- size);
+ fprintf(stderr, "creating a buffer file for %d B failed: %s\n",
+ size, strerror(errno));
return ;
}
@@ -815,7 +816,7 @@ createShmBuffer(struct wlContextStruct *p_wlCtx)
mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (MAP_FAILED == p_wlCtx->data) {
- fprintf(stderr, "mmap failed: %m\n");
+ fprintf(stderr, "mmap failed: %s\n", strerror(errno));
close(fd);
return;
}
@@ -828,7 +829,8 @@ createShmBuffer(struct wlContextStruct *p_wlCtx)
WL_SHM_FORMAT_ARGB8888);
if (NULL == p_wlCtx->wlBuffer) {
- fprintf(stderr, "wl_shm_create_buffer failed: %m\n");
+ fprintf(stderr, "wl_shm_create_buffer failed: %s\n",
+ strerror(errno));
close(fd);
return;
}
diff --git a/clients/keyboard.c b/clients/keyboard.c
index c9f6f28e..e39d76dd 100644
--- a/clients/keyboard.c
+++ b/clients/keyboard.c
@@ -29,6 +29,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#include <linux/input.h>
#include <cairo.h>
@@ -1019,7 +1020,8 @@ main(int argc, char *argv[])
virtual_keyboard.display = display_create(&argc, argv);
if (virtual_keyboard.display == NULL) {
- fprintf(stderr, "failed to create display: %m\n");
+ fprintf(stderr, "failed to create display: %s\n",
+ strerror(errno));
return -1;
}
diff --git a/clients/multi-resource.c b/clients/multi-resource.c
index 13510957..075e7656 100644
--- a/clients/multi-resource.c
+++ b/clients/multi-resource.c
@@ -97,8 +97,8 @@ attach_buffer(struct window *window, int width, int height)
fd = os_create_anonymous_file(size);
if (fd < 0) {
- fprintf(stderr, "creating a buffer file for %d B failed: %m\n",
- size);
+ fprintf(stderr, "creating a buffer file for %d B failed: %s\n",
+ size, strerror(errno));
return -1;
}
diff --git a/clients/nested.c b/clients/nested.c
index e2bdf684..bc51b584 100644
--- a/clients/nested.c
+++ b/clients/nested.c
@@ -34,6 +34,7 @@
#include <sys/epoll.h>
#include <sys/socket.h>
#include <unistd.h>
+#include <errno.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
@@ -330,8 +331,8 @@ launch_client(struct nested *nested, const char *path)
if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sv) < 0) {
fprintf(stderr, "launch_client: "
- "socketpair failed while launching '%s': %m\n",
- path);
+ "socketpair failed while launching '%s': %s\n",
+ path, strerror(errno));
free(client);
return NULL;
}
@@ -342,7 +343,8 @@ launch_client(struct nested *nested, const char *path)
close(sv[1]);
free(client);
fprintf(stderr, "launch_client: "
- "fork failed while launching '%s': %m\n", path);
+ "fork failed while launching '%s': %s\n", path,
+ strerror(errno));
return NULL;
}
@@ -354,7 +356,8 @@ launch_client(struct nested *nested, const char *path)
* get a non-CLOEXEC fd to pass through exec. */
clientfd = dup(sv[1]);
if (clientfd == -1) {
- fprintf(stderr, "compositor: dup failed: %m\n");
+ fprintf(stderr, "compositor: dup failed: %s\n",
+ strerror(errno));
exit(-1);
}
@@ -363,8 +366,8 @@ launch_client(struct nested *nested, const char *path)
execl(path, path, NULL);
- fprintf(stderr, "compositor: executing '%s' failed: %m\n",
- path);
+ fprintf(stderr, "compositor: executing '%s' failed: %s\n",
+ path, strerror(errno));
exit(-1);
}
@@ -1116,7 +1119,8 @@ main(int argc, char *argv[])
display = display_create(&argc, argv);
if (display == NULL) {
- fprintf(stderr, "failed to create display: %m\n");
+ fprintf(stderr, "failed to create display: %s\n",
+ strerror(errno));
return -1;
}
diff --git a/clients/presentation-shm.c b/clients/presentation-shm.c
index d6a939e5..9ca3a813 100644
--- a/clients/presentation-shm.c
+++ b/clients/presentation-shm.c
@@ -35,6 +35,7 @@
#include <sys/mman.h>
#include <signal.h>
#include <time.h>
+#include <errno.h>
#include <wayland-client.h>
#include "shared/helpers.h"
@@ -141,14 +142,14 @@ create_shm_buffers(struct display *display, struct buffer **buffers,
fd = os_create_anonymous_file(size);
if (fd < 0) {
- fprintf(stderr, "creating a buffer file for %d B failed: %m\n",
- size);
+ fprintf(stderr, "creating a buffer file for %d B failed: %s\n",
+ size, strerror(errno));
return -1;
}
data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (data == MAP_FAILED) {
- fprintf(stderr, "mmap failed: %m\n");
+ fprintf(stderr, "mmap failed: %s\n", strerror(errno));
close(fd);
return -1;
}
@@ -480,7 +481,7 @@ window_emulate_rendering(struct window *window)
ret = nanosleep(&delay, NULL);
if (ret)
- printf("nanosleep failed: %m\n");
+ printf("nanosleep failed: %s\n", strerror(errno));
}
static void
diff --git a/clients/resizor.c b/clients/resizor.c
index 600452ad..cfc5d419 100644
--- a/clients/resizor.c
+++ b/clients/resizor.c
@@ -31,6 +31,7 @@
#include <cairo.h>
#include <math.h>
#include <assert.h>
+#include <errno.h>
#include <linux/input.h>
#include <wayland-client.h>
@@ -439,7 +440,8 @@ main(int argc, char *argv[])
display = display_create(&argc, argv);
if (display == NULL) {
- fprintf(stderr, "failed to create display: %m\n");
+ fprintf(stderr, "failed to create display: %s\n",
+ strerror(errno));
return -1;
}
diff --git a/clients/scaler.c b/clients/scaler.c
index 23cc3a49..91736fb3 100644
--- a/clients/scaler.c
+++ b/clients/scaler.c
@@ -28,6 +28,7 @@
#include <stdio.h>
#include <string.h>
#include <assert.h>
+#include <errno.h>
#include <cairo.h>
#include <linux/input.h>
@@ -288,7 +289,8 @@ main(int argc, char *argv[])
d = display_create(&argc, argv);
if (d == NULL) {
- fprintf(stderr, "failed to create display: %m\n");
+ fprintf(stderr, "failed to create display: %s\n",
+ strerror(errno));
return -1;
}
diff --git a/clients/screenshot.c b/clients/screenshot.c
index 96fb1682..bbf2e6bd 100644
--- a/clients/screenshot.c
+++ b/clients/screenshot.c
@@ -173,14 +173,14 @@ screenshot_create_shm_buffer(int width, int height, void **data_out,
fd = os_create_anonymous_file(size);
if (fd < 0) {
- fprintf(stderr, "creating a buffer file for %d B failed: %m\n",
- size);
+ fprintf(stderr, "creating a buffer file for %d B failed: %s\n",
+ size, strerror(errno));
return NULL;
}
data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (data == MAP_FAILED) {
- fprintf(stderr, "mmap failed: %m\n");
+ fprintf(stderr, "mmap failed: %s\n", strerror(errno));
close(fd);
return NULL;
}
@@ -286,7 +286,8 @@ int main(int argc, char *argv[])
display = wl_display_connect(NULL);
if (display == NULL) {
- fprintf(stderr, "failed to create display: %m\n");
+ fprintf(stderr, "failed to create display: %s\n",
+ strerror(errno));
return -1;
}
diff --git a/clients/simple-damage.c b/clients/simple-damage.c
index f33b9790..ad9be18f 100644
--- a/clients/simple-damage.c
+++ b/clients/simple-damage.c
@@ -35,6 +35,7 @@
#include <sys/mman.h>
#include <sys/time.h>
#include <signal.h>
+#include <errno.h>
#include <wayland-client.h>
#include "shared/os-compatibility.h"
@@ -123,14 +124,14 @@ create_shm_buffer(struct display *display, struct buffer *buffer,
fd = os_create_anonymous_file(size);
if (fd < 0) {
- fprintf(stderr, "creating a buffer file for %d B failed: %m\n",
- size);
+ fprintf(stderr, "creating a buffer file for %d B failed: %s\n",
+ size, strerror(errno));
return -1;
}
data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (data == MAP_FAILED) {
- fprintf(stderr, "mmap failed: %m\n");
+ fprintf(stderr, "mmap failed: %s\n", strerror(errno));
close(fd);
return -1;
}
diff --git a/clients/simple-im.c b/clients/simple-im.c
index 280589b1..a5b834de 100644
--- a/clients/simple-im.c
+++ b/clients/simple-im.c
@@ -28,6 +28,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <errno.h>
#include <sys/mman.h>
#include <linux/input.h>
@@ -490,7 +491,8 @@ main(int argc, char *argv[])
simple_im.display = wl_display_connect(NULL);
if (simple_im.display == NULL) {
- fprintf(stderr, "Failed to connect to server: %m\n");
+ fprintf(stderr, "Failed to connect to server: %s\n",
+ strerror(errno));
return -1;
}
@@ -516,7 +518,7 @@ main(int argc, char *argv[])
ret = wl_display_dispatch(simple_im.display);
if (ret == -1) {
- fprintf(stderr, "Dispatch error: %m\n");
+ fprintf(stderr, "Dispatch error: %s\n", strerror(errno));
return -1;
}
diff --git a/clients/simple-shm.c b/clients/simple-shm.c
index 979d7988..17fc235c 100644
--- a/clients/simple-shm.c
+++ b/clients/simple-shm.c
@@ -33,6 +33,7 @@
#include <unistd.h>
#include <sys/mman.h>
#include <signal.h>
+#include <errno.h>
#include <wayland-client.h>
#include "shared/os-compatibility.h"
@@ -98,14 +99,14 @@ create_shm_buffer(struct display *display, struct buffer *buffer,
fd = os_create_anonymous_file(size);
if (fd < 0) {
- fprintf(stderr, "creating a buffer file for %d B failed: %m\n",
- size);
+ fprintf(stderr, "creating a buffer file for %d B failed: %s\n",
+ size, strerror(errno));
return -1;
}
data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (data == MAP_FAILED) {
- fprintf(stderr, "mmap failed: %m\n");
+ fprintf(stderr, "mmap failed: %s\n", strerror(errno));
close(fd);
return -1;
}
diff --git a/clients/simple-touch.c b/clients/simple-touch.c
index 4d011471..385188c3 100644
--- a/clients/simple-touch.c
+++ b/clients/simple-touch.c
@@ -31,6 +31,7 @@
#include <stdbool.h>
#include <assert.h>
#include <unistd.h>
+#include <errno.h>
#include <sys/mman.h>
#include <wayland-client.h>
@@ -70,15 +71,15 @@ create_shm_buffer(struct touch *touch)
fd = os_create_anonymous_file(size);
if (fd < 0) {
- fprintf(stderr, "creating a buffer file for %d B failed: %m\n",
- size);
+ fprintf(stderr, "creating a buffer file for %d B failed: %s\n",
+ size, strerror(errno));
exit(1);
}
touch->data =
mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (touch->data == MAP_FAILED) {
- fprintf(stderr, "mmap failed: %m\n");
+ fprintf(stderr, "mmap failed: %s\n", strerror(errno));
close(fd);
exit(1);
}
diff --git a/clients/smoke.c b/clients/smoke.c
index cedd17f4..f1b90ec7 100644
--- a/clients/smoke.c
+++ b/clients/smoke.c
@@ -29,6 +29,7 @@
#include <string.h>
#include <time.h>
#include <math.h>
+#include <errno.h>
#include <cairo.h>
#include <wayland-client.h>
@@ -273,7 +274,8 @@ int main(int argc, char *argv[])
d = display_create(&argc, argv);
if (d == NULL) {
- fprintf(stderr, "failed to create display: %m\n");
+ fprintf(stderr, "failed to create display: %s\n",
+ strerror(errno));
return -1;
}
diff --git a/clients/stacking.c b/clients/stacking.c
index b034cf2a..5e9084f8 100644
--- a/clients/stacking.c
+++ b/clients/stacking.c
@@ -29,6 +29,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
+#include <errno.h>
#include <linux/input.h>
#include <cairo.h>
@@ -290,7 +291,8 @@ main(int argc, char *argv[])
stacking.display = display_create(&argc, argv);
if (stacking.display == NULL) {
- fprintf(stderr, "Failed to create display: %m\n");
+ fprintf(stderr, "Failed to create display: %s\n",
+ strerror(errno));
return -1;
}
diff --git a/clients/subsurfaces.c b/clients/subsurfaces.c
index d88b8617..0d457518 100644
--- a/clients/subsurfaces.c
+++ b/clients/subsurfaces.c
@@ -32,6 +32,7 @@
#include <cairo.h>
#include <math.h>
#include <assert.h>
+#include <errno.h>
#include <linux/input.h>
#include <wayland-client.h>
@@ -788,7 +789,8 @@ main(int argc, char *argv[])
display = display_create(&argc, argv);
if (display == NULL) {
- fprintf(stderr, "failed to create display: %m\n");
+ fprintf(stderr, "failed to create display: %s\n",
+ strerror(errno));
return -1;
}
diff --git a/clients/terminal.c b/clients/terminal.c
index adc682fa..25a533e2 100644
--- a/clients/terminal.c
+++ b/clients/terminal.c
@@ -3087,11 +3087,12 @@ terminal_run(struct terminal *terminal, const char *path)
setenv("TERM", option_term, 1);
setenv("COLORTERM", option_term, 1);
if (execl(path, path, NULL)) {
- printf("exec failed: %m\n");
+ printf("exec failed: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
} else if (pid < 0) {
- fprintf(stderr, "failed to fork and create pty (%m).\n");
+ fprintf(stderr, "failed to fork and create pty (%s).\n",
+ strerror(errno));
return -1;
}
@@ -3158,7 +3159,8 @@ int main(int argc, char *argv[])
d = display_create(&argc, argv);
if (d == NULL) {
- fprintf(stderr, "failed to create display: %m\n");
+ fprintf(stderr, "failed to create display: %s\n",
+ strerror(errno));
return -1;
}
diff --git a/clients/transformed.c b/clients/transformed.c
index 6687a4a8..dd88fcd4 100644
--- a/clients/transformed.c
+++ b/clients/transformed.c
@@ -29,6 +29,7 @@
#include <stdlib.h>
#include <string.h>
#include <math.h>
+#include <errno.h>
#include <cairo.h>
#include <linux/input.h>
@@ -263,7 +264,8 @@ int main(int argc, char *argv[])
d = display_create(&argc, argv);
if (d == NULL) {
- fprintf(stderr, "failed to create display: %m\n");
+ fprintf(stderr, "failed to create display: %s\n",
+ strerror(errno));
return -1;
}
diff --git a/clients/weston-debug.c b/clients/weston-debug.c
index 563c64ea..8a0bcc66 100644
--- a/clients/weston-debug.c
+++ b/clients/weston-debug.c
@@ -276,8 +276,8 @@ setup_out_fd(const char *output, const char *outfd)
O_WRONLY | O_APPEND | O_CREAT, 0644);
if (fd < 0) {
fprintf(stderr,
- "Error: opening file '%s' failed: %m\n",
- output);
+ "Error: opening file '%s' failed: %s\n",
+ output, strerror(errno));
}
return fd;
}
@@ -290,7 +290,8 @@ setup_out_fd(const char *output, const char *outfd)
flags = fcntl(fd, F_GETFL);
if (flags == -1) {
fprintf(stderr,
- "Error: cannot use file descriptor %d: %m\n", fd);
+ "Error: cannot use file descriptor %d: %s\n", fd,
+ strerror(errno));
return -1;
}
@@ -432,7 +433,8 @@ main(int argc, char **argv)
app.dpy = wl_display_connect(NULL);
if (!app.dpy) {
- fprintf(stderr, "Error: Could not connect to Wayland display: %m\n");
+ fprintf(stderr, "Error: Could not connect to Wayland display: %s\n",
+ strerror(errno));
ret = 1;
goto out_parse;
}
diff --git a/clients/weston-info.c b/clients/weston-info.c
index 7d562a17..8ee5e628 100644
--- a/clients/weston-info.c
+++ b/clients/weston-info.c
@@ -1856,7 +1856,8 @@ main(int argc, char **argv)
info.display = wl_display_connect(NULL);
if (!info.display) {
- fprintf(stderr, "failed to create display: %m\n");
+ fprintf(stderr, "failed to create display: %s\n",
+ strerror(errno));
return -1;
}
diff --git a/clients/window.c b/clients/window.c
index 00592cbf..ea0af1c0 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -740,14 +740,14 @@ make_shm_pool(struct display *display, int size, void **data)
fd = os_create_anonymous_file(size);
if (fd < 0) {
- fprintf(stderr, "creating a buffer file for %d B failed: %m\n",
- size);
+ fprintf(stderr, "creating a buffer file for %d B failed: %s\n",
+ size, strerror(errno));
return NULL;
}
*data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (*data == MAP_FAILED) {
- fprintf(stderr, "mmap failed: %m\n");
+ fprintf(stderr, "mmap failed: %s\n", strerror(errno));
close(fd);
return NULL;
}
@@ -6168,7 +6168,8 @@ display_create(int *argc, char *argv[])
d->display = wl_display_connect(NULL);
if (d->display == NULL) {
- fprintf(stderr, "failed to connect to Wayland display: %m\n");
+ fprintf(stderr, "failed to connect to Wayland display: %s\n",
+ strerror(errno));
free(d);
return NULL;
}
@@ -6195,7 +6196,8 @@ display_create(int *argc, char *argv[])
wl_registry_add_listener(d->registry, &registry_listener, d);
if (wl_display_roundtrip(d->display) < 0) {
- fprintf(stderr, "Failed to process Wayland connection: %m\n");
+ fprintf(stderr, "Failed to process Wayland connection: %s\n",
+ strerror(errno));
return NULL;
}
@@ -6531,7 +6533,8 @@ toytimer_fire(struct task *tsk, uint32_t events)
* readable and getting here, there'll be nothing to
* read and we get EAGAIN. */
if (errno != EAGAIN)
- fprintf(stderr, "timer read failed: %m\n");
+ fprintf(stderr, "timer read failed: %s\n",
+ strerror(errno));
return;
}
@@ -6546,7 +6549,8 @@ toytimer_init(struct toytimer *tt, clockid_t clock, struct display *display,
tt->fd = timerfd_create(clock, TFD_CLOEXEC | TFD_NONBLOCK);
if (tt->fd == -1) {
- fprintf(stderr, "creating timer failed: %m\n");
+ fprintf(stderr, "creating timer failed: %s\n",
+ strerror(errno));
abort();
}
@@ -6571,7 +6575,7 @@ toytimer_arm(struct toytimer *tt, const struct itimerspec *its)
ret = timerfd_settime(tt->fd, 0, its, NULL);
if (ret < 0) {
- fprintf(stderr, "timer setup failed: %m\n");
+ fprintf(stderr, "timer setup failed: %s\n", strerror(errno));
abort();
}
}
diff --git a/compositor/main.c b/compositor/main.c
index e86f696f..47b0c315 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -365,7 +365,7 @@ sigchld_handler(int signal_number, void *data)
}
if (pid < 0 && errno != ECHILD)
- weston_log("waitpid error %m\n");
+ weston_log("waitpid error %s\n", strerror(errno));
return 1;
}
@@ -391,7 +391,7 @@ child_client_exec(int sockfd, const char *path)
* non-CLOEXEC fd to pass through exec. */
clientfd = dup(sockfd);
if (clientfd == -1) {
- weston_log("compositor: dup failed: %m\n");
+ weston_log("compositor: dup failed: %s\n", strerror(errno));
return;
}
@@ -399,8 +399,8 @@ child_client_exec(int sockfd, const char *path)
setenv("WAYLAND_SOCKET", s, 1);
if (execl(path, path, NULL) < 0)
- weston_log("compositor: executing '%s' failed: %m\n",
- path);
+ weston_log("compositor: executing '%s' failed: %s\n",
+ path, strerror(errno));
}
WL_EXPORT struct wl_client *
@@ -417,8 +417,8 @@ weston_client_launch(struct weston_compositor *compositor,
if (os_socketpair_cloexec(AF_UNIX, SOCK_STREAM, 0, sv) < 0) {
weston_log("weston_client_launch: "
- "socketpair failed while launching '%s': %m\n",
- path);
+ "socketpair failed while launching '%s': %s\n",
+ path, strerror(errno));
return NULL;
}
@@ -427,7 +427,8 @@ weston_client_launch(struct weston_compositor *compositor,
close(sv[0]);
close(sv[1]);
weston_log("weston_client_launch: "
- "fork failed while launching '%s': %m\n", path);
+ "fork failed while launching '%s': %s\n", path,
+ strerror(errno));
return NULL;
}
@@ -812,13 +813,15 @@ weston_create_listening_socket(struct wl_display *display, const char *socket_na
{
if (socket_name) {
if (wl_display_add_socket(display, socket_name)) {
- weston_log("fatal: failed to add socket: %m\n");
+ weston_log("fatal: failed to add socket: %s\n",
+ strerror(errno));
return -1;
}
} else {
socket_name = wl_display_add_socket_auto(display);
if (!socket_name) {
- weston_log("fatal: failed to add socket: %m\n");
+ weston_log("fatal: failed to add socket: %s\n",
+ strerror(errno));
return -1;
}
}
@@ -3087,7 +3090,8 @@ int main(int argc, char *argv[])
if (fd != -1) {
primary_client = wl_client_create(display, fd);
if (!primary_client) {
- weston_log("fatal: failed to add client: %m\n");
+ weston_log("fatal: failed to add client: %s\n",
+ strerror(errno));
goto out;
}
primary_client_destroyed.notify =
diff --git a/compositor/screen-share.c b/compositor/screen-share.c
index 33de2b1f..f62fcdfb 100644
--- a/compositor/screen-share.c
+++ b/compositor/screen-share.c
@@ -207,7 +207,7 @@ ss_seat_handle_keymap(void *data, struct wl_keyboard *wl_keyboard,
if (format == WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) {
map_str = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
if (map_str == MAP_FAILED) {
- weston_log("mmap failed: %m\n");
+ weston_log("mmap failed: %s\n", strerror(errno));
goto error;
}
@@ -462,13 +462,13 @@ shared_output_get_shm_buffer(struct shared_output *so)
fd = os_create_anonymous_file(height * stride);
if (fd < 0) {
- weston_log("os_create_anonymous_file: %m\n");
+ weston_log("os_create_anonymous_file: %s\n", strerror(errno));
return NULL;
}
data = mmap(NULL, height * stride, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (data == MAP_FAILED) {
- weston_log("mmap: %m\n");
+ weston_log("mmap: %s\n", strerror(errno));
goto out_close;
}
@@ -940,7 +940,7 @@ shared_output_create(struct weston_output *output, int parent_fd)
so->parent.surface =
wl_compositor_create_surface(so->parent.compositor);
if (!so->parent.surface) {
- weston_log("Screen share failed: %m\n");
+ weston_log("Screen share failed: %s\n", strerror(errno));
goto err_display;
}
@@ -950,7 +950,7 @@ shared_output_create(struct weston_output *output, int parent_fd)
so->parent.output,
output->current_mode->refresh);
if (!so->parent.mode_feedback) {
- weston_log("Screen share failed: %m\n");
+ weston_log("Screen share failed: %s\n", strerror(errno));
goto err_display;
}
zwp_fullscreen_shell_mode_feedback_v1_add_listener(so->parent.mode_feedback,
@@ -964,7 +964,7 @@ shared_output_create(struct weston_output *output, int parent_fd)
wl_event_loop_add_fd(loop, epoll_fd, WL_EVENT_READABLE,
shared_output_handle_event, so);
if (!so->event_source) {
- weston_log("Screen share failed: %m\n");
+ weston_log("Screen share failed: %s\n", strerror(errno));
goto err_display;
}
@@ -1033,7 +1033,8 @@ weston_output_share(struct weston_output *output, const char* command)
};
if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sv) < 0) {
- weston_log("weston_output_share: socketpair failed: %m\n");
+ weston_log("weston_output_share: socketpair failed: %s\n",
+ strerror(errno));
return NULL;
}
@@ -1042,7 +1043,8 @@ weston_output_share(struct weston_output *output, const char* command)
if (pid == -1) {
close(sv[0]);
close(sv[1]);
- weston_log("weston_output_share: fork failed: %m\n");
+ weston_log("weston_output_share: fork failed: %s\n",
+ strerror(errno));
return NULL;
}
@@ -1054,13 +1056,15 @@ weston_output_share(struct weston_output *output, const char* command)
/* Launch clients as the user. Do not launch clients with
* wrong euid. */
if (seteuid(getuid()) == -1) {
- weston_log("weston_output_share: setuid failed: %m\n");
+ weston_log("weston_output_share: setuid failed: %s\n",
+ strerror(errno));
abort();
}
sv[1] = dup(sv[1]);
if (sv[1] == -1) {
- weston_log("weston_output_share: dup failed: %m\n");
+ weston_log("weston_output_share: dup failed: %s\n",
+ strerror(errno));
abort();
}
@@ -1068,7 +1072,8 @@ weston_output_share(struct weston_output *output, const char* command)
setenv("WAYLAND_SERVER_SOCKET", str, 1);
execv(argv[0], argv);
- weston_log("weston_output_share: exec failed: %m\n");
+ weston_log("weston_output_share: exec failed: %s\n",
+ strerror(errno));
abort();
} else {
close(sv[1]);
diff --git a/compositor/xwayland.c b/compositor/xwayland.c
index 61580c7c..dd834d17 100644
--- a/compositor/xwayland.c
+++ b/compositor/xwayland.c
@@ -27,6 +27,8 @@
#include "config.h"
#include <signal.h>
+#include <string.h>
+#include <errno.h>
#include <sys/socket.h>
#include "compositor.h"
@@ -128,9 +130,10 @@ spawn_xserver(void *user_data, const char *display, int abstract_fd, int unix_fd
NULL) < 0)
weston_log("exec of '%s %s -rootless "
"-listen %s -listen %s -wm %s "
- "-terminate' failed: %m\n",
+ "-terminate' failed: %s\n",
xserver, display,
- abstract_fd_str, unix_fd_str, wm_fd_str);
+ abstract_fd_str, unix_fd_str, wm_fd_str,
+ strerror(errno));
fail:
_exit(EXIT_FAILURE);
diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index c1101105..f1c5d73a 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -661,7 +661,8 @@ drm_output_pageflip_timer_create(struct drm_output *output)
output);
if (output->pageflip_timer == NULL) {
- weston_log("creating drm pageflip timer failed: %m\n");
+ weston_log("creating drm pageflip timer failed: %s\n",
+ strerror(errno));
return -1;
}
@@ -1079,7 +1080,7 @@ drm_fb_create_dumb(struct drm_backend *b, int width, int height,
fb->fd = b->drm.fd;
if (drm_fb_addfb(b, fb) != 0) {
- weston_log("failed to create kms fb: %m\n");
+ weston_log("failed to create kms fb: %s\n", strerror(errno));
goto err_bo;
}
@@ -1329,7 +1330,8 @@ drm_fb_get_from_bo(struct gbm_bo *bo, struct drm_backend *backend,
if (drm_fb_addfb(backend, fb) != 0) {
if (type == BUFFER_GBM_SURFACE)
- weston_log("failed to create kms fb: %m\n");
+ weston_log("failed to create kms fb: %s\n",
+ strerror(errno));
goto err_free;
}
@@ -2097,7 +2099,8 @@ drm_output_render_gl(struct drm_output_state *state, pixman_region32_t *damage)
bo = gbm_surface_lock_front_buffer(output->gbm_surface);
if (!bo) {
- weston_log("failed to lock front buffer: %m\n");
+ weston_log("failed to lock front buffer: %s\n",
+ strerror(errno));
return NULL;
}
@@ -2206,7 +2209,7 @@ drm_output_set_gamma(struct weston_output *output_base,
output->crtc_id,
size, r, g, b);
if (rc)
- weston_log("set gamma failed: %m\n");
+ weston_log("set gamma failed: %s\n", strerror(errno));
}
/* Determine the type of vblank synchronization to use for the output.
@@ -2280,20 +2283,23 @@ drm_output_apply_state_legacy(struct drm_output_state *state)
ret = drmModeSetPlane(backend->drm.fd, p->plane_id,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
if (ret)
- weston_log("drmModeSetPlane failed disable: %m\n");
+ weston_log("drmModeSetPlane failed disable: %s\n",
+ strerror(errno));
}
if (output->cursor_plane) {
ret = drmModeSetCursor(backend->drm.fd, output->crtc_id,
0, 0, 0);
if (ret)
- weston_log("drmModeSetCursor failed disable: %m\n");
+ weston_log("drmModeSetCursor failed disable: %s\n",
+ strerror(errno));
}
ret = drmModeSetCrtc(backend->drm.fd, output->crtc_id, 0, 0, 0,
NULL, 0, NULL);
if (ret)
- weston_log("drmModeSetCrtc failed disabling: %m\n");
+ weston_log("drmModeSetCrtc failed disabling: %s\n",
+ strerror(errno));
drm_output_assign_state(state, DRM_STATE_APPLY_SYNC);
weston_compositor_read_presentation_clock(output->base.compositor, &now);
@@ -2334,7 +2340,7 @@ drm_output_apply_state_legacy(struct drm_output_state *state)
connectors, n_conn,
&mode->mode_info);
if (ret) {
- weston_log("set mode failed: %m\n");
+ weston_log("set mode failed: %s\n", strerror(errno));
goto err;
}
}
@@ -2347,7 +2353,7 @@ drm_output_apply_state_legacy(struct drm_output_state *state)
if (drmModePageFlip(backend->drm.fd, output->crtc_id,
scanout_state->fb->fb_id,
DRM_MODE_PAGE_FLIP_EVENT, output) < 0) {
- weston_log("queueing pageflip failed: %m\n");
+ weston_log("queueing pageflip failed: %s\n", strerror(errno));
goto err;
}
@@ -2507,7 +2513,8 @@ drm_mode_ensure_blob(struct drm_backend *backend, struct drm_mode *mode)
sizeof(mode->mode_info),
&mode->blob_id);
if (ret != 0)
- weston_log("failed to create mode property blob: %m\n");
+ weston_log("failed to create mode property blob: %s\n",
+ strerror(errno));
drm_debug(backend, "\t\t\t[atomic] created new mode blob %lu for %s\n",
(unsigned long) mode->blob_id, mode->mode_info.name);
@@ -2769,7 +2776,8 @@ drm_pending_state_apply_atomic(struct drm_pending_state *pending_state,
}
if (ret != 0) {
- weston_log("atomic: couldn't commit new state: %m\n");
+ weston_log("atomic: couldn't commit new state: %s\n",
+ strerror(errno));
goto out;
}
@@ -3045,7 +3053,8 @@ drm_output_start_repaint_loop(struct weston_output *output_base)
ret = drm_pending_state_apply(pending_state);
if (ret != 0) {
- weston_log("applying repaint-start state failed: %m\n");
+ weston_log("applying repaint-start state failed: %s\n",
+ strerror(errno));
goto finish_frame;
}
@@ -3403,7 +3412,7 @@ cursor_bo_update(struct drm_plane_state *plane_state, struct weston_view *ev)
wl_shm_buffer_end_access(buffer->shm_buffer);
if (gbm_bo_write(bo, buf, sizeof buf) < 0)
- weston_log("failed update cursor: %m\n");
+ weston_log("failed update cursor: %s\n", strerror(errno));
}
static struct drm_plane_state *
@@ -3549,7 +3558,8 @@ drm_output_set_cursor(struct drm_output_state *output_state)
handle = gbm_bo_get_handle(bo).s32;
if (drmModeSetCursor(b->drm.fd, output->crtc_id, handle,
b->cursor_width, b->cursor_height)) {
- weston_log("failed to set cursor: %m\n");
+ weston_log("failed to set cursor: %s\n",
+ strerror(errno));
goto err;
}
}
@@ -3559,7 +3569,7 @@ drm_output_set_cursor(struct drm_output_state *output_state)
if (drmModeMoveCursor(b->drm.fd, output->crtc_id,
state->dest_x, state->dest_y)) {
- weston_log("failed to move cursor: %m\n");
+ weston_log("failed to move cursor: %s\n", strerror(errno));
goto err;
}
@@ -6998,7 +7008,7 @@ recorder_frame_notify(struct wl_listener *listener, void *data)
ret = vaapi_recorder_frame(output->recorder, fd,
output->scanout_plane->state_cur->fb->strides[0]);
if (ret < 0) {
- weston_log("[libva recorder] aborted: %m\n");
+ weston_log("[libva recorder] aborted: %s\n", strerror(errno));
recorder_destroy(output);
}
}
diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index e1485ca6..6e6529ef 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -34,6 +34,7 @@
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
+#include <errno.h>
#include <sys/mman.h>
#include <linux/input.h>
@@ -302,20 +303,23 @@ wayland_output_get_shm_buffer(struct wayland_output *output)
fd = os_create_anonymous_file(height * stride);
if (fd < 0) {
- weston_log("could not create an anonymous file buffer: %m\n");
+ weston_log("could not create an anonymous file buffer: %s\n",
+ strerror(errno));
return NULL;
}
data = mmap(NULL, height * stride, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (data == MAP_FAILED) {
- weston_log("could not mmap %d memory for data: %m\n", height * stride);
+ weston_log("could not mmap %d memory for data: %s\n", height * stride,
+ strerror(errno));
close(fd);
return NULL;
}
sb = zalloc(sizeof *sb);
if (sb == NULL) {
- weston_log("could not zalloc %zu memory for sb: %m\n", sizeof *sb);
+ weston_log("could not zalloc %zu memory for sb: %s\n", sizeof *sb,
+ strerror(errno));
close(fd);
munmap(data, height * stride);
return NULL;
@@ -1917,7 +1921,7 @@ input_handle_keymap(void *data, struct wl_keyboard *keyboard, uint32_t format,
if (format == WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) {
map_str = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
if (map_str == MAP_FAILED) {
- weston_log("mmap failed: %m\n");
+ weston_log("mmap failed: %s\n", strerror(errno));
goto error;
}
@@ -2729,7 +2733,8 @@ wayland_backend_create(struct weston_compositor *compositor,
b->parent.wl_display = wl_display_connect(new_config->display_name);
if (b->parent.wl_display == NULL) {
- weston_log("Error: Failed to connect to parent Wayland compositor: %m\n");
+ weston_log("Error: Failed to connect to parent Wayland compositor: %s\n",
+ strerror(errno));
weston_log_continue(STAMP_SPACE "display option: %s, WAYLAND_DISPLAY=%s\n",
new_config->display_name ?: "(none)",
getenv("WAYLAND_DISPLAY") ?: "(not set)");
diff --git a/libweston/compositor.c b/libweston/compositor.c
index 172ea3dc..e117479c 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -7020,8 +7020,9 @@ weston_compositor_read_presentation_clock(
if (!warned)
weston_log("Error: failure to read "
- "the presentation clock %#x: '%m' (%d)\n",
- compositor->presentation_clock, errno);
+ "the presentation clock %#x: '%s' (%d)\n",
+ compositor->presentation_clock,
+ strerror(errno), errno);
warned = true;
}
}
diff --git a/libweston/input.c b/libweston/input.c
index 6579592b..063a63e8 100644
--- a/libweston/input.c
+++ b/libweston/input.c
@@ -37,6 +37,7 @@
#include <values.h>
#include <fcntl.h>
#include <limits.h>
+#include <errno.h>
#include "shared/helpers.h"
#include "shared/os-compatibility.h"
@@ -2089,8 +2090,9 @@ weston_keyboard_send_keymap(struct weston_keyboard *kbd, struct wl_resource *res
fd = os_create_anonymous_file(xkb_info->keymap_size);
if (fd < 0) {
- weston_log("creating a keymap file for %lu bytes failed: %m\n",
- (unsigned long) xkb_info->keymap_size);
+ weston_log("creating a keymap file for %lu bytes failed: %s\n",
+ (unsigned long) xkb_info->keymap_size,
+ strerror(errno));
return;
}
diff --git a/libweston/launcher-direct.c b/libweston/launcher-direct.c
index e0ce6d63..89e57e76 100644
--- a/libweston/launcher-direct.c
+++ b/libweston/launcher-direct.c
@@ -32,6 +32,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <signal.h>
+#include <string.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <linux/vt.h>
@@ -129,14 +130,16 @@ setup_tty(struct launcher_direct *launcher, int tty)
if (tty == 0) {
launcher->tty = dup(tty);
if (launcher->tty == -1) {
- weston_log("couldn't dup stdin: %m\n");
+ weston_log("couldn't dup stdin: %s\n",
+ strerror(errno));
return -1;
}
} else {
snprintf(tty_device, sizeof tty_device, "/dev/tty%d", tty);
launcher->tty = open(tty_device, O_RDWR | O_CLOEXEC);
if (launcher->tty == -1) {
- weston_log("couldn't open tty %s: %m\n", tty_device);
+ weston_log("couldn't open tty %s: %s\n", tty_device,
+ strerror(errno));
return -1;
}
}
@@ -151,7 +154,7 @@ setup_tty(struct launcher_direct *launcher, int tty)
ret = ioctl(launcher->tty, KDGETMODE, &kd_mode);
if (ret) {
- weston_log("failed to get VT mode: %m\n");
+ weston_log("failed to get VT mode: %s\n", strerror(errno));
return -1;
}
if (kd_mode != KD_TEXT) {
@@ -164,19 +167,22 @@ setup_tty(struct launcher_direct *launcher, int tty)
ioctl(launcher->tty, VT_WAITACTIVE, minor(buf.st_rdev));
if (ioctl(launcher->tty, KDGKBMODE, &launcher->kb_mode)) {
- weston_log("failed to read keyboard mode: %m\n");
+ weston_log("failed to read keyboard mode: %s\n",
+ strerror(errno));
goto err_close;
}
if (ioctl(launcher->tty, KDSKBMUTE, 1) &&
ioctl(launcher->tty, KDSKBMODE, K_OFF)) {
- weston_log("failed to set K_OFF keyboard mode: %m\n");
+ weston_log("failed to set K_OFF keyboard mode: %s\n",
+ strerror(errno));
goto err_close;
}
ret = ioctl(launcher->tty, KDSETMODE, KD_GRAPHICS);
if (ret) {
- weston_log("failed to set KD_GRAPHICS mode on tty: %m\n");
+ weston_log("failed to set KD_GRAPHICS mode on tty: %s\n",
+ strerror(errno));
goto err_close;
}
@@ -255,10 +261,12 @@ launcher_direct_restore(struct weston_launcher *launcher_base)
if (ioctl(launcher->tty, KDSKBMUTE, 0) &&
ioctl(launcher->tty, KDSKBMODE, launcher->kb_mode))
- weston_log("failed to restore kb mode: %m\n");
+ weston_log("failed to restore kb mode: %s\n",
+ strerror(errno));
if (ioctl(launcher->tty, KDSETMODE, KD_TEXT))
- weston_log("failed to set KD_TEXT mode on tty: %m\n");
+ weston_log("failed to set KD_TEXT mode on tty: %s\n",
+ strerror(errno));
/* We have to drop master before we switch the VT back in
* VT_AUTO, so we don't risk switching to a VT with another
diff --git a/libweston/launcher-logind.c b/libweston/launcher-logind.c
index 34e6e5ca..f69b55fa 100644
--- a/libweston/launcher-logind.c
+++ b/libweston/launcher-logind.c
@@ -225,7 +225,7 @@ launcher_logind_close(struct weston_launcher *launcher, int fd)
r = fstat(fd, &st);
close(fd);
if (r < 0) {
- weston_log("logind: cannot fstat fd: %m\n");
+ weston_log("logind: cannot fstat fd: %s\n", strerror(errno));
return;
}
diff --git a/libweston/launcher-weston-launch.c b/libweston/launcher-weston-launch.c
index 65beb325..a7bdfafc 100644
--- a/libweston/launcher-weston-launch.c
+++ b/libweston/launcher-weston-launch.c
@@ -169,10 +169,12 @@ launcher_weston_launch_restore(struct weston_launcher *launcher_base)
if (ioctl(launcher->tty, KDSKBMUTE, 0) &&
ioctl(launcher->tty, KDSKBMODE, launcher->kb_mode))
- weston_log("failed to restore kb mode: %m\n");
+ weston_log("failed to restore kb mode: %s\n",
+ strerror(errno));
if (ioctl(launcher->tty, KDSETMODE, KD_TEXT))
- weston_log("failed to set KD_TEXT mode on tty: %m\n");
+ weston_log("failed to set KD_TEXT mode on tty: %s\n",
+ strerror(errno));
/* We have to drop master before we switch the VT back in
* VT_AUTO, so we don't risk switching to a VT with another
diff --git a/libweston/screenshooter.c b/libweston/screenshooter.c
index 2bde4f1d..a0e65b0d 100644
--- a/libweston/screenshooter.c
+++ b/libweston/screenshooter.c
@@ -32,6 +32,7 @@
#include <linux/input.h>
#include <fcntl.h>
#include <unistd.h>
+#include <errno.h>
#include <sys/uio.h>
#include "compositor.h"
@@ -431,7 +432,8 @@ weston_recorder_create(struct weston_output *output, const char *filename)
O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);
if (recorder->fd < 0) {
- weston_log("problem opening output file %s: %m\n", filename);
+ weston_log("problem opening output file %s: %s\n", filename,
+ strerror(errno));
goto err_recorder;
}
diff --git a/libweston/weston-launch.c b/libweston/weston-launch.c
index bf73e0d6..dff83cca 100644
--- a/libweston/weston-launch.c
+++ b/libweston/weston-launch.c
@@ -129,7 +129,8 @@ read_groups(int *ngroups)
n = getgroups(0, NULL);
if (n < 0) {
- fprintf(stderr, "Unable to retrieve groups: %m\n");
+ fprintf(stderr, "Unable to retrieve groups: %s\n",
+ strerror(errno));
return NULL;
}
@@ -138,7 +139,8 @@ read_groups(int *ngroups)
return NULL;
if (getgroups(n, groups) < 0) {
- fprintf(stderr, "Unable to retrieve groups: %m\n");
+ fprintf(stderr, "Unable to retrieve groups: %s\n",
+ strerror(errno));
free(groups);
return NULL;
}
@@ -320,8 +322,8 @@ handle_open(struct weston_launch *wl, struct msghdr *msg, ssize_t len)
fd = open(message->path, message->flags);
if (fd < 0) {
- fprintf(stderr, "Error opening device %s: %m\n",
- message->path);
+ fprintf(stderr, "Error opening device %s: %s\n",
+ message->path, strerror(errno));
goto err0;
}
@@ -434,10 +436,12 @@ quit(struct weston_launch *wl, int status)
if (ioctl(wl->tty, KDSKBMUTE, 0) &&
ioctl(wl->tty, KDSKBMODE, wl->kb_mode))
- fprintf(stderr, "failed to restore keyboard mode: %m\n");
+ fprintf(stderr, "failed to restore keyboard mode: %s\n",
+ strerror(errno));
if (ioctl(wl->tty, KDSETMODE, KD_TEXT))
- fprintf(stderr, "failed to set KD_TEXT mode on tty: %m\n");
+ fprintf(stderr, "failed to set KD_TEXT mode on tty: %s\n",
+ strerror(errno));
/* We have to drop master before we switch the VT back in
* VT_AUTO, so we don't risk switching to a VT with another
diff --git a/tests/ivi-layout-test-plugin.c b/tests/ivi-layout-test-plugin.c
index aa88a712..605d3b32 100644
--- a/tests/ivi-layout-test-plugin.c
+++ b/tests/ivi-layout-test-plugin.c
@@ -33,6 +33,7 @@
#include <string.h>
#include <assert.h>
#include <limits.h>
+#include <errno.h>
#include "compositor.h"
#include "compositor/weston.h"
@@ -198,7 +199,8 @@ idle_launch_client(void *data)
pid = fork();
if (pid == -1) {
- weston_log("fatal: failed to fork '%s': %m\n", launcher->exe);
+ weston_log("fatal: failed to fork '%s': %s\n", launcher->exe,
+ strerror(errno));
weston_compositor_exit_with_code(launcher->compositor,
EXIT_FAILURE);
return;
@@ -208,8 +210,8 @@ idle_launch_client(void *data)
sigfillset(&allsigs);
sigprocmask(SIG_UNBLOCK, &allsigs, NULL);
execl(launcher->exe, launcher->exe, NULL);
- weston_log("compositor: executing '%s' failed: %m\n",
- launcher->exe);
+ weston_log("compositor: executing '%s' failed: %s\n",
+ launcher->exe, strerror(errno));
_exit(EXIT_FAILURE);
}
diff --git a/tests/weston-test-runner.c b/tests/weston-test-runner.c
index f0566ac0..9dbe43e3 100644
--- a/tests/weston-test-runner.c
+++ b/tests/weston-test-runner.c
@@ -104,7 +104,7 @@ exec_and_report_test(const struct weston_test *t, void *test_data, int iteration
run_test(t, test_data, iteration); /* never returns */
if (waitid(P_ALL, 0, &info, WEXITED)) {
- fprintf(stderr, "waitid failed: %m\n");
+ fprintf(stderr, "waitid failed: %s\n", strerror(errno));
abort();
}
diff --git a/tests/weston-test.c b/tests/weston-test.c
index 12ef54ee..1207a916 100644
--- a/tests/weston-test.c
+++ b/tests/weston-test.c
@@ -31,6 +31,7 @@
#include <signal.h>
#include <unistd.h>
#include <string.h>
+#include <errno.h>
#include "compositor.h"
#include "compositor/weston.h"
@@ -649,7 +650,8 @@ idle_launch_client(void *data)
sigfillset(&allsigs);
sigprocmask(SIG_UNBLOCK, &allsigs, NULL);
execl(path, path, NULL);
- weston_log("compositor: executing '%s' failed: %m\n", path);
+ weston_log("compositor: executing '%s' failed: %s\n", path,
+ strerror(errno));
exit(EXIT_FAILURE);
}
diff --git a/xwayland/launcher.c b/xwayland/launcher.c
index c5b99385..8bcebc7f 100644
--- a/xwayland/launcher.c
+++ b/xwayland/launcher.c
@@ -101,7 +101,8 @@ bind_to_abstract_socket(int display)
"%c/tmp/.X11-unix/X%d", 0, display);
size = offsetof(struct sockaddr_un, sun_path) + name_size;
if (bind(fd, (struct sockaddr *) &addr, size) < 0) {
- weston_log("failed to bind to @%s: %m\n", addr.sun_path + 1);
+ weston_log("failed to bind to @%s: %s\n", addr.sun_path + 1,
+ strerror(errno));
close(fd);
return -1;
}
@@ -131,7 +132,8 @@ bind_to_unix_socket(int display)
size = offsetof(struct sockaddr_un, sun_path) + name_size;
unlink(addr.sun_path);
if (bind(fd, (struct sockaddr *) &addr, size) < 0) {
- weston_log("failed to bind to %s: %m\n", addr.sun_path);
+ weston_log("failed to bind to %s: %s\n", addr.sun_path,
+ strerror(errno));
close(fd);
return -1;
}
diff --git a/xwayland/selection.c b/xwayland/selection.c
index 411fceda..e4d797ae 100644
--- a/xwayland/selection.c
+++ b/xwayland/selection.c
@@ -30,6 +30,7 @@
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
+#include <errno.h>
#include "xwayland.h"
#include "shared/helpers.h"
@@ -59,7 +60,7 @@ writable_callback(int fd, uint32_t mask, void *data)
wl_event_source_remove(wm->property_source);
wm->property_source = NULL;
close(fd);
- weston_log("write error to target fd: %m\n");
+ weston_log("write error to target fd: %s\n", strerror(errno));
return 1;
}
@@ -401,7 +402,8 @@ weston_wm_read_data_source(int fd, uint32_t mask, void *data)
len = read(fd, p, available);
if (len == -1) {
- weston_log("read error from data source: %m\n");
+ weston_log("read error from data source: %s\n",
+ strerror(errno));
weston_wm_send_selection_notify(wm, XCB_ATOM_NONE);
if (wm->property_source)
wl_event_source_remove(wm->property_source);
@@ -494,7 +496,7 @@ weston_wm_send_data(struct weston_wm *wm, xcb_atom_t target, const char *mime_ty
int p[2];
if (pipe2(p, O_CLOEXEC | O_NONBLOCK) == -1) {
- weston_log("pipe2 failed: %m\n");
+ weston_log("pipe2 failed: %s\n", strerror(errno));
weston_wm_send_selection_notify(wm, XCB_ATOM_NONE);
return;
}