chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Prep v234: Update root build files to upstream.
[elogind.git]
/
src
/
libelogind
/
sd-bus
/
bus-message.c
diff --git
a/src/libelogind/sd-bus/bus-message.c
b/src/libelogind/sd-bus/bus-message.c
index 08cecfb2853b509501ff9ddfd10d87eb9224aa4d..cbe9c6259cc21236cdf0dc0cbe5b2c1b13bb2c8d 100644
(file)
--- a/
src/libelogind/sd-bus/bus-message.c
+++ b/
src/libelogind/sd-bus/bus-message.c
@@
-1,5
+1,3
@@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
/***
This file is part of systemd.
/***
This file is part of systemd.
@@
-183,7
+181,7
@@
static void *message_extend_fields(sd_bus_message *m, size_t align, size_t sz, b
if (!np)
goto poison;
} else {
if (!np)
goto poison;
} else {
- /* Initially, the header is allocated as part of
of
+ /* Initially, the header is allocated as part of
* the sd_bus_message itself, let's replace it by
* dynamic data */
* the sd_bus_message itself, let's replace it by
* dynamic data */
@@
-802,7
+800,7
@@
_public_ int sd_bus_message_new_method_errorf(
const char *format,
...) {
const char *format,
...) {
- _cleanup_
bus_error_free_
sd_bus_error error = SD_BUS_ERROR_NULL;
+ _cleanup_
(sd_bus_error_free)
sd_bus_error error = SD_BUS_ERROR_NULL;
va_list ap;
assert_return(name, -EINVAL);
va_list ap;
assert_return(name, -EINVAL);
@@
-821,7
+819,7
@@
_public_ int sd_bus_message_new_method_errno(
int error,
const sd_bus_error *p) {
int error,
const sd_bus_error *p) {
- _cleanup_
bus_error_free_
sd_bus_error berror = SD_BUS_ERROR_NULL;
+ _cleanup_
(sd_bus_error_free)
sd_bus_error berror = SD_BUS_ERROR_NULL;
if (sd_bus_error_is_set(p))
return sd_bus_message_new_method_error(call, m, p);
if (sd_bus_error_is_set(p))
return sd_bus_message_new_method_error(call, m, p);
@@
-839,7
+837,7
@@
_public_ int sd_bus_message_new_method_errnof(
const char *format,
...) {
const char *format,
...) {
- _cleanup_
bus_error_free_
sd_bus_error berror = SD_BUS_ERROR_NULL;
+ _cleanup_
(sd_bus_error_free)
sd_bus_error berror = SD_BUS_ERROR_NULL;
va_list ap;
va_start(ap, format);
va_list ap;
va_start(ap, format);
@@
-921,7
+919,9
@@
fail:
}
_public_ sd_bus_message* sd_bus_message_ref(sd_bus_message *m) {
}
_public_ sd_bus_message* sd_bus_message_ref(sd_bus_message *m) {
- assert_return(m, NULL);
+
+ if (!m)
+ return NULL;
assert(m->n_ref > 0);
m->n_ref++;
assert(m->n_ref > 0);
m->n_ref++;
@@
-1082,7
+1082,6
@@
_public_ sd_bus_creds *sd_bus_message_get_creds(sd_bus_message *m) {
return &m->creds;
}
return &m->creds;
}
-#if 0 /// UNNEEDED by elogind
_public_ int sd_bus_message_is_signal(
sd_bus_message *m,
const char *interface,
_public_ int sd_bus_message_is_signal(
sd_bus_message *m,
const char *interface,
@@
-1101,7
+1100,6
@@
_public_ int sd_bus_message_is_signal(
return 1;
}
return 1;
}
-#endif // 0
_public_ int sd_bus_message_is_method_call(
sd_bus_message *m,
_public_ int sd_bus_message_is_method_call(
sd_bus_message *m,
@@
-1140,10
+1138,7
@@
_public_ int sd_bus_message_set_expect_reply(sd_bus_message *m, int b) {
assert_return(!m->sealed, -EPERM);
assert_return(m->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EPERM);
assert_return(!m->sealed, -EPERM);
assert_return(m->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EPERM);
- if (b)
- m->header->flags &= ~BUS_MESSAGE_NO_REPLY_EXPECTED;
- else
- m->header->flags |= BUS_MESSAGE_NO_REPLY_EXPECTED;
+ SET_FLAG(m->header->flags, BUS_MESSAGE_NO_REPLY_EXPECTED, !b);
return 0;
}
return 0;
}
@@
-1152,10
+1147,7
@@
_public_ int sd_bus_message_set_auto_start(sd_bus_message *m, int b) {
assert_return(m, -EINVAL);
assert_return(!m->sealed, -EPERM);
assert_return(m, -EINVAL);
assert_return(!m->sealed, -EPERM);
- if (b)
- m->header->flags &= ~BUS_MESSAGE_NO_AUTO_START;
- else
- m->header->flags |= BUS_MESSAGE_NO_AUTO_START;
+ SET_FLAG(m->header->flags, BUS_MESSAGE_NO_AUTO_START, !b);
return 0;
}
return 0;
}
@@
-1164,10
+1156,7
@@
_public_ int sd_bus_message_set_allow_interactive_authorization(sd_bus_message *
assert_return(m, -EINVAL);
assert_return(!m->sealed, -EPERM);
assert_return(m, -EINVAL);
assert_return(!m->sealed, -EPERM);
- if (b)
- m->header->flags |= BUS_MESSAGE_ALLOW_INTERACTIVE_AUTHORIZATION;
- else
- m->header->flags &= ~BUS_MESSAGE_ALLOW_INTERACTIVE_AUTHORIZATION;
+ SET_FLAG(m->header->flags, BUS_MESSAGE_ALLOW_INTERACTIVE_AUTHORIZATION, b);
return 0;
}
return 0;
}
@@
-1208,7
+1197,7
@@
struct bus_body_part *message_append_part(sd_bus_message *m) {
part->memfd = -1;
m->body_end = part;
part->memfd = -1;
m->body_end = part;
- m->n_body_parts
++;
+ m->n_body_parts++;
return part;
}
return part;
}
@@
-1653,7
+1642,7
@@
int message_append_basic(sd_bus_message *m, char type, const void *p, const void
}
if (type == SD_BUS_TYPE_UNIX_FD)
}
if (type == SD_BUS_TYPE_UNIX_FD)
- m->n_fds
++;
+ m->n_fds++;
if (c->enclosing != SD_BUS_TYPE_ARRAY)
c->index++;
if (c->enclosing != SD_BUS_TYPE_ARRAY)
c->index++;
@@
-2362,7
+2351,7
@@
static int type_stack_pop(TypeStack *stack, unsigned max, unsigned *i, const cha
return 1;
}
return 1;
}
-
int bus_message_append_ap
(
+
_public_ int sd_bus_message_appendv
(
sd_bus_message *m,
const char *types,
va_list ap) {
sd_bus_message *m,
const char *types,
va_list ap) {
@@
-2372,10
+2361,10
@@
int bus_message_append_ap(
unsigned stack_ptr = 0;
int r;
unsigned stack_ptr = 0;
int r;
- assert
(m
);
-
- if (!types)
-
return 0
;
+ assert
_return(m, -EINVAL
);
+ assert_return(types, -EINVAL);
+ assert_return(!m->sealed, -EPERM);
+
assert_return(!m->poisoned, -ESTALE)
;
n_array = (unsigned) -1;
n_struct = strlen(types);
n_array = (unsigned) -1;
n_struct = strlen(types);
@@
-2399,9
+2388,9
@@
int bus_message_append_ap(
t = types;
if (n_array != (unsigned) -1)
t = types;
if (n_array != (unsigned) -1)
- n_array
--;
+ n_array--;
else {
else {
- types
++;
+ types++;
n_struct--;
}
n_struct--;
}
@@
-2576,13
+2565,12
@@
_public_ int sd_bus_message_append(sd_bus_message *m, const char *types, ...) {
assert_return(!m->poisoned, -ESTALE);
va_start(ap, types);
assert_return(!m->poisoned, -ESTALE);
va_start(ap, types);
- r =
bus_message_append_ap
(m, types, ap);
+ r =
sd_bus_message_appendv
(m, types, ap);
va_end(ap);
return r;
}
va_end(ap);
return r;
}
-#if 0 /// UNNEEDED by elogind
_public_ int sd_bus_message_append_array_space(
sd_bus_message *m,
char type,
_public_ int sd_bus_message_append_array_space(
sd_bus_message *m,
char type,
@@
-2626,6
+2614,7
@@
_public_ int sd_bus_message_append_array_space(
return 0;
}
return 0;
}
+#if 0 /// UNNEEDED by elogind
_public_ int sd_bus_message_append_array(
sd_bus_message *m,
char type,
_public_ int sd_bus_message_append_array(
sd_bus_message *m,
char type,
@@
-2644,8
+2633,7
@@
_public_ int sd_bus_message_append_array(
if (r < 0)
return r;
if (r < 0)
return r;
- if (size > 0)
- memcpy(p, ptr, size);
+ memcpy_safe(p, ptr, size);
return 0;
}
return 0;
}
@@
-2889,7
+2877,7
@@
static int bus_message_close_header(sd_bus_message *m) {
/* The actual user data is finished now, we just complete the
variant and struct now (at least on gvariant). Remember
/* The actual user data is finished now, we just complete the
variant and struct now (at least on gvariant). Remember
- this position, so that during parsing we know where to
to
+ this position, so that during parsing we know where to
put the outer container end. */
m->user_body_size = m->body_size;
put the outer container end. */
m->user_body_size = m->body_size;
@@
-3883,7
+3871,7
@@
static int build_struct_offsets(
if (r < 0)
return r;
if (r == 0 && p[n] != 0) /* except the last item */
if (r < 0)
return r;
if (r == 0 && p[n] != 0) /* except the last item */
- n_variable
++;
+ n_variable++;
n_total++;
p += n;
n_total++;
p += n;
@@
-4483,9
+4471,9
@@
static int message_read_ap(
t = types;
if (n_array != (unsigned) -1)
t = types;
if (n_array != (unsigned) -1)
- n_array
--;
+ n_array--;
else {
else {
- types
++;
+ types++;
n_struct--;
}
n_struct--;
}
@@
-5686,8
+5674,8
@@
int bus_message_get_arg(sd_bus_message *m, unsigned i, const char **str) {
assert(str);
r = bus_message_get_arg_skip(m, i, &type, NULL);
assert(str);
r = bus_message_get_arg_skip(m, i, &type, NULL);
-
if (r < 0)
-
return r;
+ if (r < 0)
+ return r;
if (!IN_SET(type, SD_BUS_TYPE_STRING, SD_BUS_TYPE_OBJECT_PATH, SD_BUS_TYPE_SIGNATURE))
return -ENXIO;
if (!IN_SET(type, SD_BUS_TYPE_STRING, SD_BUS_TYPE_OBJECT_PATH, SD_BUS_TYPE_SIGNATURE))
return -ENXIO;
@@
-5704,8
+5692,8
@@
int bus_message_get_arg_strv(sd_bus_message *m, unsigned i, char ***strv) {
assert(strv);
r = bus_message_get_arg_skip(m, i, &type, &contents);
assert(strv);
r = bus_message_get_arg_skip(m, i, &type, &contents);
-
if (r < 0)
-
return r;
+ if (r < 0)
+ return r;
if (type != SD_BUS_TYPE_ARRAY)
return -ENXIO;
if (type != SD_BUS_TYPE_ARRAY)
return -ENXIO;
@@
-5860,7
+5848,7
@@
_public_ sd_bus *sd_bus_message_get_bus(sd_bus_message *m) {
}
int bus_message_remarshal(sd_bus *bus, sd_bus_message **m) {
}
int bus_message_remarshal(sd_bus *bus, sd_bus_message **m) {
- _cleanup_
bus_message_unref_
sd_bus_message *n = NULL;
+ _cleanup_
(sd_bus_message_unrefp)
sd_bus_message *n = NULL;
usec_t timeout;
int r;
usec_t timeout;
int r;