Skip to content

Commit 82b07eb

Browse files
committed
Remove a couple of strerror() calls
Change to using %m in the error message string. We need to be a bit careful here to preserve errno until we need to print it. This change avoids the use of not-thread-safe strerror() and unifies some error message strings, and maybe makes the code appear more consistent. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://www.postgresql.org/message-id/flat/daa87d79-c044-46c4-8458-8d77241ed7b0%40eisentraut.org
1 parent a68159f commit 82b07eb

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/backend/libpq/hba.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,11 @@ open_auth_file(const char *filename, int elevel, int depth,
624624
errmsg("could not open file \"%s\": %m",
625625
filename)));
626626
if (err_msg)
627-
*err_msg = psprintf("could not open file \"%s\": %s",
628-
filename, strerror(save_errno));
627+
{
628+
errno = save_errno;
629+
*err_msg = psprintf("could not open file \"%s\": %m",
630+
filename);
631+
}
629632
/* the caller may care about some specific errno */
630633
errno = save_errno;
631634
return NULL;
@@ -762,8 +765,9 @@ tokenize_auth_file(const char *filename, FILE *file, List **tok_lines,
762765
ereport(elevel,
763766
(errcode_for_file_access(),
764767
errmsg("could not read file \"%s\": %m", filename)));
765-
err_msg = psprintf("could not read file \"%s\": %s",
766-
filename, strerror(save_errno));
768+
errno = save_errno;
769+
err_msg = psprintf("could not read file \"%s\": %m",
770+
filename);
767771
break;
768772
}
769773

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy