From 04499a70fbff3f6b798028473f5c9234a53eaa2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 27 Jul 2021 12:27:28 +0200 Subject: Drop the text argument from assert_not_reached() In general we almost never hit those asserts in production code, so users see them very rarely, if ever. But either way, we just need something that users can pass to the developers. We have quite a few of those asserts, and some have fairly nice messages, but many are like "WTF?" or "???" or "unexpected something". The error that is printed includes the file location, and function name. In almost all functions there's at most one assert, so the function name alone is enough to identify the failure for a developer. So we don't get much extra from the message, and we might just as well drop them. Dropping them makes our code a tiny bit smaller, and most importantly, improves development experience by making it easy to insert such an assert in the code without thinking how to phrase the argument. --- src/busctl/busctl-introspect.c | 2 +- src/busctl/busctl.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/busctl') diff --git a/src/busctl/busctl-introspect.c b/src/busctl/busctl-introspect.c index 89b32f4c73..4dbb11f15b 100644 --- a/src/busctl/busctl-introspect.c +++ b/src/busctl/busctl-introspect.c @@ -147,7 +147,7 @@ static int parse_xml_annotation(Context *context, uint64_t *flags) { break; default: - assert_not_reached("Bad state"); + assert_not_reached(); } } } diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c index 8aa769e0f9..b9d84c9e58 100644 --- a/src/busctl/busctl.c +++ b/src/busctl/busctl.c @@ -121,7 +121,7 @@ static int acquire_bus(bool set_monitor, sd_bus **ret) { break; default: - assert_not_reached("Hmm, unknown transport type."); + assert_not_reached(); } } if (r < 0) @@ -718,7 +718,7 @@ static int format_cmdline(sd_bus_message *m, FILE *f, bool needs_space) { break; default: - assert_not_reached("Unknown basic type."); + assert_not_reached(); } needs_space = true; @@ -1957,7 +1957,7 @@ static int json_transform_one(sd_bus_message *m, JsonVariant **ret) { break; default: - assert_not_reached("Unexpected element type"); + assert_not_reached(); } *ret = TAKE_PTR(v); @@ -2525,7 +2525,7 @@ static int parse_argv(int argc, char *argv[]) { return -EINVAL; default: - assert_not_reached("Unhandled option"); + assert_not_reached(); } return 1; -- cgit v1.2.1