Merge pull request #15543 from poettering/fix-ubsan-sd-bus
sd-bus: work around ubsan warning
This commit is contained in:
commit
2d69cf6eb0
|
@ -111,7 +111,7 @@ bool strv_overlap(char * const *a, char * const *b) _pure_;
|
||||||
(s)--)
|
(s)--)
|
||||||
|
|
||||||
#define STRV_FOREACH_PAIR(x, y, l) \
|
#define STRV_FOREACH_PAIR(x, y, l) \
|
||||||
for ((x) = (l), (y) = (x+1); (x) && *(x) && *(y); (x) += 2, (y) = (x + 1))
|
for ((x) = (l), (y) = (x) ? (x+1) : NULL; (x) && *(x) && *(y); (x) += 2, (y) = (x + 1))
|
||||||
|
|
||||||
char **strv_sort(char **l);
|
char **strv_sort(char **l);
|
||||||
void strv_print(char * const *l);
|
void strv_print(char * const *l);
|
||||||
|
|
|
@ -1624,8 +1624,9 @@ int setup_namespace(
|
||||||
r = 0;
|
r = 0;
|
||||||
|
|
||||||
finish:
|
finish:
|
||||||
for (m = mounts; m < mounts + n_mounts; m++)
|
if (n_mounts > 0)
|
||||||
mount_entry_done(m);
|
for (m = mounts; m < mounts + n_mounts; m++)
|
||||||
|
mount_entry_done(m);
|
||||||
|
|
||||||
free(mounts);
|
free(mounts);
|
||||||
|
|
||||||
|
|
|
@ -1298,19 +1298,18 @@ static int message_add_offset(sd_bus_message *m, size_t offset) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void message_extend_containers(sd_bus_message *m, size_t expand) {
|
static void message_extend_containers(sd_bus_message *m, size_t expand) {
|
||||||
struct bus_container *c;
|
|
||||||
|
|
||||||
assert(m);
|
assert(m);
|
||||||
|
|
||||||
if (expand <= 0)
|
if (expand <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Update counters */
|
if (m->n_containers <= 0)
|
||||||
for (c = m->containers; c < m->containers + m->n_containers; c++) {
|
return;
|
||||||
|
|
||||||
|
/* Update counters */
|
||||||
|
for (struct bus_container *c = m->containers; c < m->containers + m->n_containers; c++)
|
||||||
if (c->array_size)
|
if (c->array_size)
|
||||||
*c->array_size += expand;
|
*c->array_size += expand;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *message_extend_body(
|
static void *message_extend_body(
|
||||||
|
@ -1373,7 +1372,6 @@ static void *message_extend_body(
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
struct bus_container *c;
|
|
||||||
void *op;
|
void *op;
|
||||||
size_t os, start_part, end_part;
|
size_t os, start_part, end_part;
|
||||||
|
|
||||||
|
@ -1394,8 +1392,9 @@ static void *message_extend_body(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Readjust pointers */
|
/* Readjust pointers */
|
||||||
for (c = m->containers; c < m->containers + m->n_containers; c++)
|
if (m->n_containers > 0)
|
||||||
c->array_size = adjust_pointer(c->array_size, op, os, part->data);
|
for (struct bus_container *c = m->containers; c < m->containers + m->n_containers; c++)
|
||||||
|
c->array_size = adjust_pointer(c->array_size, op, os, part->data);
|
||||||
|
|
||||||
m->error.message = (const char*) adjust_pointer(m->error.message, op, os, part->data);
|
m->error.message = (const char*) adjust_pointer(m->error.message, op, os, part->data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,12 +56,18 @@ static int node_vtable_get_userdata(
|
||||||
static void *vtable_method_convert_userdata(const sd_bus_vtable *p, void *u) {
|
static void *vtable_method_convert_userdata(const sd_bus_vtable *p, void *u) {
|
||||||
assert(p);
|
assert(p);
|
||||||
|
|
||||||
|
if (!u)
|
||||||
|
return SIZE_TO_PTR(p->x.method.offset); /* don't add offset on NULL, to make ubsan happy */
|
||||||
|
|
||||||
return (uint8_t*) u + p->x.method.offset;
|
return (uint8_t*) u + p->x.method.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *vtable_property_convert_userdata(const sd_bus_vtable *p, void *u) {
|
static void *vtable_property_convert_userdata(const sd_bus_vtable *p, void *u) {
|
||||||
assert(p);
|
assert(p);
|
||||||
|
|
||||||
|
if (!u)
|
||||||
|
return SIZE_TO_PTR(p->x.property.offset); /* as above */
|
||||||
|
|
||||||
return (uint8_t*) u + p->x.property.offset;
|
return (uint8_t*) u + p->x.property.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ struct acpi_table_header {
|
||||||
uint32_t oem_revision;
|
uint32_t oem_revision;
|
||||||
char asl_compiler_id[4];
|
char asl_compiler_id[4];
|
||||||
uint32_t asl_compiler_revision;
|
uint32_t asl_compiler_revision;
|
||||||
};
|
} _packed_;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ACPI_FPDT_TYPE_BOOT = 0,
|
ACPI_FPDT_TYPE_BOOT = 0,
|
||||||
|
@ -36,12 +36,12 @@ struct acpi_fpdt_header {
|
||||||
uint8_t revision;
|
uint8_t revision;
|
||||||
uint8_t reserved[4];
|
uint8_t reserved[4];
|
||||||
uint64_t ptr;
|
uint64_t ptr;
|
||||||
};
|
} _packed_;
|
||||||
|
|
||||||
struct acpi_fpdt_boot_header {
|
struct acpi_fpdt_boot_header {
|
||||||
char signature[4];
|
char signature[4];
|
||||||
uint32_t length;
|
uint32_t length;
|
||||||
};
|
} _packed_;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ACPI_FPDT_S3PERF_RESUME_REC = 0,
|
ACPI_FPDT_S3PERF_RESUME_REC = 0,
|
||||||
|
@ -59,7 +59,7 @@ struct acpi_fpdt_boot {
|
||||||
uint64_t startup_start;
|
uint64_t startup_start;
|
||||||
uint64_t exit_services_entry;
|
uint64_t exit_services_entry;
|
||||||
uint64_t exit_services_exit;
|
uint64_t exit_services_exit;
|
||||||
};
|
} _packed;
|
||||||
|
|
||||||
int acpi_get_boot_usec(usec_t *loader_start, usec_t *loader_exit) {
|
int acpi_get_boot_usec(usec_t *loader_start, usec_t *loader_exit) {
|
||||||
_cleanup_free_ char *buf = NULL;
|
_cleanup_free_ char *buf = NULL;
|
||||||
|
|
|
@ -410,7 +410,7 @@ static int output_units_list(const UnitInfo *unit_infos, unsigned c) {
|
||||||
if (arg_full)
|
if (arg_full)
|
||||||
table_set_width(table, 0);
|
table_set_width(table, 0);
|
||||||
|
|
||||||
for (u = unit_infos; u < unit_infos + c; u++) {
|
for (u = unit_infos; unit_infos && u < unit_infos + c; u++) {
|
||||||
_cleanup_free_ char *j = NULL;
|
_cleanup_free_ char *j = NULL;
|
||||||
const char *on_underline = "", *on_loaded = "", *on_active = "";
|
const char *on_underline = "", *on_loaded = "", *on_active = "";
|
||||||
const char *on_circle = "", *id;
|
const char *on_circle = "", *id;
|
||||||
|
|
Loading…
Reference in a new issue