Skip to content

Commit 6e5bcf8

Browse files
committed
Fix glibc-2.43 constness warnings
Glibc 2.43 added C23 const-preserving overloads to various string functions, which change the return type depending on the constness of the argument(s). Currently this leads to warnings from calls to strtok() or strchr(). Fix this by properly declaring the respective variable types. Signed-off-by: Holger Hoffstätte <holger@applied-asynchrony.com>
1 parent b905ab2 commit 6e5bcf8

6 files changed

Lines changed: 7 additions & 7 deletions

File tree

access.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static void make_mask(char *mask, int plen, int addrlen)
9999
return;
100100
}
101101

102-
static int match_address(const char *addr, const char *tok)
102+
static int match_address(const char *addr, char *tok)
103103
{
104104
char *p;
105105
struct addrinfo hints, *resa, *rest;

checksum.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ void parse_checksum_choice(int final_call)
176176
if (valid_checksums.negotiated_nni)
177177
xfer_sum_nni = file_sum_nni = valid_checksums.negotiated_nni;
178178
else {
179-
char *cp = checksum_choice ? strchr(checksum_choice, ',') : NULL;
179+
const char *cp = checksum_choice ? strchr(checksum_choice, ',') : NULL;
180180
if (cp) {
181181
xfer_sum_nni = parse_csum_name(checksum_choice, cp - checksum_choice);
182182
file_sum_nni = parse_csum_name(cp+1, -1);

compat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static const char *client_info;
132132
* of that protocol for it to be advertised as available. */
133133
static void check_sub_protocol(void)
134134
{
135-
char *dot;
135+
const char *dot;
136136
int their_protocol, their_sub;
137137
int our_sub = get_subprotocol_version();
138138

@@ -415,7 +415,7 @@ static const char *getenv_nstr(int ntype)
415415
env_str = ntype == NSTR_COMPRESS ? "zlib" : protocol_version >= 30 ? "md5" : "md4";
416416

417417
if (am_server && env_str) {
418-
char *cp = strchr(env_str, '&');
418+
const char *cp = strchr(env_str, '&');
419419
if (cp)
420420
env_str = cp + 1;
421421
}

exclude.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ static int rule_matches(const char *fname, filter_rule *ex, int name_flags)
904904
{
905905
int slash_handling, str_cnt = 0, anchored_match = 0;
906906
int ret_match = ex->rflags & FILTRULE_NEGATE ? 0 : 1;
907-
char *p, *pattern = ex->pattern;
907+
const char *p, *pattern = ex->pattern;
908908
const char *strings[16]; /* more than enough */
909909
const char *name = fname + (*fname == '/');
910910

io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,7 @@ void set_io_timeout(int secs)
11591159
static void check_for_d_option_error(const char *msg)
11601160
{
11611161
static const char rsync263_opts[] = "BCDHIKLPRSTWabceghlnopqrtuvxz";
1162-
char *colon;
1162+
const char *colon;
11631163
int saw_d = 0;
11641164

11651165
if (*msg != 'r'

loadparm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static char *expand_vars(const char *str)
178178

179179
for (t = buf, f = str; bufsize && *f; ) {
180180
if (*f == '%' && isUpper(f+1)) {
181-
char *percent = strchr(f+1, '%');
181+
const char *percent = strchr(f+1, '%');
182182
if (percent && percent - f < bufsize) {
183183
char *val;
184184
strlcpy(t, f+1, percent - f);

0 commit comments

Comments
 (0)