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/import | |
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/import')
-rw-r--r-- | src/import/export.c | 2 | ||||
-rw-r--r-- | src/import/import-compress.c | 2 | ||||
-rw-r--r-- | src/import/import-fs.c | 2 | ||||
-rw-r--r-- | src/import/import.c | 2 | ||||
-rw-r--r-- | src/import/importd.c | 2 | ||||
-rw-r--r-- | src/import/pull-job.c | 2 | ||||
-rw-r--r-- | src/import/pull-raw.c | 2 | ||||
-rw-r--r-- | src/import/pull-tar.c | 2 | ||||
-rw-r--r-- | src/import/pull.c | 2 |
9 files changed, 9 insertions, 9 deletions
diff --git a/src/import/export.c b/src/import/export.c index a4f3f6c38e..26533baeb8 100644 --- a/src/import/export.c +++ b/src/import/export.c @@ -261,7 +261,7 @@ static int parse_argv(int argc, char *argv[]) { return -EINVAL; default: - assert_not_reached("Unhandled option"); + assert_not_reached(); } return 1; diff --git a/src/import/import-compress.c b/src/import/import-compress.c index aa837af565..03f5efa00e 100644 --- a/src/import/import-compress.c +++ b/src/import/import-compress.c @@ -190,7 +190,7 @@ int import_uncompress(ImportCompress *c, const void *data, size_t size, ImportCo #endif default: - assert_not_reached("Unknown compression"); + assert_not_reached(); } return 1; diff --git a/src/import/import-fs.c b/src/import/import-fs.c index e8c3740879..88bfe29970 100644 --- a/src/import/import-fs.c +++ b/src/import/import-fs.c @@ -290,7 +290,7 @@ static int parse_argv(int argc, char *argv[]) { return -EINVAL; default: - assert_not_reached("Unhandled option"); + assert_not_reached(); } return 1; diff --git a/src/import/import.c b/src/import/import.c index fe4c03a4da..cc90732d71 100644 --- a/src/import/import.c +++ b/src/import/import.c @@ -278,7 +278,7 @@ static int parse_argv(int argc, char *argv[]) { return -EINVAL; default: - assert_not_reached("Unhandled option"); + assert_not_reached(); } return 1; diff --git a/src/import/importd.c b/src/import/importd.c index f0f61ca784..0a87056819 100644 --- a/src/import/importd.c +++ b/src/import/importd.c @@ -431,7 +431,7 @@ static int transfer_start(Transfer *t) { break; default: - assert_not_reached("Unexpected transfer type"); + assert_not_reached(); } switch (t->type) { diff --git a/src/import/pull-job.c b/src/import/pull-job.c index 038fa2be8b..e751d3af05 100644 --- a/src/import/pull-job.c +++ b/src/import/pull-job.c @@ -421,7 +421,7 @@ static size_t pull_job_write_callback(void *contents, size_t size, size_t nmemb, goto fail; default: - assert_not_reached("Impossible state."); + assert_not_reached(); } return sz; diff --git a/src/import/pull-raw.c b/src/import/pull-raw.c index 9b5d8ef9e3..ca4f250210 100644 --- a/src/import/pull-raw.c +++ b/src/import/pull-raw.c @@ -222,7 +222,7 @@ static void raw_pull_report_progress(RawPull *i, RawProgress p) { break; default: - assert_not_reached("Unknown progress state"); + assert_not_reached(); } sd_notifyf(false, "X_IMPORT_PROGRESS=%u", percent); diff --git a/src/import/pull-tar.c b/src/import/pull-tar.c index a2ba56df2f..1227c89ffb 100644 --- a/src/import/pull-tar.c +++ b/src/import/pull-tar.c @@ -187,7 +187,7 @@ static void tar_pull_report_progress(TarPull *i, TarProgress p) { break; default: - assert_not_reached("Unknown progress state"); + assert_not_reached(); } sd_notifyf(false, "X_IMPORT_PROGRESS=%u", percent); diff --git a/src/import/pull.c b/src/import/pull.c index d24c71b00e..17ade56c2a 100644 --- a/src/import/pull.c +++ b/src/import/pull.c @@ -321,7 +321,7 @@ static int parse_argv(int argc, char *argv[]) { return -EINVAL; default: - assert_not_reached("Unhandled option"); + assert_not_reached(); } return 1; |