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.
This commit is contained in:
+6
-6
@@ -505,7 +505,7 @@ static void json_variant_set(JsonVariant *a, JsonVariant *b) {
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unexpected variant type");
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -763,7 +763,7 @@ static size_t json_variant_size(JsonVariant* v) {
|
||||
return offsetof(JsonVariant, value);
|
||||
|
||||
default:
|
||||
assert_not_reached("unexpected type");
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1397,7 +1397,7 @@ bool json_variant_equal(JsonVariant *a, JsonVariant *b) {
|
||||
}
|
||||
|
||||
default:
|
||||
assert_not_reached("Unknown variant type.");
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1749,7 +1749,7 @@ static int json_format(FILE *f, JsonVariant *v, JsonFormatFlags flags, const cha
|
||||
}
|
||||
|
||||
default:
|
||||
assert_not_reached("Unexpected variant type.");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -2787,7 +2787,7 @@ int json_tokenize(
|
||||
return -EINVAL;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unexpected tokenizer state");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
null_return:
|
||||
@@ -3156,7 +3156,7 @@ static int json_parse_internal(
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unexpected token");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
if (add) {
|
||||
|
||||
Reference in New Issue
Block a user