summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 96ad15a)
raw | patch | inline | side by side (parent: 96ad15a)
author | Timo Sirainen <tss@iki.fi> | |
Tue, 9 Aug 2005 15:30:22 +0000 (18:30 +0300) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Wed, 10 Aug 2005 05:28:19 +0000 (22:28 -0700) |
GCC's format __attribute__ is good for checking errors, especially
with -Wformat=2 parameter. This fixes most of the reported problems
against 2005-08-09 snapshot.
with -Wformat=2 parameter. This fixes most of the reported problems
against 2005-08-09 snapshot.
apply.c | patch | blob | history | |
cache.h | patch | blob | history | |
clone-pack.c | patch | blob | history | |
connect.c | patch | blob | history | |
csum-file.h | patch | blob | history | |
pack-check.c | patch | blob | history | |
pkt-line.h | patch | blob | history | |
refs.c | patch | blob | history | |
tar-tree.c | patch | blob | history |
index c671d9e86cc04e2c6756212e3496c4ef5db8207a..81607c0fb6f39a0fb177a16b5f8c7353e97936aa 100644 (file)
--- a/apply.c
+++ b/apply.c
@@ -563,7 +563,7 @@ static int find_header(char *line, unsigned long size, int *hdrsize, struct patc
struct fragment dummy;
if (parse_fragment_header(line, len, &dummy) < 0)
continue;
- error("patch fragment without header at line %d: %.*s", linenr, len-1, line);
+ error("patch fragment without header at line %d: %.*s", linenr, (int)len-1, line);
}
if (size < len + 6)
while (frag) {
if (apply_one_fragment(desc, frag) < 0)
- return error("patch failed: %s:%d", patch->old_name, frag->oldpos);
+ return error("patch failed: %s:%ld", patch->old_name, frag->oldpos);
frag = frag->next;
}
return 0;
index 957e2ca7ca0d1a7209b8e1294286a1f641eb1338..efd2a2c595aa6253ec70d0c45289345dd6043003 100644 (file)
--- a/cache.h
+++ b/cache.h
#define NORETURN
#endif
+#ifndef __attribute__
+#define __attribute(x)
+#endif
+
/*
* Intensive research over the course of many years has shown that
* port 9418 is totally unused by anything else. Or
#define TYPE_CHANGED 0x0040
/* Return a statically allocated filename matching the sha1 signature */
-extern char *mkpath(const char *fmt, ...);
-extern char *git_path(const char *fmt, ...);
+extern char *mkpath(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
+extern char *git_path(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
extern char *sha1_file_name(const unsigned char *sha1);
extern char *sha1_pack_name(const unsigned char *sha1);
extern char *sha1_pack_index_name(const unsigned char *sha1);
@@ -218,8 +222,8 @@ extern char *sha1_to_hex(const unsigned char *sha1); /* static buffer result! */
/* General helper functions */
extern void usage(const char *err) NORETURN;
-extern void die(const char *err, ...) NORETURN;
-extern int error(const char *err, ...);
+extern void die(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2)));
+extern int error(const char *err, ...) __attribute__((format (printf, 1, 2)));
extern int base_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);
extern int cache_name_compare(const char *name1, int len1, const char *name2, int len2);
diff --git a/clone-pack.c b/clone-pack.c
index e9c20dee71ac18cdc4ff06d78e5a9345a347914d..49820c6579dc286634d083a37a80baa508626408 100644 (file)
--- a/clone-pack.c
+++ b/clone-pack.c
static void write_one_ref(struct ref *ref)
{
- char *path = git_path(ref->name);
+ char *path = git_path("%s", ref->name);
int fd;
char *hex;
diff --git a/connect.c b/connect.c
index 20b80a1b54b965d4af272aa7cb7c0009c737e4dd..8f4d99aef25d66c6c8f0196055dd7df8ecd6ef2d 100644 (file)
--- a/connect.c
+++ b/connect.c
if (matched_src)
break;
errs = 1;
- error("src refspec %s does not match any.");
+ error("src refspec %s does not match any.",
+ rs[i].src);
break;
default:
errs = 1;
diff --git a/csum-file.h b/csum-file.h
index 776cfb152af2b6c4fb6c190d875b4fb2f9162c9a..3ad1a992a758fc9339baa2cecc17ac14af359f1b 100644 (file)
--- a/csum-file.h
+++ b/csum-file.h
};
extern struct sha1file *sha1fd(int fd, const char *name);
-extern struct sha1file *sha1create(const char *fmt, ...);
+extern struct sha1file *sha1create(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
extern int sha1close(struct sha1file *, unsigned char *, int);
extern int sha1write(struct sha1file *, void *, unsigned int);
extern int sha1write_compressed(struct sha1file *, void *, unsigned int);
diff --git a/pack-check.c b/pack-check.c
index 054b0131e9756f8bb98556a62179c2f1c232e2e5..511f29424a622f62035f1cd3428aeca7ee18f0e2 100644 (file)
--- a/pack-check.c
+++ b/pack-check.c
/* Header consistency check */
hdr = p->pack_base;
if (hdr->hdr_signature != htonl(PACK_SIGNATURE))
- return error("Packfile signature mismatch", p->pack_name);
+ return error("Packfile %s signature mismatch", p->pack_name);
if (hdr->hdr_version != htonl(PACK_VERSION))
return error("Packfile version %d different from ours %d",
ntohl(hdr->hdr_version), PACK_VERSION);
diff --git a/pkt-line.h b/pkt-line.h
index b0b4f6d495e06cfe797a9c8dfba38d61804e6c81..51d0cbe219f2f45bf3920441f09dfcc2744adb06 100644 (file)
--- a/pkt-line.h
+++ b/pkt-line.h
* Silly packetized line writing interface
*/
void packet_flush(int fd);
-void packet_write(int fd, const char *fmt, ...);
+void packet_write(int fd, const char *fmt, ...) __attribute__((format (printf, 2, 3)));
int packet_read_line(int fd, char *buffer, unsigned size);
index 774f1630fe79b00780be91f7937eb75c16fd3b16..a5c894661090549e1676c7dd26fd2f72eb330d9f 100644 (file)
--- a/refs.c
+++ b/refs.c
static int read_ref(const char *refname, unsigned char *sha1)
{
int ret = -1;
- int fd = open(git_path(refname), O_RDONLY);
+ int fd = open(git_path("%s", refname), O_RDONLY);
if (fd >= 0) {
char buffer[60];
static int do_for_each_ref(const char *base, int (*fn)(const char *path, const unsigned char *sha1))
{
int retval = 0;
- DIR *dir = opendir(git_path(base));
+ DIR *dir = opendir(git_path("%s", base));
if (dir) {
struct dirent *de;
if (namelen > 255)
continue;
memcpy(path + baselen, de->d_name, namelen+1);
- if (lstat(git_path(path), &st) < 0)
+ if (lstat(git_path("%s", path), &st) < 0)
continue;
if (S_ISDIR(st.st_mode)) {
retval = do_for_each_ref(path, fn);
diff --git a/tar-tree.c b/tar-tree.c
index a877fe545e74511a905f803564e51158da68d0d1..2716ae3eb1430abfc43d980d904fc192f8dcbbf4 100644 (file)
--- a/tar-tree.c
+++ b/tar-tree.c
@@ -325,8 +325,8 @@ static void write_header(const unsigned char *sha1, char typeflag, const char *b
memcpy(&header[257], "ustar", 6);
memcpy(&header[263], "00", 2);
- printf(&header[329], "%07o", 0); /* devmajor */
- printf(&header[337], "%07o", 0); /* devminor */
+ sprintf(&header[329], "%07o", 0); /* devmajor */
+ sprintf(&header[337], "%07o", 0); /* devminor */
memset(&header[148], ' ', 8);
for (i = 0; i < RECORDSIZE; i++)