diff --git a/builtin-ls-files.c b/builtin-ls-files.c index d36181a755..e83b145b5c 100644 --- a/builtin-ls-files.c +++ b/builtin-ls-files.c @@ -211,7 +211,7 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce) putchar(line_terminator); } else { - printf("%s%06o %s %d\t", + printf("%s%06lo %s %u\t", tag, ntohl(ce->ce_mode), abbrev ? find_unique_abbrev(ce->sha1,abbrev) diff --git a/builtin-prune-packed.c b/builtin-prune-packed.c index 6473d327e6..fa9ad7bfdf 100644 --- a/builtin-prune-packed.c +++ b/builtin-prune-packed.c @@ -7,6 +7,8 @@ static const char prune_packed_usage[] = #define DRY_RUN 01 #define VERBOSE 02 +void sync(void); + static void prune_dir(int i, DIR *dir, char *pathname, int len, int opts) { struct dirent *de; diff --git a/builtin-prune.c b/builtin-prune.c index 44df59e4a7..02e4c09b0e 100644 --- a/builtin-prune.c +++ b/builtin-prune.c @@ -8,6 +8,8 @@ static const char prune_usage[] = "git-prune [-n]"; static int show_only; +void sync(void); + static int prune_object(char *path, const char *filename, const unsigned char *sha1) { if (show_only) { diff --git a/builtin-unpack-objects.c b/builtin-unpack-objects.c index a6ff62fd8c..1500be5761 100644 --- a/builtin-unpack-objects.c +++ b/builtin-unpack-objects.c @@ -318,7 +318,7 @@ static void unpack_all(void) if (ntohl(hdr->hdr_signature) != PACK_SIGNATURE) die("bad pack file"); if (!pack_version_ok(hdr->hdr_version)) - die("unknown pack file version %d", ntohl(hdr->hdr_version)); + die("unknown pack file version %lu", ntohl(hdr->hdr_version)); use(sizeof(struct pack_header)); if (!quiet) diff --git a/compat/mingw.c b/compat/mingw.c index ac8b8e0414..ca3ae4cb06 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -131,7 +131,7 @@ int pipe(int filedes[2]) CloseHandle(h[0]); return -1; } - fd = _open_osfhandle(h[0], O_NOINHERIT); + fd = _open_osfhandle( (int) h[0], O_NOINHERIT); if (fd < 0) { close(filedes[0]); close(filedes[1]); @@ -141,7 +141,7 @@ int pipe(int filedes[2]) } close(filedes[0]); filedes[0] = fd; - fd = _open_osfhandle(h[1], O_NOINHERIT); + fd = _open_osfhandle( (int) h[1], O_NOINHERIT); if (fd < 0) { close(filedes[0]); close(filedes[1]); diff --git a/compat/pread.c b/compat/pread.c index 978cac4ec9..ce29997724 100644 --- a/compat/pread.c +++ b/compat/pread.c @@ -1,5 +1,7 @@ #include "../git-compat-util.h" +int read_in_full(int fd, void *buf, size_t count); + ssize_t git_pread(int fd, void *buf, size_t count, off_t offset) { off_t current_offset; diff --git a/compat/regex.c b/compat/regex.c index 2d57c70b9c..1d39e08d47 100644 --- a/compat/regex.c +++ b/compat/regex.c @@ -1597,10 +1597,12 @@ regex_compile (pattern, size, syntax, bufp) if (syntax & RE_NO_BK_PARENS) goto normal_backslash; if (COMPILE_STACK_EMPTY) + { if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) goto normal_backslash; else return REG_ERPAREN; + } handle_close: if (fixup_alt_jump) @@ -1617,10 +1619,12 @@ regex_compile (pattern, size, syntax, bufp) /* See similar code for backslashed left paren above. */ if (COMPILE_STACK_EMPTY) + { if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) goto normal_char; else return REG_ERPAREN; + } /* Since we just checked for an empty stack above, this ``can't happen''. */ @@ -3191,14 +3195,14 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) matching and the regnum-th regend points to right after where we stopped matching the regnum-th subexpression. (The zeroth register keeps track of what the whole pattern matches.) */ - const char **regstart, **regend; + const char **regstart = NULL, **regend = NULL; /* If a group that's operated upon by a repetition operator fails to match anything, then the register for its start will need to be restored because it will have been set to wherever in the string we are when we last see its open-group operator. Similarly for a register's end. */ - const char **old_regstart, **old_regend; + const char **old_regstart = NULL, **old_regend = NULL; /* The is_active field of reg_info helps us keep track of which (possibly nested) subexpressions we are currently in. The matched_something @@ -3206,14 +3210,14 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) matched any of the pattern so far this time through the reg_num-th subexpression. These two fields get reset each time through any loop their register is in. */ - register_info_type *reg_info; + register_info_type *reg_info = NULL; /* The following record the register info as found in the above variables when we find a match better than any we've seen before. This happens as we backtrack through the failure points, which in turn happens only if we have not yet matched the entire string. */ unsigned best_regs_set = false; - const char **best_regstart, **best_regend; + const char **best_regstart = NULL, **best_regend = NULL; /* Logically, this is `best_regend[0]'. But we don't want to have to allocate space for that if we're not allocating space for anything @@ -3226,8 +3230,8 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) const char *match_end = NULL; /* Used when we pop values we don't care about. */ - const char **reg_dummy; - register_info_type *reg_info_dummy; + const char **reg_dummy = NULL; + register_info_type *reg_info_dummy = NULL; #ifdef DEBUG /* Counts the total number of registers pushed. */ @@ -4561,10 +4565,12 @@ common_op_match_null_string_p (p, end, reg_info) bytes; nonzero otherwise. */ static int -bcmp_translate (s1, s2, len, translate) - unsigned char *s1, *s2; - register int len; - char *translate; +bcmp_translate( + unsigned char *s1, + unsigned char *s2, + int len, + char *translate +) { register unsigned char *p1 = s1, *p2 = s2; while (len) diff --git a/config.c b/config.c index 977115a6e9..98ae20d551 100644 --- a/config.c +++ b/config.c @@ -15,6 +15,8 @@ static const char *config_file_name; static int config_linenr; static int zlib_compression_seen; +extern int getpagesize(); + static int get_next_char(void) { int c; diff --git a/connect.c b/connect.c index f50db639a4..dcae813b58 100644 --- a/connect.c +++ b/connect.c @@ -585,7 +585,7 @@ pid_t git_connect(int fd[2], char *url, const char *prog, int flags) const char *argv[] = { NULL, host, command, NULL }; const char *ssh = getenv("GIT_SSH"); if (!ssh) ssh = "ssh"; - pid = spawnvpe_pipe(ssh, argv, environ, pipefd[1], pipefd[0]); + pid = spawnvpe_pipe(ssh, argv, (const char**) environ, pipefd[1], pipefd[0]); } else { const char *argv[] = { NULL, "-c", command, NULL }; diff --git a/diff.c b/diff.c index e64625129d..462d1e8563 100644 --- a/diff.c +++ b/diff.c @@ -1793,7 +1793,7 @@ static int spawn_prog(const char *pgm, const char **arg) int status; fflush(NULL); - pid = spawnvpe_pipe(pgm, arg, environ, NULL, NULL); + pid = spawnvpe_pipe(pgm, arg, (const char**) environ, NULL, NULL); if (pid < 0) die("unable to fork"); diff --git a/exec_cmd.c b/exec_cmd.c index a9886b87fd..2a8e48b048 100644 --- a/exec_cmd.c +++ b/exec_cmd.c @@ -4,7 +4,6 @@ #include "spawn-pipe.h" #define MAX_ARGS 32 -extern char **environ; static const char *current_exec_path; static const char *builtin_exec_path(void) @@ -138,7 +137,7 @@ int execv_git_cmd(const char **argv) trace_argv_printf(argv, -1, "trace: exec:"); /* execve() can only ever return if it fails */ - execve(git_command, (char **)argv, environ); + execve(git_command, (const char **) argv, (const char **) environ); trace_printf("trace: exec failed: %s\n", strerror(errno)); @@ -247,7 +246,7 @@ int spawnv_git_cmd(const char **argv, int pin[2], int pout[2]) trace_argv_printf(argv, -1, "trace: exec:"); - pid = spawnvppe_pipe(cmd, argv, environ, usedpaths, + pid = spawnvppe_pipe(cmd, argv, (const char**) environ, usedpaths, pin, pout); argv[0] = tmp; diff --git a/fetch-pack.c b/fetch-pack.c index e6abf1625a..b6470932fb 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -512,7 +512,7 @@ static int get_pack(int xd[2]) if (read_pack_header(fd[0], &header)) die("protocol error: bad pack header"); - snprintf(hdr_arg, sizeof(hdr_arg), "--pack_header=%u,%u", + snprintf(hdr_arg, sizeof(hdr_arg), "--pack_header=%lu,%lu", ntohl(header.hdr_version), ntohl(header.hdr_entries)); if (ntohl(header.hdr_entries) < unpack_limit) do_keep = 0; diff --git a/index-pack.c b/index-pack.c index 8403c36b63..32e9dd99df 100644 --- a/index-pack.c +++ b/index-pack.c @@ -141,7 +141,7 @@ static void parse_pack_header(void) if (hdr->hdr_signature != htonl(PACK_SIGNATURE)) die("pack signature mismatch"); if (!pack_version_ok(hdr->hdr_version)) - die("pack version %d unsupported", ntohl(hdr->hdr_version)); + die("pack version %lu unsupported", ntohl(hdr->hdr_version)); nr_objects = ntohl(hdr->hdr_entries); use(sizeof(struct pack_header)); diff --git a/merge-index.c b/merge-index.c index fa719cb0b1..1cf4cb5b3f 100644 --- a/merge-index.c +++ b/merge-index.c @@ -48,7 +48,7 @@ static int merge_entry(int pos, const char *path) break; found++; strcpy(hexbuf[stage], sha1_to_hex(ce->sha1)); - sprintf(ownbuf[stage], "%o", ntohl(ce->ce_mode)); + sprintf(ownbuf[stage], "%lo", ntohl(ce->ce_mode)); arguments[stage] = hexbuf[stage]; arguments[stage + 4] = ownbuf[stage]; } while (++pos < active_nr); diff --git a/pager.c b/pager.c index a55f4e9d1e..4048894734 100644 --- a/pager.c +++ b/pager.c @@ -88,7 +88,7 @@ void setup_pager(void) #else /* spawn the pager */ pager_argv[2] = pager; - pager_pid = spawnvpe_pipe(pager_argv[0], pager_argv, environ, fd, NULL); + pager_pid = spawnvpe_pipe(pager_argv[0], pager_argv, (const char**) environ, fd, NULL); if (pager_pid < 0) return; diff --git a/read-cache.c b/read-cache.c index abc41561df..849e8d6b0f 100644 --- a/read-cache.c +++ b/read-cache.c @@ -149,7 +149,7 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st) changed |= DATA_CHANGED; return changed; default: - die("internal error: ce_mode is %o", ntohl(ce->ce_mode)); + die("internal error: ce_mode is %lo", ntohl(ce->ce_mode)); } if (ce->ce_mtime.sec != htonl(st->st_mtime)) changed |= MTIME_CHANGED; diff --git a/receive-pack.c b/receive-pack.c index d3c422be58..94bc99b40d 100644 --- a/receive-pack.c +++ b/receive-pack.c @@ -352,7 +352,7 @@ static const char *unpack(void) hdr_err = parse_pack_header(&hdr); if (hdr_err) return hdr_err; - snprintf(hdr_arg, sizeof(hdr_arg), "--pack_header=%u,%u", + snprintf(hdr_arg, sizeof(hdr_arg), "--pack_header=%lu,%lu", ntohl(hdr.hdr_version), ntohl(hdr.hdr_entries)); if (ntohl(hdr.hdr_entries) < unpack_limit) { diff --git a/run-command.c b/run-command.c index 5964e7d4dd..f208ed45fa 100644 --- a/run-command.c +++ b/run-command.c @@ -14,7 +14,7 @@ int start_command(struct child_process *cmd) int need_in, need_out; int fdin[2] = { -1, -1 }; int fdout[2] = { -1, -1 }; - char **env = environ; + const char **env = (const char **) environ; need_in = !cmd->no_stdin && cmd->in < 0; if (need_in) { @@ -75,7 +75,7 @@ int start_command(struct child_process *cmd) if (cmd->git_cmd) { cmd->pid = spawnv_git_cmd(cmd->argv, fdin, fdout); } else { - cmd->pid = spawnvpe_pipe(cmd->argv[0], cmd->argv, env, fdin, fdout); + cmd->pid = spawnvpe_pipe(cmd->argv[0], cmd->argv, (const char**) env, fdin, fdout); } } if (cmd->pid < 0) { diff --git a/sha1_file.c b/sha1_file.c index 4629fe81a4..1e3cf60ca0 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -425,15 +425,17 @@ static size_t peak_pack_mapped; static size_t pack_mapped; struct packed_git *packed_git; +extern size_t getpagesize(); + void pack_report(void) { fprintf(stderr, "pack_report: getpagesize() = %10" SZ_FMT "\n" "pack_report: core.packedGitWindowSize = %10" SZ_FMT "\n" "pack_report: core.packedGitLimit = %10" SZ_FMT "\n", - (size_t) getpagesize(), - packed_git_window_size, - packed_git_limit); + (unsigned long) getpagesize(), + (unsigned long) packed_git_window_size, + (unsigned long) packed_git_limit); fprintf(stderr, "pack_report: pack_used_ctr = %10u\n" "pack_report: pack_mmap_calls = %10u\n" @@ -443,7 +445,8 @@ void pack_report(void) pack_used_ctr, pack_mmap_calls, pack_open_windows, peak_pack_open_windows, - pack_mapped, peak_pack_mapped); + (unsigned long) pack_mapped, + (unsigned long) peak_pack_mapped); } static int check_packed_git_idx(const char *path, struct packed_git *p) @@ -634,7 +637,6 @@ static int open_packed_git_1(struct packed_git *p) struct pack_header hdr; unsigned char sha1[20]; unsigned char *idx_sha1; - long fd_flag; if (!p->index_data && open_pack_index(p)) return error("packfile %s index unavailable", p->pack_name); @@ -669,13 +671,13 @@ static int open_packed_git_1(struct packed_git *p) if (hdr.hdr_signature != htonl(PACK_SIGNATURE)) return error("file %s is not a GIT packfile", p->pack_name); if (!pack_version_ok(hdr.hdr_version)) - return error("packfile %s is version %u and not supported" + return error("packfile %s is version %lu and not supported" " (try upgrading GIT to a newer version)", p->pack_name, ntohl(hdr.hdr_version)); /* Verify the pack matches its index. */ if (p->num_objects != ntohl(hdr.hdr_entries)) - return error("packfile %s claims to have %u objects" + return error("packfile %s claims to have %lu objects" " while index indicates %u objects", p->pack_name, ntohl(hdr.hdr_entries), p->num_objects); diff --git a/show-index.c b/show-index.c index 57ed9e87b7..6943e4bbb3 100644 --- a/show-index.c +++ b/show-index.c @@ -68,7 +68,7 @@ int main(int argc, char **argv) ntohl(off64[1]); off64_nr++; } - printf("%llu %s (%08x)\n", (unsigned long long) offset, + printf("%llu %s (%08lx)\n", (unsigned long long) offset, sha1_to_hex(entries[i].sha1), ntohl(entries[i].crc)); } diff --git a/spawn-pipe.c b/spawn-pipe.c index c8f0452823..e8872dc0ff 100644 --- a/spawn-pipe.c +++ b/spawn-pipe.c @@ -1,8 +1,6 @@ #include "git-compat-util.h" #include "spawn-pipe.h" -extern char **environ; - #ifdef __MINGW32__ static char *lookup_prog(const char *dir, const char *cmd, int tryexe) { @@ -193,7 +191,7 @@ int spawnvppe_pipe(const char *cmd, const char **argv, const char **env, qargv = xmalloc((argc+2)*sizeof(char*)); if (!interpr) { quote_argv(qargv, argv); - pid = spawnve(_P_NOWAIT, prog, qargv, env); + pid = spawnve(_P_NOWAIT, prog, qargv, (const char**) env); } else { qargv[0] = interpr; argv[0] = prog; @@ -219,7 +217,7 @@ int spawnvppe_pipe(const char *cmd, const char **argv, const char **env, const char **copy_environ() { - return copy_env(environ); + return copy_env( (const char**)environ); } const char **copy_env(const char **env) diff --git a/unpack-trees.c b/unpack-trees.c index dfd985b0ef..d017f667ce 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -638,7 +638,7 @@ static void show_stage_entry(FILE *o, if (!ce) fprintf(o, "%s (missing)\n", label); else - fprintf(o, "%s%06o %s %d\t%s\n", + fprintf(o, "%s%06lo %s %d\t%s\n", label, ntohl(ce->ce_mode), sha1_to_hex(ce->sha1),