Skip to content

Commit 65c756f

Browse files
peffgitster
authored andcommitted
fast-export: drop data parameter from anonymous generators
The anonymization code has a specific generator callback for each type of data (e.g., one for paths, one for oids, and so on). These all take a "data" parameter, but none of them use it for anything. Which is not surprising, as the point is to generate a new name independent of any input, and each function keeps its own static counter. We added the extra pointer in d5bf91f (fast-export: add a "data" callback parameter to anonymize_str(), 2020-06-23) to handle --anonymize-map parsing, but that turned out to be awkward itself, and was recently dropped. So let's get rid of this "data" parameter that nobody is using, both from the generators and from anonymize_str() which plumbed it through. This simplifies the code, and makes -Wunused-parameter happier. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent aa54845 commit 65c756f

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

builtin/fast-export.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,8 @@ static struct anonymized_entry *add_anonymized_entry(struct hashmap *map,
168168
* is farmed out to the generate function.
169169
*/
170170
static const char *anonymize_str(struct hashmap *map,
171-
char *(*generate)(void *),
172-
const char *orig, size_t len,
173-
void *data)
171+
char *(*generate)(void),
172+
const char *orig, size_t len)
174173
{
175174
struct anonymized_entry_key key;
176175
struct anonymized_entry *ret;
@@ -189,7 +188,7 @@ static const char *anonymize_str(struct hashmap *map,
189188
/* ...and finally generate a new mapping if necessary */
190189
if (!ret)
191190
ret = add_anonymized_entry(map, key.hash.hash,
192-
orig, len, generate(data));
191+
orig, len, generate());
193192

194193
return ret->anon;
195194
}
@@ -202,12 +201,12 @@ static const char *anonymize_str(struct hashmap *map,
202201
*/
203202
static void anonymize_path(struct strbuf *out, const char *path,
204203
struct hashmap *map,
205-
char *(*generate)(void *))
204+
char *(*generate)(void))
206205
{
207206
while (*path) {
208207
const char *end_of_component = strchrnul(path, '/');
209208
size_t len = end_of_component - path;
210-
const char *c = anonymize_str(map, generate, path, len, NULL);
209+
const char *c = anonymize_str(map, generate, path, len);
211210
strbuf_addstr(out, c);
212211
path = end_of_component;
213212
if (*path)
@@ -382,7 +381,7 @@ static void print_path_1(const char *path)
382381
printf("%s", path);
383382
}
384383

385-
static char *anonymize_path_component(void *data)
384+
static char *anonymize_path_component(void)
386385
{
387386
static int counter;
388387
struct strbuf out = STRBUF_INIT;
@@ -404,7 +403,7 @@ static void print_path(const char *path)
404403
}
405404
}
406405

407-
static char *generate_fake_oid(void *data)
406+
static char *generate_fake_oid(void)
408407
{
409408
static uint32_t counter = 1; /* avoid null oid */
410409
const unsigned hashsz = the_hash_algo->rawsz;
@@ -420,7 +419,7 @@ static const char *anonymize_oid(const char *oid_hex)
420419
{
421420
static struct hashmap objs;
422421
size_t len = strlen(oid_hex);
423-
return anonymize_str(&objs, generate_fake_oid, oid_hex, len, NULL);
422+
return anonymize_str(&objs, generate_fake_oid, oid_hex, len);
424423
}
425424

426425
static void show_filemodify(struct diff_queue_struct *q,
@@ -517,7 +516,7 @@ static const char *find_encoding(const char *begin, const char *end)
517516
return bol;
518517
}
519518

520-
static char *anonymize_ref_component(void *data)
519+
static char *anonymize_ref_component(void)
521520
{
522521
static int counter;
523522
struct strbuf out = STRBUF_INIT;
@@ -563,7 +562,7 @@ static char *anonymize_commit_message(const char *old)
563562
return xstrfmt("subject %d\n\nbody\n", counter++);
564563
}
565564

566-
static char *anonymize_ident(void *data)
565+
static char *anonymize_ident(void)
567566
{
568567
static int counter;
569568
struct strbuf out = STRBUF_INIT;
@@ -606,7 +605,7 @@ static void anonymize_ident_line(const char **beg, const char **end)
606605

607606
len = split.mail_end - split.name_begin;
608607
ident = anonymize_str(&idents, anonymize_ident,
609-
split.name_begin, len, NULL);
608+
split.name_begin, len);
610609
strbuf_addstr(out, ident);
611610
strbuf_addch(out, ' ');
612611
strbuf_add(out, split.date_begin, split.tz_end - split.date_begin);
@@ -747,7 +746,7 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
747746
show_progress();
748747
}
749748

750-
static char *anonymize_tag(void *data)
749+
static char *anonymize_tag(void)
751750
{
752751
static int counter;
753752
struct strbuf out = STRBUF_INIT;
@@ -809,7 +808,7 @@ static void handle_tag(const char *name, struct tag *tag)
809808
if (message) {
810809
static struct hashmap tags;
811810
message = anonymize_str(&tags, anonymize_tag,
812-
message, message_size, NULL);
811+
message, message_size);
813812
message_size = strlen(message);
814813
}
815814
}

0 commit comments

Comments
 (0)