@matheusbsbs / matheus-bagliano / commits / 9db56f71b9
Fork 0

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 <casey@nrlssc.navy.mil>. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Daniel Lowe committed Nov 10, 2008 at 16:07 UTC 9db56f71b91153f4076a796c80c61f00edd8b700
8 files changed +12 -12
builtin-remote.c
+1 -1
@@ -323,7 +323,7 @@ static int add_branch_for_removal(const char *refname,
323
324 /* make sure that symrefs are deleted */
325 if (flags & REF_ISSYMREF)
326 - return unlink(git_path(refname));
326 + return unlink(git_path("%s", refname));
327
328 item = string_list_append(refname, branches->branches);
329 item->util = xmalloc(20);
bundle.c
+2 -2
@@ -114,7 +114,7 @@ int verify_bundle(struct bundle_header *header, int verbose)
114 continue;
115 }
116 if (++ret == 1)
117 - error(message);
117 + error("%s", message);
118 error("%s %s", sha1_to_hex(e->sha1), e->name);
119 }
120 if (revs.pending.nr != p->nr)
@@ -139,7 +139,7 @@ int verify_bundle(struct bundle_header *header, int verbose)
139 for (i = 0; i < req_nr; i++)
140 if (!(refs.objects[i].item->flags & SHOWN)) {
141 if (++ret == 1)
142 - error(message);
142 + error("%s", message);
143 error("%s %s", sha1_to_hex(refs.objects[i].item->sha1),
144 refs.objects[i].name);
145 }
environment.c
+1 -1
@@ -113,7 +113,7 @@ const char *get_git_work_tree(void)
113 work_tree = git_work_tree_cfg;
114 /* make_absolute_path also normalizes the path */
115 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)));
117 } else if (work_tree)
118 work_tree = xstrdup(make_absolute_path(work_tree));
119 git_work_tree_initialized = 1;
fsck.c
+1 -1
@@ -327,7 +327,7 @@ int fsck_error_function(struct object *obj, int type, const char *fmt, ...)
327 die("this should not happen, your snprintf is broken");
328 }
329
330 - error(sb.buf);
330 + error("%s", sb.buf);
331 strbuf_release(&sb);
332 return 1;
333 }
grep.c
+3 -3
@@ -507,7 +507,7 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
507 if (from <= last_shown)
508 from = last_shown + 1;
509 if (last_shown && from != last_shown + 1)
510 - printf(hunk_mark);
510 + fputs(hunk_mark, stdout);
511 while (from < lno) {
512 pcl = &prev[lno-from-1];
513 show_line(opt, pcl->bol, pcl->eol,
@@ -517,7 +517,7 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
517 last_shown = lno-1;
518 }
519 if (last_shown && lno != last_shown + 1)
520 - printf(hunk_mark);
520 + fputs(hunk_mark, stdout);
521 if (!opt->count)
522 show_line(opt, bol, eol, name, lno, ':');
523 last_shown = last_hit = lno;
@@ -528,7 +528,7 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
528 * we need to show this line.
529 */
530 if (last_shown && lno != last_shown + 1)
531 - printf(hunk_mark);
531 + fputs(hunk_mark, stdout);
532 show_line(opt, bol, eol, name, lno, '-');
533 last_shown = lno;
534 }
path.c
+2 -2
@@ -41,7 +41,7 @@ char *mksnpath(char *buf, size_t n, const char *fmt, ...)
41 len = vsnprintf(buf, n, fmt, args);
42 va_end(args);
43 if (len >= n) {
44 - snprintf(buf, n, bad_path);
44 + strlcpy(buf, bad_path, n);
45 return buf;
46 }
47 return cleanup_path(buf);
@@ -63,7 +63,7 @@ static char *git_vsnpath(char *buf, size_t n, const char *fmt, va_list args)
63 goto bad;
64 return cleanup_path(buf);
65 bad:
66 - snprintf(buf, n, bad_path);
66 + strlcpy(buf, bad_path, n);
67 return buf;
68 }
69
refs.c
+1 -1
@@ -934,7 +934,7 @@ int delete_ref(const char *refname, const unsigned char *sha1, int delopt)
934 lock->lk->filename[i] = 0;
935 path = lock->lk->filename;
936 } else {
937 - path = git_path(refname);
937 + path = git_path("%s", refname);
938 }
939 err = unlink(path);
940 if (err && errno != ENOENT) {
unpack-trees.c
+1 -1
@@ -352,7 +352,7 @@ static int unpack_failed(struct unpack_trees_options *o, const char *message)
352 discard_index(&o->result);
353 if (!o->gently) {
354 if (message)
355 - return error(message);
355 + return error("%s", message);
356 return -1;
357 }
358 return -1;