summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2022-08-10 00:38:33 -0700
committerStan Hu <stanhu@gmail.com>2022-08-10 00:38:33 -0700
commitc71116178b63bc121a41749eea5f89d997522f19 (patch)
tree65159ab40f0e73e886cd7a8d59434fac189aab91
parent0865c115ba963167214d33541870c6a6318897fb (diff)
Improve example for SSL initialization in README.md
The previous example left `ssl_error` uninitialized. `redisCreateSSLContex` is not guaranteed to set this when no error occurs. Use the `REDIS_SSL_CTX_NONE` constant instead of 0 to be precise.
-rw-r--r--README.md6
1 files changed, 3 insertions, 3 deletions
diff --git a/README.md b/README.md
index 028c71a..b0b2aff 100644
--- a/README.md
+++ b/README.md
@@ -604,7 +604,7 @@ redisSSLContext *ssl_context;
/* An error variable to indicate what went wrong, if the context fails to
* initialize.
*/
-redisSSLContextError ssl_error;
+redisSSLContextError ssl_error = REDIS_SSL_CTX_NONE;
/* Initialize global OpenSSL state.
*
@@ -622,11 +622,11 @@ ssl_context = redisCreateSSLContext(
"redis.mydomain.com", /* Server name to request (SNI), optional */
&ssl_error);
-if(ssl_context == NULL || ssl_error != 0) {
+if(ssl_context == NULL || ssl_error != REDIS_SSL_CTX_NONE) {
/* Handle error and abort... */
/* e.g.
printf("SSL error: %s\n",
- (ssl_error != 0) ?
+ (ssl_error != REDIS_SSL_CTX_NONE) ?
redisSSLContextGetError(ssl_error) : "Unknown error");
// Abort
*/