]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix unreachable code warning from commit 2d819a08a1.
authorJeff Davis <jdavis@postgresql.org>
Mon, 18 Mar 2024 16:15:47 +0000 (09:15 -0700)
committerJeff Davis <jdavis@postgresql.org>
Mon, 18 Mar 2024 16:15:47 +0000 (09:15 -0700)
Found by Coverity.

Discussion: https://postgr.es/m/3422201.1710711993@sss.pgh.pa.us
Reported-by: Tom Lane
src/backend/utils/adt/pg_locale.c

index 39390fbe4eb23a525a0103dcac4413949c1dce98..364716bcec8692db16908f1987c971d58ec7c962 100644 (file)
@@ -2501,28 +2501,23 @@ pg_strnxfrm_prefix(char *dest, size_t destsize, const char *src,
        return result;
 }
 
+/*
+ * Validate the locale and encoding combination, and return the canonical form
+ * of the locale name.
+ *
+ * The only supported locale for the builtin provider is "C", and it's
+ * available for any encoding.
+ */
 const char *
 builtin_validate_locale(int encoding, const char *locale)
 {
-       const char *canonical_name = NULL;
-       int                     required_encoding = -1;
-
-       if (strcmp(locale, "C") == 0)
-               canonical_name = "C";
-
-       if (!canonical_name)
+       if (strcmp(locale, "C") != 0)
                ereport(ERROR,
                                (errcode(ERRCODE_WRONG_OBJECT_TYPE),
                                 errmsg("invalid locale name \"%s\" for builtin provider",
                                                locale)));
 
-       if (required_encoding >= 0 && encoding != required_encoding)
-               ereport(ERROR,
-                               (errcode(ERRCODE_WRONG_OBJECT_TYPE),
-                                errmsg("encoding \"%s\" does not match locale \"%s\"",
-                                               pg_encoding_to_char(encoding), locale)));
-
-       return canonical_name;
+       return "C";
 }