chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d838db0
)
libsystemd-bus: use assert_return
author
Lukasz Skalski
<l.skalski@partner.samsung.com>
Mon, 9 Dec 2013 13:09:25 +0000
(14:09 +0100)
committer
Zbigniew Jędrzejewski-Szmek
<zbyszek@in.waw.pl>
Tue, 10 Dec 2013 04:27:19 +0000
(23:27 -0500)
src/libsystemd-bus/bus-error.c
patch
|
blob
|
history
src/libsystemd-bus/bus-kernel.c
patch
|
blob
|
history
src/libsystemd-bus/bus-message.c
patch
|
blob
|
history
src/libsystemd-bus/bus-signature.c
patch
|
blob
|
history
diff --git
a/src/libsystemd-bus/bus-error.c
b/src/libsystemd-bus/bus-error.c
index 25eaf0eee4961563535afc95b55e1ced63145169..4f1862975882e71c7c7a4cfddc4287dcbee9f0df 100644
(file)
--- a/
src/libsystemd-bus/bus-error.c
+++ b/
src/libsystemd-bus/bus-error.c
@@
-39,8
+39,7
@@
static int bus_error_name_to_errno(const char *name) {
const char *p;
int r;
const char *p;
int r;
- if (!name)
- return EINVAL;
+ assert_return(name, EINVAL);
p = startswith(name, "System.Error.");
if (p) {
p = startswith(name, "System.Error.");
if (p) {
diff --git
a/src/libsystemd-bus/bus-kernel.c
b/src/libsystemd-bus/bus-kernel.c
index d0a9fbc3fb9af7476e65275ac910c17188900ed6..0f38b660a5368ba802c35b92cf5940abf8dca635 100644
(file)
--- a/
src/libsystemd-bus/bus-kernel.c
+++ b/
src/libsystemd-bus/bus-kernel.c
@@
-321,9
+321,7
@@
int bus_kernel_take_fd(sd_bus *b) {
int r;
assert(b);
int r;
assert(b);
-
- if (b->is_server)
- return -EINVAL;
+ assert_return(!b->is_server, -EINVAL);
b->use_memfd = 1;
b->use_memfd = 1;
@@
-375,9
+373,7
@@
int bus_kernel_connect(sd_bus *b) {
assert(b->input_fd < 0);
assert(b->output_fd < 0);
assert(b->kernel);
assert(b->input_fd < 0);
assert(b->output_fd < 0);
assert(b->kernel);
-
- if (b->is_server)
- return -EINVAL;
+ assert_return(!b->is_server, -EINVAL);
b->input_fd = open(b->kernel, O_RDWR|O_NOCTTY|O_CLOEXEC);
if (b->input_fd < 0)
b->input_fd = open(b->kernel, O_RDWR|O_NOCTTY|O_CLOEXEC);
if (b->input_fd < 0)
@@
-918,9
+914,7
@@
int bus_kernel_pop_memfd(sd_bus *bus, void **address, size_t *size) {
assert(address);
assert(size);
assert(address);
assert(size);
-
- if (!bus || !bus->is_kernel)
- return -ENOTSUP;
+ assert_return(bus && bus->is_kernel, -ENOTSUP);
assert_se(pthread_mutex_lock(&bus->memfd_cache_mutex) >= 0);
assert_se(pthread_mutex_lock(&bus->memfd_cache_mutex) >= 0);
diff --git
a/src/libsystemd-bus/bus-message.c
b/src/libsystemd-bus/bus-message.c
index 9e712717cc34b31864af3e5d97953cc52dac2539..5e355127b0cb119f460738c1c9c346a5a3114b97 100644
(file)
--- a/
src/libsystemd-bus/bus-message.c
+++ b/
src/libsystemd-bus/bus-message.c
@@
-161,9
+161,7
@@
static void *message_extend_fields(sd_bus_message *m, size_t align, size_t sz, b
size_t old_size, new_size, start;
assert(m);
size_t old_size, new_size, start;
assert(m);
-
- if (m->poisoned)
- return NULL;
+ assert_return(!m->poisoned, NULL);
old_size = sizeof(struct bus_header) + m->header->fields_size;
start = ALIGN_TO(old_size, align);
old_size = sizeof(struct bus_header) + m->header->fields_size;
start = ALIGN_TO(old_size, align);
@@
-989,9
+987,7
@@
struct bus_body_part *message_append_part(sd_bus_message *m) {
struct bus_body_part *part;
assert(m);
struct bus_body_part *part;
assert(m);
-
- if (m->poisoned)
- return NULL;
+ assert_return(!m->poisoned, NULL);
if (m->n_body_parts <= 0) {
part = &m->body;
if (m->n_body_parts <= 0) {
part = &m->body;
@@
-1138,9
+1134,7
@@
static void *message_extend_body(sd_bus_message *m, size_t align, size_t sz, boo
assert(m);
assert(align > 0);
assert(!m->sealed);
assert(m);
assert(align > 0);
assert(!m->sealed);
-
- if (m->poisoned)
- return NULL;
+ assert_return(!m->poisoned, NULL);
start_body = ALIGN_TO((size_t) m->header->body_size, align);
end_body = start_body + sz;
start_body = ALIGN_TO((size_t) m->header->body_size, align);
end_body = start_body + sz;
diff --git
a/src/libsystemd-bus/bus-signature.c
b/src/libsystemd-bus/bus-signature.c
index 1e5bf4821d9526da05478c92cfe2785acd611b08..3fb07943d7c9e09c8a369055c8bb86544cc8c1a3 100644
(file)
--- a/
src/libsystemd-bus/bus-signature.c
+++ b/
src/libsystemd-bus/bus-signature.c
@@
-33,9
+33,7
@@
static int signature_element_length_internal(
int r;
int r;
- if (!s)
- return -EINVAL;
-
+ assert_return(s, -EINVAL);
assert(l);
if (bus_type_is_basic(*s) || *s == SD_BUS_TYPE_VARIANT) {
assert(l);
if (bus_type_is_basic(*s) || *s == SD_BUS_TYPE_VARIANT) {
@@
-117,8
+115,7
@@
bool signature_is_single(const char *s, bool allow_dict_entry) {
int r;
size_t t;
int r;
size_t t;
- if (!s)
- return false;
+ assert_return(s, false);
r = signature_element_length_internal(s, allow_dict_entry, 0, 0, &t);
if (r < 0)
r = signature_element_length_internal(s, allow_dict_entry, 0, 0, &t);
if (r < 0)
@@
-129,8
+126,7
@@
bool signature_is_single(const char *s, bool allow_dict_entry) {
bool signature_is_pair(const char *s) {
bool signature_is_pair(const char *s) {
- if (!s)
- return false;
+ assert_return(s, false);
if (!bus_type_is_basic(*s))
return false;
if (!bus_type_is_basic(*s))
return false;
@@
-142,8
+138,7
@@
bool signature_is_valid(const char *s, bool allow_dict_entry) {
const char *p;
int r;
const char *p;
int r;
- if (!s)
- return false;
+ assert_return(s, false);
p = s;
while (*p) {
p = s;
while (*p) {