Skip to content

Commit e9a820c

Browse files
jiangxingitster
authored andcommitted
write_name{_quoted_relative,}(): remove redundant parameters
After substitute path_relative() in quote.c with relative_path() from path.c, parameters (such as len and prefix_len) are redundant in function write_name() and write_name_quoted_relative(). The callers have already been audited that the strings they pass are properly NUL terminated and the length they give are the length of the string (or -1 that asks the length to be counted by the callee). Remove these now-redundant parameters. Signed-off-by: Jiang Xin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 39598f9 commit e9a820c

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

builtin/ls-files.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,14 @@ static const char *tag_modified = "";
4646
static const char *tag_skip_worktree = "";
4747
static const char *tag_resolve_undo = "";
4848

49-
static void write_name(const char* name, size_t len)
49+
static void write_name(const char *name)
5050
{
5151
/*
52-
* With "--full-name", prefix_len=0; write_name_quoted_relative()
53-
* ignores prefix_len, so this caller needs to pass empty string
54-
* in that case (a NULL is good for "").
52+
* With "--full-name", prefix_len=0; this caller needs to pass
53+
* an empty string in that case (a NULL is good for "").
5554
*/
56-
write_name_quoted_relative(name, len, prefix_len ? prefix : NULL,
57-
prefix_len, stdout, line_terminator);
55+
write_name_quoted_relative(name, prefix_len ? prefix : NULL,
56+
stdout, line_terminator);
5857
}
5958

6059
static void show_dir_entry(const char *tag, struct dir_entry *ent)
@@ -68,7 +67,7 @@ static void show_dir_entry(const char *tag, struct dir_entry *ent)
6867
return;
6968

7069
fputs(tag, stdout);
71-
write_name(ent->name, ent->len);
70+
write_name(ent->name);
7271
}
7372

7473
static void show_other_files(struct dir_struct *dir)
@@ -168,7 +167,7 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce)
168167
find_unique_abbrev(ce->sha1,abbrev),
169168
ce_stage(ce));
170169
}
171-
write_name(ce->name, ce_namelen(ce));
170+
write_name(ce->name);
172171
if (debug_mode) {
173172
printf(" ctime: %d:%d\n", ce->ce_ctime.sec, ce->ce_ctime.nsec);
174173
printf(" mtime: %d:%d\n", ce->ce_mtime.sec, ce->ce_mtime.nsec);
@@ -201,7 +200,7 @@ static void show_ru_info(void)
201200
printf("%s%06o %s %d\t", tag_resolve_undo, ui->mode[i],
202201
find_unique_abbrev(ui->sha1[i], abbrev),
203202
i + 1);
204-
write_name(path, len);
203+
write_name(path);
205204
}
206205
}
207206
}

quote.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,7 @@ void write_name_quotedpfx(const char *pfx, size_t pfxlen,
312312
fputc(terminator, fp);
313313
}
314314

315-
void write_name_quoted_relative(const char *name, size_t len,
316-
const char *prefix, size_t prefix_len,
315+
void write_name_quoted_relative(const char *name, const char *prefix,
317316
FILE *fp, int terminator)
318317
{
319318
struct strbuf sb = STRBUF_INIT;

quote.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ extern void quote_two_c_style(struct strbuf *, const char *, const char *, int);
6060
extern void write_name_quoted(const char *name, FILE *, int terminator);
6161
extern void write_name_quotedpfx(const char *pfx, size_t pfxlen,
6262
const char *name, FILE *, int terminator);
63-
extern void write_name_quoted_relative(const char *name, size_t len,
64-
const char *prefix, size_t prefix_len,
63+
extern void write_name_quoted_relative(const char *name, const char *prefix,
6564
FILE *fp, int terminator);
6665

6766
/* quote path as relative to the given prefix */

0 commit comments

Comments
 (0)