unicode: pass a UNICODE_AGE() tripple to utf8_load

Don't bother with pointless string parsing when the caller can just pass
the version in the format that the core expects.  Also remove the
fallback to the latest version that none of the callers actually uses.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
This commit is contained in:
Christoph Hellwig
2021-09-15 09:00:00 +02:00
committed by Gabriel Krisman Bertazi
parent f3a9c82396
commit 49bd03cc7e
7 changed files with 65 additions and 86 deletions

View File

@@ -235,7 +235,7 @@ static void check_utf8_nfdicf(void)
static void check_utf8_comparisons(void)
{
int i;
struct unicode_map *table = utf8_load("12.1.0");
struct unicode_map *table = utf8_load(UNICODE_AGE(12, 1, 0));
if (IS_ERR(table)) {
pr_err("%s: Unable to load utf8 %d.%d.%d. Skipping.\n",
@@ -269,18 +269,19 @@ static void check_utf8_comparisons(void)
static void check_supported_versions(void)
{
/* Unicode 7.0.0 should be supported. */
test(utf8version_is_supported(7, 0, 0));
test(utf8version_is_supported(UNICODE_AGE(7, 0, 0)));
/* Unicode 9.0.0 should be supported. */
test(utf8version_is_supported(9, 0, 0));
test(utf8version_is_supported(UNICODE_AGE(9, 0, 0)));
/* Unicode 1x.0.0 (the latest version) should be supported. */
test(utf8version_is_supported(latest_maj, latest_min, latest_rev));
test(utf8version_is_supported(
UNICODE_AGE(latest_maj, latest_min, latest_rev)));
/* Next versions don't exist. */
test(!utf8version_is_supported(13, 0, 0));
test(!utf8version_is_supported(0, 0, 0));
test(!utf8version_is_supported(-1, -1, -1));
test(!utf8version_is_supported(UNICODE_AGE(13, 0, 0)));
test(!utf8version_is_supported(UNICODE_AGE(0, 0, 0)));
test(!utf8version_is_supported(UNICODE_AGE(-1, -1, -1)));
}
static int __init init_test_ucd(void)