From 3957863667c15bc5f1984ddc6c5967a323f41e7a Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Fri, 26 Apr 2019 23:57:31 +0200 Subject: [PATCH] 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 --- clients/calibrator.c | 4 ++- clients/clickdot.c | 4 ++- clients/cliptest.c | 4 ++- clients/confine.c | 4 ++- clients/desktop-shell.c | 8 ++++-- clients/dnd.c | 4 ++- clients/editor.c | 8 ++++-- clients/eventdemo.c | 8 ++++-- clients/flower.c | 4 ++- clients/fullscreen.c | 4 ++- clients/gears.c | 4 ++- clients/image.c | 4 ++- clients/ivi-shell-user-interface.c | 10 ++++--- clients/keyboard.c | 4 ++- clients/multi-resource.c | 4 +-- clients/nested.c | 18 +++++++----- clients/presentation-shm.c | 9 +++--- clients/resizor.c | 4 ++- clients/scaler.c | 4 ++- clients/screenshot.c | 9 +++--- clients/simple-damage.c | 7 +++-- clients/simple-im.c | 6 ++-- clients/simple-shm.c | 7 +++-- clients/simple-touch.c | 7 +++-- clients/smoke.c | 4 ++- clients/stacking.c | 4 ++- clients/subsurfaces.c | 4 ++- clients/terminal.c | 8 ++++-- clients/transformed.c | 4 ++- clients/weston-debug.c | 10 ++++--- clients/weston-info.c | 3 +- clients/window.c | 20 ++++++++------ compositor/main.c | 24 +++++++++------- compositor/screen-share.c | 27 ++++++++++-------- compositor/xwayland.c | 7 +++-- libweston/compositor-drm.c | 44 ++++++++++++++++++------------ libweston/compositor-wayland.c | 15 ++++++---- libweston/compositor.c | 5 ++-- libweston/input.c | 6 ++-- libweston/launcher-direct.c | 24 ++++++++++------ libweston/launcher-logind.c | 2 +- libweston/launcher-weston-launch.c | 6 ++-- libweston/screenshooter.c | 4 ++- libweston/weston-launch.c | 16 +++++++---- tests/ivi-layout-test-plugin.c | 8 ++++-- tests/weston-test-runner.c | 2 +- tests/weston-test.c | 4 ++- xwayland/launcher.c | 6 ++-- xwayland/selection.c | 8 ++++-- 49 files changed, 265 insertions(+), 149 deletions(-) diff --git a/clients/calibrator.c b/clients/calibrator.c index 2439fc94..21ca876f 100644 --- a/clients/calibrator.c +++ b/clients/calibrator.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -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 #include #include +#include #include #include @@ -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 #include #include +#include #include #include @@ -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 #include #include +#include #include #include @@ -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 c60e74d2..8114491d 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 #include #include +#include #include #include @@ -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 03e6b491..c3d9491d 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 #include #include +#include +#include #include @@ -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 #include #include +#include #include #include @@ -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 22fcec11..ff41d418 100644 --- a/clients/fullscreen.c +++ b/clients/fullscreen.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -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 #include #include +#include #include #include @@ -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 #include #include +#include #include #include @@ -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 445892a6..7d2d1a20 100644 --- a/clients/ivi-shell-user-interface.c +++ b/clients/ivi-shell-user-interface.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #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 #include #include +#include #include #include @@ -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 f3c42d0d..b86503db 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 #include #include +#include #include #include @@ -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 9f4790ae..7150eb08 100644 --- a/clients/presentation-shm.c +++ b/clients/presentation-shm.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #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 #include #include +#include #include #include @@ -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 #include #include +#include #include #include @@ -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 72ab6dd6..0458bd06 100644 --- a/clients/simple-damage.c +++ b/clients/simple-damage.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #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 #include #include +#include #include #include @@ -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 ff6613f8..90892c87 100644 --- a/clients/simple-shm.c +++ b/clients/simple-shm.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #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 #include #include +#include #include #include @@ -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 #include #include +#include #include #include @@ -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 #include #include +#include #include #include @@ -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 23c22e8f..0e4e52b0 100644 --- a/clients/subsurfaces.c +++ b/clients/subsurfaces.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -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 f7e9ba95..38e40207 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 #include #include +#include #include #include @@ -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 d7ff081e..3060dec9 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 08c26191..a26f0bf0 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 d4dc96e1..80479976 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, ®istry_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 4855cdbb..280211e3 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; } } @@ -3083,7 +3086,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 69689d73..360cd3cd 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 50b8dcc1..8eadbe25 100644 --- a/compositor/xwayland.c +++ b/compositor/xwayland.c @@ -27,6 +27,8 @@ #include "config.h" #include +#include +#include #include #include @@ -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 5c1ccdd7..bbeb1cfb 100644 --- a/libweston/compositor-drm.c +++ b/libweston/compositor-drm.c @@ -665,7 +665,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; } @@ -1083,7 +1084,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; } @@ -1333,7 +1334,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; } @@ -2104,7 +2106,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; } @@ -2228,7 +2231,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. @@ -2302,20 +2305,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); @@ -2356,7 +2362,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; } } @@ -2369,7 +2375,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; } @@ -2529,7 +2535,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); @@ -2828,7 +2835,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; } @@ -3104,7 +3112,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; } @@ -3462,7 +3471,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 * @@ -3608,7 +3617,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; } } @@ -3618,7 +3628,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; } @@ -7057,7 +7067,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 337ea105..729cbb71 100644 --- a/libweston/compositor-wayland.c +++ b/libweston/compositor-wayland.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -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 6a7c4ced..4dc52ec3 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 93ac0f6c..9ecee4b1 100644 --- a/libweston/input.c +++ b/libweston/input.c @@ -37,6 +37,7 @@ #include #include #include +#include #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 e5f1bcfb..d59de1bd 100644 --- a/libweston/launcher-direct.c +++ b/libweston/launcher-direct.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -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 bcbde16c..9893cca1 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 c811a500..e5d828ce 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 5199d2cb..2c722a66 100644 --- a/libweston/screenshooter.c +++ b/libweston/screenshooter.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -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 0ae7d0df..4962bd6f 100644 --- a/libweston/weston-launch.c +++ b/libweston/weston-launch.c @@ -128,7 +128,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; } @@ -137,7 +138,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; } @@ -325,8 +327,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; } @@ -439,10 +441,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 4799919c..d7aa17d0 100644 --- a/tests/ivi-layout-test-plugin.c +++ b/tests/ivi-layout-test-plugin.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #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 34c1089d..eea73fb3 100644 --- a/tests/weston-test.c +++ b/tests/weston-test.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #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 2c7da113..d71be145 100644 --- a/xwayland/launcher.c +++ b/xwayland/launcher.c @@ -100,7 +100,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; } @@ -130,7 +131,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 #include #include +#include #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; }