From c47bf0d9c405436d44eee5f06b6cbc78120cd089 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 14 Oct 2025 13:53:30 +1030 Subject: [PATCH] global: replace grab_file() with grab_file_str(). Signed-off-by: Rusty Russell --- ccan/aga/test/api-lazytrie.c | 2 +- ccan/ccan_tokenizer/_info | 2 +- ccan/cdump/_info | 2 +- ccan/cdump/tools/cdump-enumstr.c | 2 +- ccan/charset/_info | 2 +- ccan/crc32c/benchmark/bench.c | 2 +- ccan/crcsync/_info | 2 +- ccan/htable/tools/hsearchspeed.c | 2 +- ccan/htable/tools/stringspeed.c | 2 +- ccan/rfc822/examples/headernames.c | 2 +- ccan/rune/test/run.c | 2 +- ccan/strset/_info | 2 +- ccan/strset/tools/cbspeed.c | 2 +- ccan/strset/tools/speed.c | 2 +- ccan/tal/grab_file/_info | 2 +- ccan/tal/str/_info | 2 +- ccan/ungraph/_info | 2 +- tools/ccanlint/tests/info_compiles.c | 2 +- tools/ccanlint/tests/info_documentation_exists.c | 2 +- tools/ccanlint/tests/tests_coverage.c | 2 +- tools/ccanlint/tests/tests_pass_valgrind.c | 2 +- tools/depends.c | 4 ++-- tools/doc_extract.c | 2 +- tools/manifest.c | 4 ++-- tools/namespacize.c | 6 +++--- tools/read_config_header.c | 2 +- tools/tools.c | 2 +- 27 files changed, 31 insertions(+), 31 deletions(-) diff --git a/ccan/aga/test/api-lazytrie.c b/ccan/aga/test/api-lazytrie.c index feea4d16..421298cf 100644 --- a/ccan/aga/test/api-lazytrie.c +++ b/ccan/aga/test/api-lazytrie.c @@ -52,7 +52,7 @@ static void setup_words(void) char *wordfile; /* read in the words */ - wordfile = grab_file(NULL, "test/api-lazytrie-words.txt"); + wordfile = grab_file_str(NULL, "test/api-lazytrie-words.txt"); ok1(wordfile); wordarray = tal_strsplit(NULL, take(wordfile), "\n", STR_NO_EMPTY); ok1(wordarray); diff --git a/ccan/ccan_tokenizer/_info b/ccan/ccan_tokenizer/_info index f5116b4f..dd8c4e00 100644 --- a/ccan/ccan_tokenizer/_info +++ b/ccan/ccan_tokenizer/_info @@ -58,7 +58,7 @@ * fprintf(stderr, "Usage: %s source_file\n", argv[0]); * return 1; * } - * file = grab_file(NULL, argv[1]); + * file = grab_file_str(NULL, argv[1]); * if (!file) * err(1, "Could not read file %s", argv[1]); * diff --git a/ccan/cdump/_info b/ccan/cdump/_info index c79d013b..5c2acee7 100644 --- a/ccan/cdump/_info +++ b/ccan/cdump/_info @@ -33,7 +33,7 @@ * size_t j; * * // Read code from stdin. - * code = grab_file(NULL, NULL); + * code = grab_file_str(NULL, NULL); * * defs = cdump_extract(NULL, code, &problems); * if (!defs) diff --git a/ccan/cdump/tools/cdump-enumstr.c b/ccan/cdump/tools/cdump-enumstr.c index f0b70ecd..147f2a23 100644 --- a/ccan/cdump/tools/cdump-enumstr.c +++ b/ccan/cdump/tools/cdump-enumstr.c @@ -27,7 +27,7 @@ int main(int argc, char *argv[]) if (argc < 2) errx(1, "Usage: cdump-enumstr [...]"); - code = grab_file(NULL, streq(argv[1], "-") ? NULL : argv[1]); + code = grab_file_str(NULL, streq(argv[1], "-") ? NULL : argv[1]); if (!code) err(1, "Reading %s", argv[1]); diff --git a/ccan/charset/_info b/ccan/charset/_info index 919acda6..a966176d 100644 --- a/ccan/charset/_info +++ b/ccan/charset/_info @@ -25,7 +25,7 @@ * { * char *input; * - * input = grab_file(NULL, NULL); + * input = grab_file_str(NULL, NULL); * if (!input) * err(1, "Error reading input"); * if (!utf8_validate(input, tal_count(input)-1)) { diff --git a/ccan/crc32c/benchmark/bench.c b/ccan/crc32c/benchmark/bench.c index 54b2d97a..e584ae71 100644 --- a/ccan/crc32c/benchmark/bench.c +++ b/ccan/crc32c/benchmark/bench.c @@ -31,7 +31,7 @@ int main(int argc, char *argv[]) if (argc < 2 || (runs = atol(argv[1])) == 0) errx(1, "Usage: bench []"); - p = grab_file(NULL, argv[2]); + p = grab_file_str(NULL, argv[2]); if (!p) err(1, "Reading %s", argv[2] ? argv[2] : ""); len = tal_count(p) - 1; diff --git a/ccan/crcsync/_info b/ccan/crcsync/_info index 7516f447..92617da8 100644 --- a/ccan/crcsync/_info +++ b/ccan/crcsync/_info @@ -38,7 +38,7 @@ * errx(1, "Usage: %s ...\n" * "OR: %s ", argv[0], argv[0]); * - * file = grab_file(NULL, argv[2]); + * file = grab_file_str(NULL, argv[2]); * if (!file) * err(1, "Opening file %s", argv[2]); * len = tal_count(file) - 1; diff --git a/ccan/htable/tools/hsearchspeed.c b/ccan/htable/tools/hsearchspeed.c index 88280114..bed6f859 100644 --- a/ccan/htable/tools/hsearchspeed.c +++ b/ccan/htable/tools/hsearchspeed.c @@ -29,7 +29,7 @@ int main(int argc, char *argv[]) char **w; ENTRY *words, *misswords; - w = tal_strsplit(NULL, grab_file(NULL, + w = tal_strsplit(NULL, grab_file_str(NULL, argv[1] ? argv[1] : "/usr/share/dict/words"), "\n", STR_NO_EMPTY); num = tal_count(w) - 1; printf("%zu words\n", num); diff --git a/ccan/htable/tools/stringspeed.c b/ccan/htable/tools/stringspeed.c index 5f30359a..24eb1587 100644 --- a/ccan/htable/tools/stringspeed.c +++ b/ccan/htable/tools/stringspeed.c @@ -48,7 +48,7 @@ int main(int argc, char *argv[]) struct htable_str ht; char **words, **misswords; - words = tal_strsplit(NULL, grab_file(NULL, + words = tal_strsplit(NULL, grab_file_str(NULL, argv[1] ? argv[1] : "/usr/share/dict/words"), "\n", STR_NO_EMPTY); htable_str_init(&ht); diff --git a/ccan/rfc822/examples/headernames.c b/ccan/rfc822/examples/headernames.c index 161ceab3..7ef871ed 100644 --- a/ccan/rfc822/examples/headernames.c +++ b/ccan/rfc822/examples/headernames.c @@ -18,7 +18,7 @@ static void process_file(const char *name) struct rfc822_msg *msg; struct rfc822_header *hdr; - buf = grab_file(ctx, name, &size); + buf = grab_file_str(ctx, name, &size); msg = rfc822_start(ctx, buf, size); diff --git a/ccan/rune/test/run.c b/ccan/rune/test/run.c index d90b701c..85cb6903 100644 --- a/ccan/rune/test/run.c +++ b/ccan/rune/test/run.c @@ -39,7 +39,7 @@ int main(void) mr = rune_new(NULL, secret_zero, sizeof(secret_zero), NULL); /* Python runes library generates test vectors */ - vecs = grab_file(mr, "test/test_vectors.csv"); + vecs = grab_file_str(mr, "test/test_vectors.csv"); assert(vecs); lines = tal_strsplit(mr, take(vecs), "\n", STR_NO_EMPTY); diff --git a/ccan/strset/_info b/ccan/strset/_info index 982a9c0f..bcd261b9 100644 --- a/ccan/strset/_info +++ b/ccan/strset/_info @@ -32,7 +32,7 @@ * char *file, *word; * * strset_init(&words); - * file = grab_fd(NULL, 0); + * file = grab_fd_str(NULL, 0); * if (!file) * err(1, "Reading stdin"); * diff --git a/ccan/strset/tools/cbspeed.c b/ccan/strset/tools/cbspeed.c index 5d551b6e..88ce981a 100644 --- a/ccan/strset/tools/cbspeed.c +++ b/ccan/strset/tools/cbspeed.c @@ -395,7 +395,7 @@ int main(int argc, char *argv[]) critbit0_tree ct; char **words, **misswords; - words = tal_strsplit(NULL, grab_file(NULL, + words = tal_strsplit(NULL, grab_file_str(NULL, argv[1] ? argv[1] : "/usr/share/dict/words"), "\n", STR_NO_EMPTY); ct.root = NULL; num = tal_count(words) - 1; diff --git a/ccan/strset/tools/speed.c b/ccan/strset/tools/speed.c index 325b3a88..70a43c25 100644 --- a/ccan/strset/tools/speed.c +++ b/ccan/strset/tools/speed.c @@ -46,7 +46,7 @@ int main(int argc, char *argv[]) struct strset set; char **words, **misswords; - words = tal_strsplit(NULL, grab_file(NULL, + words = tal_strsplit(NULL, grab_file_str(NULL, argv[1] ? argv[1] : "/usr/share/dict/words"), "\n", STR_NO_EMPTY); strset_init(&set); diff --git a/ccan/tal/grab_file/_info b/ccan/tal/grab_file/_info index 0c18e6dc..9b130a5f 100644 --- a/ccan/tal/grab_file/_info +++ b/ccan/tal/grab_file/_info @@ -20,7 +20,7 @@ * * if (argc > 2) * err(1, "Takes 0 or 1 arguments"); - * file = grab_file(NULL, argv[1]); + * file = grab_file_str(NULL, argv[1]); * if (!file) * err(1, "Could not read file %s", argv[1]); * if (strlen(file)+1 != tal_count(file)) diff --git a/ccan/tal/str/_info b/ccan/tal/str/_info index 9b9c70b6..83e089e7 100644 --- a/ccan/tal/str/_info +++ b/ccan/tal/str/_info @@ -25,7 +25,7 @@ * if (argc > 2) * errx(1, "Takes 0 or 1 arguments"); * // Grab lines in file. - * textfile = grab_file(NULL, argv[1]); + * textfile = grab_file_str(NULL, argv[1]); * if (!textfile) * err(1, "Failed reading %s", argv[1]); * lines = tal_strsplit(textfile, textfile, "\n", STR_EMPTY_OK); diff --git a/ccan/ungraph/_info b/ccan/ungraph/_info index 6088c5e4..d38d3113 100644 --- a/ccan/ungraph/_info +++ b/ccan/ungraph/_info @@ -50,7 +50,7 @@ * * int main(int argc, char *argv[]) * { - * const char *graph = grab_file(NULL, argv[1], NULL), *errmsg; + * const char *graph = grab_file_str(NULL, argv[1], NULL), *errmsg; * printf("digraph %s {\n", argv[1] ? argv[1] : "stdin"); * errmsg = ungraph(NULL, graph, add_node, add_edge, NULL); * if (errmsg) diff --git a/tools/ccanlint/tests/info_compiles.c b/tools/ccanlint/tests/info_compiles.c index e1485963..f839c856 100644 --- a/tools/ccanlint/tests/info_compiles.c +++ b/tools/ccanlint/tests/info_compiles.c @@ -31,7 +31,7 @@ static void check_info_compiles(struct manifest *m, } /* Copy it to a file with proper .c suffix. */ - info = grab_file(score, m->info_file->fullname); + info = grab_file_str(score, m->info_file->fullname); if (!info) { score_file_error(score, m->info_file, 0, "could not be read: %s", strerror(errno)); diff --git a/tools/ccanlint/tests/info_documentation_exists.c b/tools/ccanlint/tests/info_documentation_exists.c index c3f02226..9b1cb549 100644 --- a/tools/ccanlint/tests/info_documentation_exists.c +++ b/tools/ccanlint/tests/info_documentation_exists.c @@ -52,7 +52,7 @@ static void create_info_template_doc(struct manifest *m, err(1, "Writing to _info.new to insert documentation"); } - oldcontents = grab_file(m, m->info_file->fullname); + oldcontents = grab_file_str(m, m->info_file->fullname); if (!oldcontents) { unlink_noerr("_info.new"); err(1, "Reading %s", m->info_file->fullname); diff --git a/tools/ccanlint/tests/tests_coverage.c b/tools/ccanlint/tests/tests_coverage.c index e2957201..401b4bf4 100644 --- a/tools/ccanlint/tests/tests_coverage.c +++ b/tools/ccanlint/tests/tests_coverage.c @@ -100,7 +100,7 @@ static void analyze_coverage(struct manifest *m, bool full_gcov, apostrophe = strchr(filename, '\''); *apostrophe = '\0'; if (lines_matter) { - file = grab_file(score, filename); + file = grab_file_str(score, filename); if (!file) { score->error = tal_fmt(score, "Reading %s", diff --git a/tools/ccanlint/tests/tests_pass_valgrind.c b/tools/ccanlint/tests/tests_pass_valgrind.c index 90e42349..2fbcc087 100644 --- a/tools/ccanlint/tests/tests_pass_valgrind.c +++ b/tools/ccanlint/tests/tests_pass_valgrind.c @@ -181,7 +181,7 @@ static void do_run_tests_vg(struct manifest *m, continue; } - output = grab_file(i, i->valgrind_log); + output = grab_file_str(i, i->valgrind_log); /* No valgrind errors? */ if (!output || output[0] == '\0') { err = NULL; diff --git a/tools/depends.c b/tools/depends.c index e8e0f138..63f50124 100644 --- a/tools/depends.c +++ b/tools/depends.c @@ -49,7 +49,7 @@ char *compile_info(const void *ctx, const char *dir) int fd; /* Copy it to a file with proper .c suffix. */ - info = grab_file(ctx, tal_fmt(ctx, "%s/_info", dir)); + info = grab_file_str(ctx, tal_fmt(ctx, "%s/_info", dir)); if (!info) return NULL; @@ -131,7 +131,7 @@ static char **get_one_safe_deps(const void *ctx, bool correct_style = false; fname = path_join(ctx, dir, "_info"); - raw = grab_file(fname, fname); + raw = grab_file_str(fname, fname); if (!raw) errx(1, "Could not open %s", fname); diff --git a/tools/doc_extract.c b/tools/doc_extract.c index 99c3202c..95bf9fe3 100644 --- a/tools/doc_extract.c +++ b/tools/doc_extract.c @@ -46,7 +46,7 @@ int main(int argc, char *argv[]) struct list_head *list; struct doc_section *d; - file = grab_file(NULL, argv[i]); + file = grab_file_str(NULL, argv[i]); if (!file) err(1, "Reading file %s", argv[i]); lines = tal_strsplit(file, file, "\n", STR_EMPTY_OK); diff --git a/tools/manifest.c b/tools/manifest.c index fcc2f15b..5a9791e4 100644 --- a/tools/manifest.c +++ b/tools/manifest.c @@ -44,10 +44,10 @@ static struct htable_manifest *manifests; const char *get_ccan_file_contents(struct ccan_file *f) { if (!f->contents) { - f->contents = grab_file(f, f->fullname); + f->contents = grab_file_str(f, f->fullname); if (!f->contents) err(1, "Reading file %s", f->fullname); - f->contents_size = tal_count(f->contents) - 1; + f->contents_size = tal_count(f->contents); } return f->contents; } diff --git a/tools/namespacize.c b/tools/namespacize.c index ae20e3d6..c3c56757 100644 --- a/tools/namespacize.c +++ b/tools/namespacize.c @@ -252,7 +252,7 @@ static void analyze_headers(const char *dir, struct replace **repl) hdr = tal_fmt(dir, "%s.h", path_join(NULL, dir, take(path_basename(NULL, dir)))); - contents = grab_file(dir, hdr); + contents = grab_file_str(dir, hdr); if (!contents) err(1, "Reading %s", hdr); @@ -327,7 +327,7 @@ static const char *rewrite_file(const char *filename, int fd; verbose("Rewriting %s\n", filename); - file = grab_file(filename, filename); + file = grab_file_str(filename, filename); if (!file) err(1, "Reading file %s", filename); @@ -424,7 +424,7 @@ static struct replace *read_replacement_file(const char *depdir) char *replname = path_join(depdir, depdir, ".namespacize"); char *file, **line; - file = grab_file(replname, replname); + file = grab_file_str(replname, replname); if (!file) { if (errno != ENOENT) err(1, "Opening %s", replname); diff --git a/tools/read_config_header.c b/tools/read_config_header.c index da3e00cd..ff2af3b3 100644 --- a/tools/read_config_header.c +++ b/tools/read_config_header.c @@ -95,7 +95,7 @@ char *read_config_header(const char *ccan_dir, bool verbose) unsigned int i; char *config_header; - config_header = grab_file(NULL, fname); + config_header = grab_file_str(NULL, fname); if (!config_header) { tal_free(fname); diff --git a/tools/tools.c b/tools/tools.c index 6a96c943..bb1f80d5 100644 --- a/tools/tools.c +++ b/tools/tools.c @@ -233,7 +233,7 @@ bool move_file(const char *oldname, const char *newname) } /* Try copy and delete: not atomic! */ - contents = grab_file(NULL, oldname); + contents = grab_file_str(NULL, oldname); if (!contents) { if (tools_verbose) printf("read failed: %s\n", strerror(errno)); -- 2.47.3