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 <worldhello.net@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jiang Xin committed Jun 25, 2013 at 23:53 UTC e9a820cefde2170840fbcdf7c4b74369988869dc
3 files changed +10 -13
builtin/ls-files.c
+8 -9
@@ -46,15 +46,14 @@ static const char *tag_modified = "";
46 static const char *tag_skip_worktree = "";
47 static const char *tag_resolve_undo = "";
48
49 -static void write_name(const char* name, size_t len)
49 +static void write_name(const char *name)
50 {
51 /*
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 "").
54 */
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);
57 }
58
59 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)
67 return;
68
69 fputs(tag, stdout);
71 - write_name(ent->name, ent->len);
70 + write_name(ent->name);
71 }
72
73 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)
167 find_unique_abbrev(ce->sha1,abbrev),
168 ce_stage(ce));
169 }
171 - write_name(ce->name, ce_namelen(ce));
170 + write_name(ce->name);
171 if (debug_mode) {
172 printf(" ctime: %d:%d\n", ce->ce_ctime.sec, ce->ce_ctime.nsec);
173 printf(" mtime: %d:%d\n", ce->ce_mtime.sec, ce->ce_mtime.nsec);
@@ -201,7 +200,7 @@ static void show_ru_info(void)
200 printf("%s%06o %s %d\t", tag_resolve_undo, ui->mode[i],
201 find_unique_abbrev(ui->sha1[i], abbrev),
202 i + 1);
204 - write_name(path, len);
203 + write_name(path);
204 }
205 }
206 }
quote.c
+1 -2
@@ -312,8 +312,7 @@ void write_name_quotedpfx(const char *pfx, size_t pfxlen,
312 fputc(terminator, fp);
313 }
314
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,
316 FILE *fp, int terminator)
317 {
318 struct strbuf sb = STRBUF_INIT;
quote.h
+1 -2
@@ -60,8 +60,7 @@ extern void quote_two_c_style(struct strbuf *, const char *, const char *, int);
60 extern void write_name_quoted(const char *name, FILE *, int terminator);
61 extern void write_name_quotedpfx(const char *pfx, size_t pfxlen,
62 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,
64 FILE *fp, int terminator);
65
66 /* quote path as relative to the given prefix */