Avoid printing to stderr

Use wl_log in the last few places where we print to stderr.  Remove
logging in a couple of places where we properly return an error code.

https://bugs.freedesktop.org/show_bug.cgi?id=73339
This commit is contained in:
Kristian Høgsberg 2014-04-30 12:18:52 -07:00
parent 3e962728bf
commit 88f3bd84c8
2 changed files with 9 additions and 15 deletions

View file

@ -97,7 +97,6 @@ add_source(struct wl_event_loop *loop,
struct epoll_event ep;
if (source->fd < 0) {
fprintf(stderr, "could not add source\n: %m");
free(source);
return NULL;
}
@ -175,7 +174,7 @@ wl_event_source_timer_dispatch(struct wl_event_source *source,
len = read(source->fd, &expires, sizeof expires);
if (!(len == -1 && errno == EAGAIN) && len != sizeof expires)
/* Is there anything we can do here? Will this ever happen? */
fprintf(stderr, "timerfd read error: %m\n");
wl_log("timerfd read error: %m\n");
return timer_source->func(timer_source->base.data);
}
@ -212,10 +211,8 @@ wl_event_source_timer_update(struct wl_event_source *source, int ms_delay)
its.it_interval.tv_nsec = 0;
its.it_value.tv_sec = ms_delay / 1000;
its.it_value.tv_nsec = (ms_delay % 1000) * 1000 * 1000;
if (timerfd_settime(source->fd, 0, &its, NULL) < 0) {
fprintf(stderr, "could not set timerfd\n: %m");
if (timerfd_settime(source->fd, 0, &its, NULL) < 0)
return -1;
}
return 0;
}
@ -238,7 +235,7 @@ wl_event_source_signal_dispatch(struct wl_event_source *source,
len = read(source->fd, &signal_info, sizeof signal_info);
if (len != sizeof signal_info)
/* Is there anything we can do here? Will this ever happen? */
fprintf(stderr, "signalfd read error: %m\n");
wl_log("signalfd read error: %m\n");
return signal_source->func(signal_source->signal_number,
signal_source->base.data);

View file

@ -329,7 +329,7 @@ wl_proxy_add_listener(struct wl_proxy *proxy,
void (**implementation)(void), void *data)
{
if (proxy->object.implementation || proxy->dispatcher) {
fprintf(stderr, "proxy already has listener\n");
wl_log("proxy %p already has listener\n", proxy);
return -1;
}
@ -382,7 +382,7 @@ wl_proxy_add_dispatcher(struct wl_proxy *proxy,
const void *implementation, void *data)
{
if (proxy->object.implementation || proxy->dispatcher) {
fprintf(stderr, "proxy already has listener\n");
wl_log("proxy %p already has listener\n");
return -1;
}
@ -465,7 +465,7 @@ wl_proxy_marshal_array_constructor(struct wl_proxy *proxy,
closure = wl_closure_marshal(&proxy->object, opcode, args, message);
if (closure == NULL) {
fprintf(stderr, "Error marshalling request\n");
wl_log("Error marshalling request: %m\n");
abort();
}
@ -473,7 +473,7 @@ wl_proxy_marshal_array_constructor(struct wl_proxy *proxy,
wl_closure_print(closure, &proxy->object, true);
if (wl_closure_send(closure, proxy->display->connection)) {
fprintf(stderr, "Error sending request: %m\n");
wl_log("Error sending request: %m\n");
abort();
}
@ -635,9 +635,7 @@ connect_to_socket(const char *name)
runtime_dir = getenv("XDG_RUNTIME_DIR");
if (!runtime_dir) {
fprintf(stderr,
"error: XDG_RUNTIME_DIR not set in the environment.\n");
wl_log("error: XDG_RUNTIME_DIR not set in the environment.\n");
/* to prevent programs reporting
* "failed to create display: Success" */
errno = ENOENT;
@ -661,8 +659,7 @@ connect_to_socket(const char *name)
assert(name_size > 0);
if (name_size > (int)sizeof addr.sun_path) {
fprintf(stderr,
"error: socket path \"%s/%s\" plus null terminator"
wl_log("error: socket path \"%s/%s\" plus null terminator"
" exceeds 108 bytes\n", runtime_dir, name);
close(fd);
/* to prevent programs reporting