summaryrefslogtreecommitdiff
path: root/src/backend/libpq/hba.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2022-08-17 11:12:35 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2022-08-17 11:12:35 -0400
commitefd0c16becbf45e3b0215e124fde75fee8fcbce4 (patch)
tree4583c8e845ce18ae4a6c6b4c008a4989c514b3cb /src/backend/libpq/hba.c
parent4a319fce7671ffbe2a730f79529b7a2ef3794d41 (diff)
Avoid using list_length() to test for empty list.
The standard way to check for list emptiness is to compare the List pointer to NIL; our list code goes out of its way to ensure that that is the only representation of an empty list. (An acceptable alternative is a plain boolean test for non-null pointer, but explicit mention of NIL is usually preferable.) Various places didn't get that memo and expressed the condition with list_length(), which might not be so bad except that there were such a variety of ways to check it exactly: equal to zero, less than or equal to zero, less than one, yadda yadda. In the name of code readability, let's standardize all those spellings as "list == NIL" or "list != NIL". (There's probably some microscopic efficiency gain too, though few of these look to be at all performance-critical.) A very small number of cases were left as-is because they seemed more consistent with other adjacent list_length tests that way. Peter Smith, with bikeshedding from a number of us Discussion: https://postgr.es/m/CAHut+PtQYe+ENX5KrONMfugf0q6NHg4hR5dAhqEXEc2eefFeig@mail.gmail.com
Diffstat (limited to 'src/backend/libpq/hba.c')
-rw-r--r--src/backend/libpq/hba.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c
index 857b9e5eb24..1447588c4ae 100644
--- a/src/backend/libpq/hba.c
+++ b/src/backend/libpq/hba.c
@@ -1564,7 +1564,7 @@ parse_hba_line(TokenizedAuthLine *tok_line, int elevel)
MANDATORY_AUTH_ARG(parsedline->radiusservers, "radiusservers", "radius");
MANDATORY_AUTH_ARG(parsedline->radiussecrets, "radiussecrets", "radius");
- if (list_length(parsedline->radiusservers) < 1)
+ if (parsedline->radiusservers == NIL)
{
ereport(elevel,
(errcode(ERRCODE_CONFIG_FILE_ERROR),
@@ -1575,7 +1575,7 @@ parse_hba_line(TokenizedAuthLine *tok_line, int elevel)
return NULL;
}
- if (list_length(parsedline->radiussecrets) < 1)
+ if (parsedline->radiussecrets == NIL)
{
ereport(elevel,
(errcode(ERRCODE_CONFIG_FILE_ERROR),