Skip to content

Commit d16788e

Browse files
authored
Fix discarded-qualifiers warnings reported by fedorarawhide (#2874)
fedorarawhide CI reports these warnings: ``` networking.c: In function 'afterErrorReply': networking.c:821:30: error: initialization discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers] 821 | char *spaceloc = memchr(s, ' ', len < 32 ? len : 32); ``` Signed-off-by: Binbin <[email protected]>
1 parent faac14a commit d16788e

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

src/cli_common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ void parseUri(const char *uri, const char *tool_name, cliConnInfo *connInfo, int
331331
!strncasecmp(redisTlsscheme, curr, strlen(redisTlsscheme))) {
332332
#ifdef USE_OPENSSL
333333
*tls_flag = 1;
334-
char *del = strstr(curr, "://");
334+
const char *del = strstr(curr, "://");
335335
curr += (del - curr) + 3;
336336
#else
337337
char *copy = strdup(curr);
@@ -341,7 +341,7 @@ void parseUri(const char *uri, const char *tool_name, cliConnInfo *connInfo, int
341341
exit(1);
342342
#endif
343343
} else if (!strncasecmp(scheme, curr, strlen(scheme)) || !strncasecmp(redisScheme, curr, strlen(redisScheme))) {
344-
char *del = strstr(curr, "://");
344+
const char *del = strstr(curr, "://");
345345
curr += (del - curr) + 3;
346346
} else {
347347
fprintf(stderr, "Invalid URI scheme\n");

src/module.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6833,7 +6833,7 @@ uint64_t moduleTypeEncodeId(const char *name, int encver) {
68336833

68346834
uint64_t id = 0;
68356835
for (int j = 0; j < 9; j++) {
6836-
char *p = strchr(cset, name[j]);
6836+
const char *p = strchr(cset, name[j]);
68376837
if (!p) return 0;
68386838
unsigned long pos = p - cset;
68396839
id = (id << 6) | pos;

src/networking.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ void afterErrorReply(client *c, const char *s, size_t len, int flags) {
818818
char *err_prefix = "ERR";
819819
size_t prefix_len = 3;
820820
if (s[0] == '-') {
821-
char *spaceloc = memchr(s, ' ', len < 32 ? len : 32);
821+
const char *spaceloc = memchr(s, ' ', len < 32 ? len : 32);
822822
/* If we cannot retrieve the error prefix, use the default: "ERR". */
823823
if (spaceloc) {
824824
const size_t errEndPos = (size_t)(spaceloc - s);

src/resp_parser.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262

6363
static int parseBulk(ReplyParser *parser, void *p_ctx) {
6464
const char *proto = parser->curr_location;
65-
char *p = strchr(proto + 1, '\r');
65+
const char *p = strchr(proto + 1, '\r');
6666
long long bulklen;
6767
parser->curr_location = p + 2; /* for \r\n */
6868

@@ -81,23 +81,23 @@ static int parseBulk(ReplyParser *parser, void *p_ctx) {
8181

8282
static int parseSimpleString(ReplyParser *parser, void *p_ctx) {
8383
const char *proto = parser->curr_location;
84-
char *p = strchr(proto + 1, '\r');
84+
const char *p = strchr(proto + 1, '\r');
8585
parser->curr_location = p + 2; /* for \r\n */
8686
parser->callbacks.simple_str_callback(p_ctx, proto + 1, p - proto - 1, proto, parser->curr_location - proto);
8787
return C_OK;
8888
}
8989

9090
static int parseError(ReplyParser *parser, void *p_ctx) {
9191
const char *proto = parser->curr_location;
92-
char *p = strchr(proto + 1, '\r');
92+
const char *p = strchr(proto + 1, '\r');
9393
parser->curr_location = p + 2; // for \r\n
9494
parser->callbacks.error_callback(p_ctx, proto + 1, p - proto - 1, proto, parser->curr_location - proto);
9595
return C_OK;
9696
}
9797

9898
static int parseLong(ReplyParser *parser, void *p_ctx) {
9999
const char *proto = parser->curr_location;
100-
char *p = strchr(proto + 1, '\r');
100+
const char *p = strchr(proto + 1, '\r');
101101
parser->curr_location = p + 2; /* for \r\n */
102102
long long val;
103103
string2ll(proto + 1, p - proto - 1, &val);
@@ -107,7 +107,7 @@ static int parseLong(ReplyParser *parser, void *p_ctx) {
107107

108108
static int parseAttributes(ReplyParser *parser, void *p_ctx) {
109109
const char *proto = parser->curr_location;
110-
char *p = strchr(proto + 1, '\r');
110+
const char *p = strchr(proto + 1, '\r');
111111
long long len;
112112
string2ll(proto + 1, p - proto - 1, &len);
113113
p += 2;
@@ -118,7 +118,7 @@ static int parseAttributes(ReplyParser *parser, void *p_ctx) {
118118

119119
static int parseVerbatimString(ReplyParser *parser, void *p_ctx) {
120120
const char *proto = parser->curr_location;
121-
char *p = strchr(proto + 1, '\r');
121+
const char *p = strchr(proto + 1, '\r');
122122
long long bulklen;
123123
parser->curr_location = p + 2; /* for \r\n */
124124
string2ll(proto + 1, p - proto - 1, &bulklen);
@@ -132,23 +132,23 @@ static int parseVerbatimString(ReplyParser *parser, void *p_ctx) {
132132

133133
static int parseBigNumber(ReplyParser *parser, void *p_ctx) {
134134
const char *proto = parser->curr_location;
135-
char *p = strchr(proto + 1, '\r');
135+
const char *p = strchr(proto + 1, '\r');
136136
parser->curr_location = p + 2; /* for \r\n */
137137
parser->callbacks.big_number_callback(p_ctx, proto + 1, p - proto - 1, proto, parser->curr_location - proto);
138138
return C_OK;
139139
}
140140

141141
static int parseNull(ReplyParser *parser, void *p_ctx) {
142142
const char *proto = parser->curr_location;
143-
char *p = strchr(proto + 1, '\r');
143+
const char *p = strchr(proto + 1, '\r');
144144
parser->curr_location = p + 2; /* for \r\n */
145145
parser->callbacks.null_callback(p_ctx, proto, parser->curr_location - proto);
146146
return C_OK;
147147
}
148148

149149
static int parseDouble(ReplyParser *parser, void *p_ctx) {
150150
const char *proto = parser->curr_location;
151-
char *p = strchr(proto + 1, '\r');
151+
const char *p = strchr(proto + 1, '\r');
152152
parser->curr_location = p + 2; /* for \r\n */
153153
char buf[MAX_LONG_DOUBLE_CHARS + 1];
154154
size_t len = p - proto - 1;
@@ -164,15 +164,15 @@ static int parseDouble(ReplyParser *parser, void *p_ctx) {
164164

165165
static int parseBool(ReplyParser *parser, void *p_ctx) {
166166
const char *proto = parser->curr_location;
167-
char *p = strchr(proto + 1, '\r');
167+
const char *p = strchr(proto + 1, '\r');
168168
parser->curr_location = p + 2; /* for \r\n */
169169
parser->callbacks.bool_callback(p_ctx, proto[1] == 't', proto, parser->curr_location - proto);
170170
return C_OK;
171171
}
172172

173173
static int parseArray(ReplyParser *parser, void *p_ctx) {
174174
const char *proto = parser->curr_location;
175-
char *p = strchr(proto + 1, '\r');
175+
const char *p = strchr(proto + 1, '\r');
176176
long long len;
177177
string2ll(proto + 1, p - proto - 1, &len);
178178
p += 2;
@@ -187,7 +187,7 @@ static int parseArray(ReplyParser *parser, void *p_ctx) {
187187

188188
static int parseSet(ReplyParser *parser, void *p_ctx) {
189189
const char *proto = parser->curr_location;
190-
char *p = strchr(proto + 1, '\r');
190+
const char *p = strchr(proto + 1, '\r');
191191
long long len;
192192
string2ll(proto + 1, p - proto - 1, &len);
193193
p += 2;
@@ -198,7 +198,7 @@ static int parseSet(ReplyParser *parser, void *p_ctx) {
198198

199199
static int parseMap(ReplyParser *parser, void *p_ctx) {
200200
const char *proto = parser->curr_location;
201-
char *p = strchr(proto + 1, '\r');
201+
const char *p = strchr(proto + 1, '\r');
202202
long long len;
203203
string2ll(proto + 1, p - proto - 1, &len);
204204
p += 2;

0 commit comments

Comments
 (0)