Skip to content

Commit 88d968a

Browse files
committed
use const-correct types with strchr, strstr, etc.
Because ccan/config.h #defines _GNU_SOURCE, glibc declares qualifier- preserving generic prototypes for the twelve "qualifier-losing search functions" (bsearch, bsearch_s, memchr, strchr, strpbrk, strrchr, strstr, wcschr, wcspbrk, wcsrchr, wcsstr, wmemchr), even in -std=gnu11 mode. Several places throughout the code base were calling these search functions and inadvertently stripping away the constness of their return values, triggering compilation errors due to -Werror. Fix up these call sites so that the assignments of their return values do not implicitly discard the const qualifier. Changelog-None
1 parent 49c2f29 commit 88d968a

6 files changed

Lines changed: 8 additions & 8 deletions

File tree

common/wireaddr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,10 @@ char *fmt_wireaddr(const tal_t *ctx, const struct wireaddr *a)
292292
bool separate_address_and_port(const tal_t *ctx, const char *arg,
293293
char **addr, u16 *port)
294294
{
295-
char *portcolon;
295+
const char *portcolon;
296296

297297
if (strstarts(arg, "[")) {
298-
char *end = strchr(arg, ']');
298+
const char *end = strchr(arg, ']');
299299
if (!end)
300300
return false;
301301
/* Copy inside [] */

connectd/tor_autoservice.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ static void negotiate_auth(struct rbuf *rbuf, const char *tor_password)
200200
tor_send_cmd(rbuf, "PROTOCOLINFO 1");
201201

202202
while ((line = tor_response_line(rbuf)) != NULL) {
203-
const char *p;
203+
char *p;
204204

205205
if (!strstarts(line, "AUTH METHODS="))
206206
continue;

db/db_sqlite3.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,8 @@ static char **prepare_table_manip(const tal_t *ctx,
438438
struct db *db, const char *tablename)
439439
{
440440
sqlite3_stmt *stmt;
441-
const char *sql;
442-
char *cmd, *bracket;
441+
const char *sql, *bracket;
442+
char *cmd;
443443
char **parts;
444444
int err;
445445
struct db_sqlite3 *wrapper = (struct db_sqlite3 *)db->conn;

plugins/fetchinvoice.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ struct command_result *json_fetchinvoice(struct command *cmd,
10291029
* - `domain` set to the post-@ part of the BIP 353 HRN.
10301030
*/
10311031
if (bip353) {
1032-
char *at;
1032+
const char *at;
10331033
if (!utf8_check(bip353, strlen(bip353)))
10341034
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
10351035
"invalid UTF-8 for bip353");

plugins/spender/multifundchannel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1845,7 +1845,7 @@ param_destinations_array(struct command *cmd, const char *name,
18451845
json_for_each_arr(i, json_dest, tok) {
18461846
struct multifundchannel_destination *dest;
18471847
const char *id;
1848-
char *addrhint;
1848+
const char *addrhint;
18491849
struct amount_sat *amount, *request_amt;
18501850
bool *announce;
18511851
struct amount_msat *push_msat;

tools/check-bolt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ static void fail_mismatch(const char *filename,
236236
static bool find_strings(const char *bolttext, char **strings, size_t nstrings)
237237
{
238238
const char *p = bolttext;
239-
char *find;
239+
const char *find;
240240

241241
if (nstrings == 0)
242242
return true;

0 commit comments

Comments
 (0)