diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-07-27 12:27:28 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-08-03 10:05:10 +0200 |
commit | 04499a70fbff3f6b798028473f5c9234a53eaa2d (patch) | |
tree | ec7a851e163ee20ba5211c16a86f1c251543e0a7 /src/udev | |
parent | Merge pull request #20346 from poettering/strlen-unsigned-fix (diff) | |
download | systemd-04499a70fbff3f6b798028473f5c9234a53eaa2d.tar.xz systemd-04499a70fbff3f6b798028473f5c9234a53eaa2d.zip |
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.
Diffstat (limited to 'src/udev')
-rw-r--r-- | src/udev/cdrom_id/cdrom_id.c | 2 | ||||
-rw-r--r-- | src/udev/dmi_memory_id/dmi_memory_id.c | 2 | ||||
-rw-r--r-- | src/udev/net/link-config.c | 4 | ||||
-rw-r--r-- | src/udev/scsi_id/scsi_id.c | 2 | ||||
-rw-r--r-- | src/udev/test-udev-event.c | 2 | ||||
-rw-r--r-- | src/udev/udev-event.c | 2 | ||||
-rw-r--r-- | src/udev/udev-rules.c | 8 | ||||
-rw-r--r-- | src/udev/udevadm-control.c | 2 | ||||
-rw-r--r-- | src/udev/udevadm-hwdb.c | 2 | ||||
-rw-r--r-- | src/udev/udevadm-info.c | 6 | ||||
-rw-r--r-- | src/udev/udevadm-monitor.c | 2 | ||||
-rw-r--r-- | src/udev/udevadm-settle.c | 2 | ||||
-rw-r--r-- | src/udev/udevadm-test-builtin.c | 2 | ||||
-rw-r--r-- | src/udev/udevadm-test.c | 2 | ||||
-rw-r--r-- | src/udev/udevadm-trigger.c | 4 | ||||
-rw-r--r-- | src/udev/udevadm.c | 2 | ||||
-rw-r--r-- | src/udev/udevd.c | 2 | ||||
-rw-r--r-- | src/udev/v4l_id/v4l_id.c | 2 |
18 files changed, 25 insertions, 25 deletions
diff --git a/src/udev/cdrom_id/cdrom_id.c b/src/udev/cdrom_id/cdrom_id.c index df0ee6a3bb..a2185350d3 100644 --- a/src/udev/cdrom_id/cdrom_id.c +++ b/src/udev/cdrom_id/cdrom_id.c @@ -943,7 +943,7 @@ static int parse_argv(int argc, char *argv[]) { case 'h': return help(); default: - assert_not_reached("Unknown option"); + assert_not_reached(); } arg_node = argv[optind]; diff --git a/src/udev/dmi_memory_id/dmi_memory_id.c b/src/udev/dmi_memory_id/dmi_memory_id.c index 64eba0d314..4c0ec2eccb 100644 --- a/src/udev/dmi_memory_id/dmi_memory_id.c +++ b/src/udev/dmi_memory_id/dmi_memory_id.c @@ -665,7 +665,7 @@ static int parse_argv(int argc, char * const *argv) { case '?': return -EINVAL; default: - assert_not_reached("Unknown option"); + assert_not_reached(); } return 1; diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c index 8dfe23691b..fa43548280 100644 --- a/src/udev/net/link-config.c +++ b/src/udev/net/link-config.c @@ -501,7 +501,7 @@ static int link_config_generate_new_name(const LinkConfigContext *ctx, const Lin (void) sd_device_get_property_value(device, "ID_NET_NAME_MAC", &new_name); break; default: - assert_not_reached("invalid policy"); + assert_not_reached(); } if (ifname_valid(new_name)) { log_device_debug(device, "Policy *%s* yields \"%s\".", name_policy_to_string(policy), new_name); @@ -569,7 +569,7 @@ static int link_config_apply_alternative_names(sd_netlink **rtnl, const LinkConf (void) sd_device_get_property_value(device, "ID_NET_NAME_MAC", &n); break; default: - assert_not_reached("invalid policy"); + assert_not_reached(); } if (!isempty(n)) { r = strv_extend(&altnames, n); diff --git a/src/udev/scsi_id/scsi_id.c b/src/udev/scsi_id/scsi_id.c index b2d8154d86..8ce73d03da 100644 --- a/src/udev/scsi_id/scsi_id.c +++ b/src/udev/scsi_id/scsi_id.c @@ -306,7 +306,7 @@ static int set_options(int argc, char **argv, return -1; default: - assert_not_reached("Unknown option"); + assert_not_reached(); } if (optind < argc && !dev_specified) { diff --git a/src/udev/test-udev-event.c b/src/udev/test-udev-event.c index fd1752c65f..b1a631dea2 100644 --- a/src/udev/test-udev-event.c +++ b/src/udev/test-udev-event.c @@ -83,7 +83,7 @@ int main(int argc, char *argv[]) { else if (streq(argv[1], "test2")) test2(); else - assert_not_reached("unknown command."); + assert_not_reached(); return 0; } diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c index d269345259..2179c8d254 100644 --- a/src/udev/udev-event.c +++ b/src/udev/udev-event.c @@ -429,7 +429,7 @@ static ssize_t udev_event_subst_format( strpcpy(&s, l, val); break; default: - assert_not_reached("Unknown format substitution type"); + assert_not_reached(); } return s - dest; diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index bf997fc0ed..d050134aef 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -1374,7 +1374,7 @@ static bool token_match_string(UdevRuleToken *token, const char *str) { } break; default: - assert_not_reached("Invalid match type"); + assert_not_reached(); } return token->op == (match ? OP_MATCH : OP_NOMATCH); @@ -1405,7 +1405,7 @@ static bool token_match_attr(UdevRuleToken *token, sd_device *dev, UdevEvent *ev value = vbuf; break; default: - assert_not_reached("Invalid attribute substitution type"); + assert_not_reached(); } /* remove trailing whitespace, if not asked to match for it */ @@ -1607,7 +1607,7 @@ static int udev_rule_apply_token_to_event( else if (streq(k, "virt")) val = virtualization_to_string(detect_virtualization()); else - assert_not_reached("Invalid CONST key"); + assert_not_reached(); return token_match_string(token, val); } case TK_M_TAG: @@ -2233,7 +2233,7 @@ static int udev_rule_apply_token_to_event( /* do nothing for events. */ break; default: - assert_not_reached("Invalid token type"); + assert_not_reached(); } return true; diff --git a/src/udev/udevadm-control.c b/src/udev/udevadm-control.c index 437ac9b832..20820dd647 100644 --- a/src/udev/udevadm-control.c +++ b/src/udev/udevadm-control.c @@ -171,7 +171,7 @@ int control_main(int argc, char *argv[], void *userdata) { case '?': return -EINVAL; default: - assert_not_reached("Unknown option."); + assert_not_reached(); } if (optind < argc) diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c index 9414269fb8..e9db2847cf 100644 --- a/src/udev/udevadm-hwdb.c +++ b/src/udev/udevadm-hwdb.c @@ -71,7 +71,7 @@ static int parse_argv(int argc, char *argv[]) { case '?': return -EINVAL; default: - assert_not_reached("Unknown option"); + assert_not_reached(); } return 1; diff --git a/src/udev/udevadm-info.c b/src/udev/udevadm-info.c index fa7f04f14c..1ea89c16cc 100644 --- a/src/udev/udevadm-info.c +++ b/src/udev/udevadm-info.c @@ -328,7 +328,7 @@ static int query_device(QueryType query, sd_device* device) { return print_record(device); } - assert_not_reached("unknown query type"); + assert_not_reached(); return 0; } @@ -456,7 +456,7 @@ int info_main(int argc, char *argv[], void *userdata) { case '?': return -EINVAL; default: - assert_not_reached("Unknown option"); + assert_not_reached(); } if (action == ACTION_DEVICE_ID_FILE) { @@ -508,7 +508,7 @@ int info_main(int argc, char *argv[], void *userdata) { else if (action == ACTION_ATTRIBUTE_WALK) r = print_device_chain(device); else - assert_not_reached("Unknown action"); + assert_not_reached(); if (r < 0) return r; } diff --git a/src/udev/udevadm-monitor.c b/src/udev/udevadm-monitor.c index 00b03c550d..76aaf7c42e 100644 --- a/src/udev/udevadm-monitor.c +++ b/src/udev/udevadm-monitor.c @@ -179,7 +179,7 @@ static int parse_argv(int argc, char *argv[]) { case '?': return -EINVAL; default: - assert_not_reached("Unknown option."); + assert_not_reached(); } if (!arg_print_kernel && !arg_print_udev) { diff --git a/src/udev/udevadm-settle.c b/src/udev/udevadm-settle.c index 2c61c2d8b0..84b4f9ca45 100644 --- a/src/udev/udevadm-settle.c +++ b/src/udev/udevadm-settle.c @@ -81,7 +81,7 @@ static int parse_argv(int argc, char *argv[]) { case '?': return -EINVAL; default: - assert_not_reached("Unknown option."); + assert_not_reached(); } } diff --git a/src/udev/udevadm-test-builtin.c b/src/udev/udevadm-test-builtin.c index 008d6f2914..992fc70807 100644 --- a/src/udev/udevadm-test-builtin.c +++ b/src/udev/udevadm-test-builtin.c @@ -45,7 +45,7 @@ static int parse_argv(int argc, char *argv[]) { case '?': return -EINVAL; default: - assert_not_reached("Unknown option"); + assert_not_reached(); } arg_command = argv[optind++]; diff --git a/src/udev/udevadm-test.c b/src/udev/udevadm-test.c index fbac719fa0..f6ec222884 100644 --- a/src/udev/udevadm-test.c +++ b/src/udev/udevadm-test.c @@ -81,7 +81,7 @@ static int parse_argv(int argc, char *argv[]) { case '?': return -EINVAL; default: - assert_not_reached("Unknown option"); + assert_not_reached(); } if (!argv[optind]) diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c index 984ec1b84b..8acf3d9b11 100644 --- a/src/udev/udevadm-trigger.c +++ b/src/udev/udevadm-trigger.c @@ -416,7 +416,7 @@ int trigger_main(int argc, char *argv[], void *userdata) { case '?': return -EINVAL; default: - assert_not_reached("Unknown option"); + assert_not_reached(); } } @@ -482,7 +482,7 @@ int trigger_main(int argc, char *argv[], void *userdata) { return log_error_errno(r, "Failed to scan devices: %m"); break; default: - assert_not_reached("Unknown device type"); + assert_not_reached(); } r = exec_list(e, action, settle_hashmap); diff --git a/src/udev/udevadm.c b/src/udev/udevadm.c index e55ae4bd54..ba17d9348b 100644 --- a/src/udev/udevadm.c +++ b/src/udev/udevadm.c @@ -77,7 +77,7 @@ static int parse_argv(int argc, char *argv[]) { return -EINVAL; default: - assert_not_reached("Unhandled option"); + assert_not_reached(); } return 1; /* work to do */ diff --git a/src/udev/udevd.c b/src/udev/udevd.c index 13ac7c83b5..5a4657de14 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -1663,7 +1663,7 @@ static int parse_argv(int argc, char *argv[]) { case '?': return -EINVAL; default: - assert_not_reached("Unhandled option"); + assert_not_reached(); } } diff --git a/src/udev/v4l_id/v4l_id.c b/src/udev/v4l_id/v4l_id.c index 26b634ef5b..c2312c7909 100644 --- a/src/udev/v4l_id/v4l_id.c +++ b/src/udev/v4l_id/v4l_id.c @@ -52,7 +52,7 @@ int main(int argc, char *argv[]) { return -EINVAL; default: - assert_not_reached("Unhandled option"); + assert_not_reached(); } device = argv[optind]; |