summaryrefslogtreecommitdiff
path: root/src/debug.c
diff options
context:
space:
mode:
authorWang Yuan <wangyuan21@baidu.com>2022-01-18 21:55:20 +0800
committerGitHub <noreply@github.com>2022-01-18 15:55:20 +0200
commitd697daa7a5600ca82a0098bc7c857bc7167bb35e (patch)
tree303549e26aa773c5fd5544c6d3a9948711b77d9d /src/debug.c
parent99ab4236afb210dc118fad892210b9fbb369aa8e (diff)
downloadredis-d697daa7a5600ca82a0098bc7c857bc7167bb35e.tar.gz
Use const char pointer in redismodule.h as far as possible (#10064)
When I used C++ to develop a redis module. i used `string.data()` as the second parameter `ele` of `RedisModule_DigestAddStringBuffer`, but there is a warning, since we never change the `ele`, i think we should use `const char` for it. This PR adds const to just a handful of module APIs that required it, all not very widely used. The implication is a breaking change in terms of compilation error that's easy to resolve, and no ABI impact. The affected APIs are around Digest, Info injection, and Cluster bus messages.
Diffstat (limited to 'src/debug.c')
-rw-r--r--src/debug.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/debug.c b/src/debug.c
index c8a6fc186..2da2c5d50 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -79,13 +79,13 @@ void logStackTrace(void *eip, int uplevel);
* "add" digests relative to unordered elements.
*
* So digest(a,b,c,d) will be the same of digest(b,a,c,d) */
-void xorDigest(unsigned char *digest, void *ptr, size_t len) {
+void xorDigest(unsigned char *digest, const void *ptr, size_t len) {
SHA1_CTX ctx;
- unsigned char hash[20], *s = ptr;
+ unsigned char hash[20];
int j;
SHA1Init(&ctx);
- SHA1Update(&ctx,s,len);
+ SHA1Update(&ctx,ptr,len);
SHA1Final(hash,&ctx);
for (j = 0; j < 20; j++)
@@ -112,11 +112,10 @@ void xorStringObjectDigest(unsigned char *digest, robj *o) {
* Also note that mixdigest("foo") followed by mixdigest("bar")
* will lead to a different digest compared to "fo", "obar".
*/
-void mixDigest(unsigned char *digest, void *ptr, size_t len) {
+void mixDigest(unsigned char *digest, const void *ptr, size_t len) {
SHA1_CTX ctx;
- char *s = ptr;
- xorDigest(digest,s,len);
+ xorDigest(digest,ptr,len);
SHA1Init(&ctx);
SHA1Update(&ctx,digest,20);
SHA1Final(digest,&ctx);