summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/test-bus-error.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-10-31 09:31:02 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-10-31 11:32:00 -0400
commit5e071f200c4cc86443af07a876ee0e1c2901fda1 (patch)
tree5c1d626fcaa0260e9eeb0d5bc2fe4941b171ee5c /src/libsystemd/sd-bus/test-bus-error.c
parent919699ec301ea507edce4a619141ed22e789ac0d (diff)
bus: do not segfault on zeros in errno mapping table
Depending on the link order, holes might appear in the body of the sd_bus_errnomap section. Ignore them. Adds a simple test to print the table to help with debugging such issues in the future.
Diffstat (limited to 'src/libsystemd/sd-bus/test-bus-error.c')
-rw-r--r--src/libsystemd/sd-bus/test-bus-error.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libsystemd/sd-bus/test-bus-error.c b/src/libsystemd/sd-bus/test-bus-error.c
index dd0cca4ab8..aff34a90cd 100644
--- a/src/libsystemd/sd-bus/test-bus-error.c
+++ b/src/libsystemd/sd-bus/test-bus-error.c
@@ -111,6 +111,18 @@ static void test_error(void) {
assert_se(sd_bus_error_is_set(&error));
}
+extern const sd_bus_name_error_mapping __start_sd_bus_errnomap[];
+extern const sd_bus_name_error_mapping __stop_sd_bus_errnomap[];
+
+static void dump_mapping_table(void) {
+ const sd_bus_name_error_mapping *m;
+
+ printf("----- errno mappings ------\n");
+ for (m = __start_sd_bus_errnomap; m < __stop_sd_bus_errnomap; m++)
+ printf("%s -> %d\n", m->name, m->code);
+ printf("---------------------------\n");
+}
+
static void test_errno_mapping_standard(void) {
assert_se(sd_bus_error_set(NULL, "System.Error.EUCLEAN", NULL) == -EUCLEAN);
assert_se(sd_bus_error_set(NULL, "System.Error.EBUSY", NULL) == -EBUSY);
@@ -130,6 +142,7 @@ static void test_errno_mapping_custom(void) {
}
int main(int argc, char *argv[]) {
+ dump_mapping_table();
test_error();
test_errno_mapping_standard();