Skip to content

Commit 36ea345

Browse files
committed
Improve/correct comments
Change comments for pg_cryptohash_init(), pg_cryptohash_update(), pg_cryptohash_final() in cryptohash.c to match cryptohash_openssl.c. In particular, the claim that these functions were "designed" to never fail was incorrect, since by design callers need to be prepared to handle failures, for compatibility with the cryptohash_openssl.c versions. Reviewed-by: Daniel Gustafsson <daniel@yesql.se> Discussion: https://www.postgresql.org/message-id/301F4EDD-27B9-460F-B462-B9DB2BDE4ACF@yesql.se
1 parent 544b452 commit 36ea345

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/common/cryptohash.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ pg_cryptohash_create(pg_cryptohash_type type)
9494
/*
9595
* pg_cryptohash_init
9696
*
97-
* Initialize a hash context. Note that this implementation is designed
98-
* to never fail, so this always returns 0.
97+
* Initialize a hash context. Returns 0 on success, and -1 on failure.
9998
*/
10099
int
101100
pg_cryptohash_init(pg_cryptohash_ctx *ctx)
@@ -131,9 +130,7 @@ pg_cryptohash_init(pg_cryptohash_ctx *ctx)
131130
/*
132131
* pg_cryptohash_update
133132
*
134-
* Update a hash context. Note that this implementation is designed
135-
* to never fail, so this always returns 0 except if the caller has
136-
* given a NULL context.
133+
* Update a hash context. Returns 0 on success, and -1 on failure.
137134
*/
138135
int
139136
pg_cryptohash_update(pg_cryptohash_ctx *ctx, const uint8 *data, size_t len)
@@ -169,9 +166,7 @@ pg_cryptohash_update(pg_cryptohash_ctx *ctx, const uint8 *data, size_t len)
169166
/*
170167
* pg_cryptohash_final
171168
*
172-
* Finalize a hash context. Note that this implementation is designed to
173-
* never fail, so this always returns 0 except if the destination buffer
174-
* is not large enough.
169+
* Finalize a hash context. Returns 0 on success, and -1 on failure.
175170
*/
176171
int
177172
pg_cryptohash_final(pg_cryptohash_ctx *ctx, uint8 *dest, size_t len)

0 commit comments

Comments
 (0)