From f228d1f006241e4085a432799356ebd7b1e86108 Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Thu, 7 Apr 2011 19:22:18 +0100 Subject: Makefile: Use cgcc rather than sparse in the check target cgcc is the recommended way to run sparse, since it provides many -Defines suitable for the given gcc platform. Using an "cgcc -no-compile" command runs sparse, with all the platform specific definitions provided by cgcc, without also invoking gcc. Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano diff --git a/Makefile b/Makefile index cbc3fce..a21f60e 100644 --- a/Makefile +++ b/Makefile @@ -323,9 +323,7 @@ GCOV = gcov export TCL_PATH TCLTK_PATH -# sparse is architecture-neutral, which means that we need to tell it -# explicitly what architecture to check for. Fix this up for yours.. -SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__ +SPARSE_FLAGS = @@ -924,6 +922,7 @@ ifeq ($(uname_O),Cygwin) X = .exe COMPAT_OBJS += compat/cygwin.o UNRELIABLE_FSTAT = UnfortunatelyYes + SPARSE_FLAGS = -isystem /usr/include/w32api -Wno-one-bit-signed-bitfield endif ifeq ($(uname_S),FreeBSD) NEEDS_LIBICONV = YesPlease @@ -1177,6 +1176,7 @@ ifneq (,$(findstring MINGW,$(uname_S))) EXTLIBS += -lws2_32 PTHREAD_LIBS = X = .exe + SPARSE_FLAGS = -Wno-one-bit-signed-bitfield ifneq (,$(wildcard ../THIS_IS_MSYSGIT)) htmldir=doc/git/html/ prefix = @@ -2161,11 +2161,12 @@ check-sha1:: test-sha1$X ./test-sha1.sh check: common-cmds.h - if sparse; \ + @if sparse; \ then \ for i in $(patsubst %.o, %.c, $(GIT_OBJS)); \ do \ - sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \ + echo ' ' SP $$i; \ + cgcc -no-compile $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \ done; \ else \ echo 2>&1 "Did you mean 'make test'?"; \ -- cgit v0.10.2-6-g49f6 From 2ad9d4cb18bc8debcc9da253425f7a598f40cee2 Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Thu, 7 Apr 2011 19:23:40 +0100 Subject: sparse: Fix an "symbol 'cmd_index_pack' not declared" warning Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 31f001f..e40451f 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -1,4 +1,4 @@ -#include "cache.h" +#include "builtin.h" #include "delta.h" #include "pack.h" #include "csum-file.h" -- cgit v0.10.2-6-g49f6 From d27da38a19d0c21702a012689f256b83545f2e7f Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Thu, 7 Apr 2011 19:24:57 +0100 Subject: sparse: Fix some "Using plain integer as NULL pointer" warnings Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano diff --git a/imap-send.c b/imap-send.c index 9adf4b9..e1ad1a4 100644 --- a/imap-send.c +++ b/imap-send.c @@ -1193,13 +1193,13 @@ static struct store *imap_open_store(struct imap_server_conf *srvc) if (!preauth) { #ifndef NO_OPENSSL if (!srvc->use_ssl && CAP(STARTTLS)) { - if (imap_exec(ctx, 0, "STARTTLS") != RESP_OK) + if (imap_exec(ctx, NULL, "STARTTLS") != RESP_OK) goto bail; if (ssl_socket_connect(&imap->buf.sock, 1, srvc->ssl_verify)) goto bail; /* capabilities may have changed, so get the new capabilities */ - if (imap_exec(ctx, 0, "CAPABILITY") != RESP_OK) + if (imap_exec(ctx, NULL, "CAPABILITY") != RESP_OK) goto bail; } #endif -- cgit v0.10.2-6-g49f6 From c8f1444d9e708e3994c74c180194c43bf1588b65 Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Thu, 7 Apr 2011 19:26:23 +0100 Subject: sparse: Fix an "symbol 'format_subject' not declared" warning In order to fix the warning, we add an extern declaration for this function to the "commit.h" header file, along with all other non- static functions defined in pretty.c. Also, we remove the function declaration from builtin/shortlog.c, since it is no longer needed. Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano diff --git a/builtin/shortlog.c b/builtin/shortlog.c index f5efc67..b6f4b0e 100644 --- a/builtin/shortlog.c +++ b/builtin/shortlog.c @@ -29,9 +29,6 @@ static int compare_by_number(const void *a1, const void *a2) return -1; } -const char *format_subject(struct strbuf *sb, const char *msg, - const char *line_separator); - static void insert_one_record(struct shortlog *log, const char *author, const char *oneline) diff --git a/commit.h b/commit.h index 4198513..b3c3bb7 100644 --- a/commit.h +++ b/commit.h @@ -90,6 +90,8 @@ extern char *logmsg_reencode(const struct commit *commit, extern char *reencode_commit_message(const struct commit *commit, const char **encoding_p); extern void get_commit_format(const char *arg, struct rev_info *); +extern const char *format_subject(struct strbuf *sb, const char *msg, + const char *line_separator); extern void userformat_find_requirements(const char *fmt, struct userformat_want *w); extern void format_commit_message(const struct commit *commit, const char *format, struct strbuf *sb, -- cgit v0.10.2-6-g49f6 From 1e0f8c41ac157c54a33f2ee0afb7d96f5156ed0d Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Thu, 7 Apr 2011 19:31:24 +0100 Subject: sparse: Fix an "symbol 'merge_file' not decared" warning In order to fix the warning, we add a new "merge-file.h" header containing the extern declaration of the merge_file() function, and include the header in the source files that require the declaration. Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano diff --git a/Makefile b/Makefile index a21f60e..385193a 100644 --- a/Makefile +++ b/Makefile @@ -525,6 +525,7 @@ LIB_H += list-objects.h LIB_H += ll-merge.h LIB_H += log-tree.h LIB_H += mailmap.h +LIB_H += merge-file.h LIB_H += merge-recursive.h LIB_H += notes.h LIB_H += notes-cache.h diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c index 1991742..897a563 100644 --- a/builtin/merge-tree.c +++ b/builtin/merge-tree.c @@ -3,6 +3,7 @@ #include "xdiff-interface.h" #include "blob.h" #include "exec_cmd.h" +#include "merge-file.h" static const char merge_tree_usage[] = "git merge-tree "; static int resolve_directories = 1; @@ -54,8 +55,6 @@ static const char *explanation(struct merge_list *entry) return "removed in remote"; } -extern void *merge_file(const char *, struct blob *, struct blob *, struct blob *, unsigned long *); - static void *result(struct merge_list *entry, unsigned long *size) { enum object_type type; diff --git a/merge-file.c b/merge-file.c index f7f4533..7845528 100644 --- a/merge-file.c +++ b/merge-file.c @@ -3,6 +3,7 @@ #include "xdiff-interface.h" #include "ll-merge.h" #include "blob.h" +#include "merge-file.h" static int fill_mmfile_blob(mmfile_t *f, struct blob *obj) { diff --git a/merge-file.h b/merge-file.h new file mode 100644 index 0000000..9b3b83a --- /dev/null +++ b/merge-file.h @@ -0,0 +1,7 @@ +#ifndef MERGE_FILE_H +#define MERGE_FILE_H + +extern void *merge_file(const char *path, struct blob *base, struct blob *our, + struct blob *their, unsigned long *size); + +#endif -- cgit v0.10.2-6-g49f6 From 0bcd9ae85d7e05e78a10a69a2ebe98dcde130937 Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Thu, 21 Apr 2011 20:14:42 +0100 Subject: sparse: Fix errors due to missing target-specific variables In particular, sparse issues the following errors: attr.c:472:43: error: undefined identifier 'ETC_GITATTRIBUTES' config.c:821:43: error: undefined identifier 'ETC_GITCONFIG' exec_cmd.c:14:37: error: undefined identifier 'PREFIX' exec_cmd.c:83:28: error: undefined identifier 'GIT_EXEC_PATH' builtin/help.c:328:46: error: undefined identifier 'GIT_MAN_PATH' builtin/help.c:374:40: error: undefined identifier 'GIT_INFO_PATH' builtin/help.c:382:45: error: undefined identifier 'GIT_HTML_PATH' git.c:96:42: error: undefined identifier 'GIT_HTML_PATH' git.c:241:35: error: invalid initializer http.c:293:43: error: undefined identifier 'GIT_HTTP_USER_AGENT' which is caused by not passing the target-specific additions to the EXTRA_CPPFLAGS variable to cgcc. In order to fix the problem, we define a new sparse target which depends on a set of non-existent "sparse object" files (*.sp) which correspond to the set of C source files. In addition to the new target, we also provide a new pattern rule for "creating" the sparse object files from the source files by running cgcc. This allows us to add '*.sp' to the rules setting the target-specific EXTRA_CPPFLAGS variable, which is then included in the new pattern rule to run cgcc. Also, we change the 'check' target to re-direct the user to the new sparse target. Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano diff --git a/Makefile b/Makefile index 385193a..c7c1530 100644 --- a/Makefile +++ b/Makefile @@ -1581,6 +1581,7 @@ ifndef V QUIET_LNCP = @echo ' ' LN/CP $@; QUIET_XGETTEXT = @echo ' ' XGETTEXT $@; QUIET_GCOV = @echo ' ' GCOV $@; + QUIET_SP = @echo ' ' SP $<; QUIET_SUBDIR0 = +@subdir= QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \ $(MAKE) $(PRINT_DIR) -C $$subdir @@ -1676,17 +1677,17 @@ strip: $(PROGRAMS) git$X $(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X git.o: common-cmds.h -git.s git.o: EXTRA_CPPFLAGS = -DGIT_VERSION='"$(GIT_VERSION)"' \ +git.sp git.s git.o: EXTRA_CPPFLAGS = -DGIT_VERSION='"$(GIT_VERSION)"' \ '-DGIT_HTML_PATH="$(htmldir_SQ)"' git$X: git.o $(BUILTIN_OBJS) $(GITLIBS) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \ $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS) -help.o: common-cmds.h +help.sp help.o: common-cmds.h -builtin/help.o: common-cmds.h -builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \ +builtin/help.sp builtin/help.o: common-cmds.h +builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \ '-DGIT_HTML_PATH="$(htmldir_SQ)"' \ '-DGIT_MAN_PATH="$(mandir_SQ)"' \ '-DGIT_INFO_PATH="$(infodir_SQ)"' @@ -1972,30 +1973,34 @@ $(VCSSVN_OBJS) $(VCSSVN_TEST_OBJS): $(LIB_H) \ test-svn-fe.o: vcs-svn/svndump.h endif -exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \ +exec_cmd.sp exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \ '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \ '-DBINDIR="$(bindir_relative_SQ)"' \ '-DPREFIX="$(prefix_SQ)"' -builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \ +builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \ -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' -config.s config.o: EXTRA_CPPFLAGS = -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"' +config.sp config.s config.o: EXTRA_CPPFLAGS = \ + -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"' -attr.s attr.o: EXTRA_CPPFLAGS = -DETC_GITATTRIBUTES='"$(ETC_GITATTRIBUTES_SQ)"' +attr.sp attr.s attr.o: EXTRA_CPPFLAGS = \ + -DETC_GITATTRIBUTES='"$(ETC_GITATTRIBUTES_SQ)"' -http.s http.o: EXTRA_CPPFLAGS = -DGIT_HTTP_USER_AGENT='"git/$(GIT_VERSION)"' +http.sp http.s http.o: EXTRA_CPPFLAGS = \ + -DGIT_HTTP_USER_AGENT='"git/$(GIT_VERSION)"' ifdef NO_EXPAT -http-walker.s http-walker.o: EXTRA_CPPFLAGS = -DNO_EXPAT +http-walker.sp http-walker.s http-walker.o: EXTRA_CPPFLAGS = -DNO_EXPAT endif ifdef NO_REGEX -compat/regex/regex.o: EXTRA_CPPFLAGS = -DGAWK -DNO_MBSUPPORT +compat/regex/regex.sp compat/regex/regex.o: EXTRA_CPPFLAGS = \ + -DGAWK -DNO_MBSUPPORT endif ifdef USE_NED_ALLOCATOR -compat/nedmalloc/nedmalloc.o: EXTRA_CPPFLAGS = \ +compat/nedmalloc/nedmalloc.sp compat/nedmalloc/nedmalloc.o: EXTRA_CPPFLAGS = \ -DNDEBUG -DOVERRIDE_STRDUP -DREPLACE_SYSTEM_ALLOCATOR endif @@ -2161,14 +2166,20 @@ test-%$X: test-%.o $(GITLIBS) check-sha1:: test-sha1$X ./test-sha1.sh +SP_OBJ = $(patsubst %.o,%.sp,$(C_OBJ)) + +$(SP_OBJ): %.sp: %.c GIT-CFLAGS FORCE + $(QUIET_SP)cgcc -no-compile $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) \ + $(SPARSE_FLAGS) $< + +.PHONY: sparse $(SP_OBJ) +sparse: $(SP_OBJ) + check: common-cmds.h @if sparse; \ then \ - for i in $(patsubst %.o, %.c, $(GIT_OBJS)); \ - do \ - echo ' ' SP $$i; \ - cgcc -no-compile $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \ - done; \ + echo 2>&1 "Use 'make sparse' instead"; \ + $(MAKE) --no-print-directory sparse; \ else \ echo 2>&1 "Did you mean 'make test'?"; \ exit 1; \ -- cgit v0.10.2-6-g49f6 From c51477229ee4c7846d40a447860b5bf94aa1103d Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Thu, 7 Apr 2011 19:49:33 +0100 Subject: sparse: Fix some "symbol not declared" warnings In particular, sparse issues the "symbol 'a_symbol' was not declared. Should it be static?" warnings for the following symbols: attr.c:468:12: 'git_etc_gitattributes' attr.c:476:5: 'git_attr_system' vcs-svn/svndump.c:282:6: 'svndump_read' vcs-svn/svndump.c:417:5: 'svndump_init' vcs-svn/svndump.c:432:6: 'svndump_deinit' vcs-svn/svndump.c:445:6: 'svndump_reset' The symbols in attr.c only require file scope, so we add the static modifier to their declaration. The symbols in vcs-svn/svndump.c are external symbols, and they already have extern declarations in the "svndump.h" header file, so we simply include the header in svndump.c. Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano diff --git a/attr.c b/attr.c index 0e28ba8..f6b3f7e 100644 --- a/attr.c +++ b/attr.c @@ -465,7 +465,7 @@ static void drop_attr_stack(void) } } -const char *git_etc_gitattributes(void) +static const char *git_etc_gitattributes(void) { static const char *system_wide; if (!system_wide) @@ -473,7 +473,7 @@ const char *git_etc_gitattributes(void) return system_wide; } -int git_attr_system(void) +static int git_attr_system(void) { return !git_env_bool("GIT_ATTR_NOSYSTEM", 0); } diff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c index 572a995..bc79222 100644 --- a/vcs-svn/svndump.c +++ b/vcs-svn/svndump.c @@ -13,6 +13,7 @@ #include "line_buffer.h" #include "string_pool.h" #include "strbuf.h" +#include "svndump.h" /* * Compare start of string to literal of equal length; -- cgit v0.10.2-6-g49f6