Commit c7bada03 authored by Marek Chalupa's avatar Marek Chalupa Committed by Bryce Harrington
Browse files

add wl_abort private function



On many places in the code we use wl_log + abort or wl_log + assert(0).
Replace these with one call to wl_abort, so that we don't mix abort(),
assert(0) and we'll save few lines
Signed-off-by: default avatarMarek Chalupa <mchqwerty@gmail.com>
Reviewed-by: default avatarDerek Foreman <derekf@osg.samsung.com>
parent 5660ea41
......@@ -33,7 +33,6 @@
#include <stdio.h>
#include <errno.h>
#include <sys/uio.h>
#include <assert.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
......@@ -569,16 +568,12 @@ wl_closure_marshal(struct wl_object *sender, uint32_t opcode,
case 'h':
fd = args[i].h;
dup_fd = wl_os_dupfd_cloexec(fd, 0);
if (dup_fd < 0) {
wl_log("dup failed: %m");
abort();
}
if (dup_fd < 0)
wl_abort("dup failed: %s\n", strerror(errno));
closure->args[i].h = dup_fd;
break;
default:
wl_log("unhandled format code: '%c'\n",
arg.type);
assert(0);
wl_abort("unhandled format code: '%c'\n", arg.type);
break;
}
}
......@@ -771,8 +766,7 @@ wl_connection_demarshal(struct wl_connection *connection,
closure->args[i].h = fd;
break;
default:
wl_log("unknown type\n");
assert(0);
wl_abort("unknown type\n");
break;
}
}
......@@ -906,8 +900,7 @@ convert_arguments_to_ffi(const char *signature, uint32_t flags,
ffi_args[i] = &args[i].h;
break;
default:
wl_log("unknown type\n");
assert(0);
wl_abort("unknown type\n");
break;
}
}
......@@ -938,9 +931,8 @@ wl_closure_invoke(struct wl_closure *closure, uint32_t flags,
implementation = target->implementation;
if (!implementation[opcode]) {
wl_log("listener function for opcode %u of %s is NULL\n",
opcode, target->interface->name);
abort();
wl_abort("listener function for opcode %u of %s is NULL\n",
opcode, target->interface->name);
}
ffi_call(&cif, implementation[opcode], NULL, ffi_args);
}
......
......@@ -597,18 +597,14 @@ wl_proxy_marshal_array_constructor(struct wl_proxy *proxy,
}
closure = wl_closure_marshal(&proxy->object, opcode, args, message);
if (closure == NULL) {
wl_log("Error marshalling request: %m\n");
abort();
}
if (closure == NULL)
wl_abort("Error marshalling request: %s\n", strerror(errno));
if (debug_client)
wl_closure_print(closure, &proxy->object, true);
if (wl_closure_send(closure, proxy->display->connection)) {
wl_log("Error sending request: %m\n");
abort();
}
if (wl_closure_send(closure, proxy->display->connection))
wl_abort("Error sending request: %s\n", strerror(errno));
wl_closure_destroy(closure);
......
......@@ -209,6 +209,7 @@ wl_closure_destroy(struct wl_closure *closure);
extern wl_log_func_t wl_log_handler;
void wl_log(const char *fmt, ...);
void wl_abort(const char *fmt, ...);
struct wl_display;
......
......@@ -385,3 +385,15 @@ wl_log(const char *fmt, ...)
wl_log_handler(fmt, argp);
va_end(argp);
}
void
wl_abort(const char *fmt, ...)
{
va_list argp;
va_start(argp, fmt);
wl_log_handler(fmt, argp);
va_end(argp);
abort();
}
......@@ -31,8 +31,8 @@
#include "test-runner.h"
#include "wayland-util.h"
#include "wayland-private.h"
#define WL_HIDE_DEPRECATED
#include "test-compositor.h"
extern int leak_check_enabled;
......@@ -56,6 +56,11 @@ FAIL_TEST(fail_abort)
abort();
}
FAIL_TEST(fail_wl_abort)
{
wl_abort("Abort the program\n");
}
FAIL_TEST(fail_kill)
{
kill(getpid(), SIGTERM);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment