Skip to content

Commit 9db56f7

Browse files
Daniel Lowegitster
authored andcommitted
Fix non-literal format in printf-style calls
These were found using gcc 4.3.2-1ubuntu11 with the warning: warning: format not a string literal and no format arguments Incorporated suggestions from Brandon Casey <[email protected]>. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 989206f commit 9db56f7

File tree

8 files changed

+12
-12
lines changed

8 files changed

+12
-12
lines changed

builtin-remote.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ static int add_branch_for_removal(const char *refname,
323323

324324
/* make sure that symrefs are deleted */
325325
if (flags & REF_ISSYMREF)
326-
return unlink(git_path(refname));
326+
return unlink(git_path("%s", refname));
327327

328328
item = string_list_append(refname, branches->branches);
329329
item->util = xmalloc(20);

bundle.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ int verify_bundle(struct bundle_header *header, int verbose)
114114
continue;
115115
}
116116
if (++ret == 1)
117-
error(message);
117+
error("%s", message);
118118
error("%s %s", sha1_to_hex(e->sha1), e->name);
119119
}
120120
if (revs.pending.nr != p->nr)
@@ -139,7 +139,7 @@ int verify_bundle(struct bundle_header *header, int verbose)
139139
for (i = 0; i < req_nr; i++)
140140
if (!(refs.objects[i].item->flags & SHOWN)) {
141141
if (++ret == 1)
142-
error(message);
142+
error("%s", message);
143143
error("%s %s", sha1_to_hex(refs.objects[i].item->sha1),
144144
refs.objects[i].name);
145145
}

environment.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ const char *get_git_work_tree(void)
113113
work_tree = git_work_tree_cfg;
114114
/* make_absolute_path also normalizes the path */
115115
if (work_tree && !is_absolute_path(work_tree))
116-
work_tree = xstrdup(make_absolute_path(git_path(work_tree)));
116+
work_tree = xstrdup(make_absolute_path(git_path("%s", work_tree)));
117117
} else if (work_tree)
118118
work_tree = xstrdup(make_absolute_path(work_tree));
119119
git_work_tree_initialized = 1;

fsck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ int fsck_error_function(struct object *obj, int type, const char *fmt, ...)
327327
die("this should not happen, your snprintf is broken");
328328
}
329329

330-
error(sb.buf);
330+
error("%s", sb.buf);
331331
strbuf_release(&sb);
332332
return 1;
333333
}

grep.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
507507
if (from <= last_shown)
508508
from = last_shown + 1;
509509
if (last_shown && from != last_shown + 1)
510-
printf(hunk_mark);
510+
fputs(hunk_mark, stdout);
511511
while (from < lno) {
512512
pcl = &prev[lno-from-1];
513513
show_line(opt, pcl->bol, pcl->eol,
@@ -517,7 +517,7 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
517517
last_shown = lno-1;
518518
}
519519
if (last_shown && lno != last_shown + 1)
520-
printf(hunk_mark);
520+
fputs(hunk_mark, stdout);
521521
if (!opt->count)
522522
show_line(opt, bol, eol, name, lno, ':');
523523
last_shown = last_hit = lno;
@@ -528,7 +528,7 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
528528
* we need to show this line.
529529
*/
530530
if (last_shown && lno != last_shown + 1)
531-
printf(hunk_mark);
531+
fputs(hunk_mark, stdout);
532532
show_line(opt, bol, eol, name, lno, '-');
533533
last_shown = lno;
534534
}

path.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ char *mksnpath(char *buf, size_t n, const char *fmt, ...)
4141
len = vsnprintf(buf, n, fmt, args);
4242
va_end(args);
4343
if (len >= n) {
44-
snprintf(buf, n, bad_path);
44+
strlcpy(buf, bad_path, n);
4545
return buf;
4646
}
4747
return cleanup_path(buf);
@@ -63,7 +63,7 @@ static char *git_vsnpath(char *buf, size_t n, const char *fmt, va_list args)
6363
goto bad;
6464
return cleanup_path(buf);
6565
bad:
66-
snprintf(buf, n, bad_path);
66+
strlcpy(buf, bad_path, n);
6767
return buf;
6868
}
6969

refs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ int delete_ref(const char *refname, const unsigned char *sha1, int delopt)
934934
lock->lk->filename[i] = 0;
935935
path = lock->lk->filename;
936936
} else {
937-
path = git_path(refname);
937+
path = git_path("%s", refname);
938938
}
939939
err = unlink(path);
940940
if (err && errno != ENOENT) {

unpack-trees.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ static int unpack_failed(struct unpack_trees_options *o, const char *message)
352352
discard_index(&o->result);
353353
if (!o->gently) {
354354
if (message)
355-
return error(message);
355+
return error("%s", message);
356356
return -1;
357357
}
358358
return -1;

0 commit comments

Comments
 (0)