Skip to content

Commit 2ac5f42

Browse files
authored
Merge pull request #2184 from dscho/address-coverity-report
Fix some issues reported by Coverity
2 parents 65f1570 + 32b5d74 commit 2ac5f42

File tree

8 files changed

+20
-11
lines changed

8 files changed

+20
-11
lines changed

add-patch.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ static void err(struct add_p_state *s, const char *fmt, ...)
218218
vfprintf(stderr, fmt, args);
219219
fputs(s->s.reset_color, stderr);
220220
fputc('\n', stderr);
221+
va_end(args);
221222
}
222223

223224
static void setup_child_process(struct child_process *cp,

builtin/bisect--helper.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,10 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout,
571571
write_file(git_path_bisect_start(), "%s\n", start_head.buf);
572572

573573
if (no_checkout) {
574-
get_oid(start_head.buf, &oid);
574+
if (get_oid(start_head.buf, &oid) < 0) {
575+
retval = error(_("invalid ref: '%s'"), start_head.buf);
576+
goto finish;
577+
}
575578
if (update_ref(NULL, "BISECT_HEAD", &oid, NULL, 0,
576579
UPDATE_REFS_MSG_ON_ERR)) {
577580
retval = -1;

builtin/rebase--interactive.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ static int get_revision_ranges(const char *upstream, const char *onto,
3333
const char *shortrev;
3434
struct object_id rev_oid;
3535

36-
get_oid(base_rev, &rev_oid);
36+
if (get_oid(base_rev, &rev_oid) < 0)
37+
return error(_("invalid rev '%s'"), base_rev);
3738
shortrev = find_unique_abbrev(&rev_oid, DEFAULT_ABBREV);
3839

3940
*shortrevisions = xstrfmt("%s..%s", shortrev, shorthead);

builtin/rebase.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ static int rebase_config(const char *var, const char *value, void *data)
848848
if (git_config_bool(var, value))
849849
opts->flags |= REBASE_DIFFSTAT;
850850
else
851-
opts->flags &= !REBASE_DIFFSTAT;
851+
opts->flags &= ~REBASE_DIFFSTAT;
852852
return 0;
853853
}
854854

ci/lib.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,12 @@ then
116116
CI_OS_NAME="$(echo "$AGENT_OS" | tr A-Z a-z)"
117117
test darwin != "$CI_OS_NAME" || CI_OS_NAME=osx
118118
CI_REPO_SLUG="$(expr "$BUILD_REPOSITORY_URI" : '.*/\([^/]*/[^/]*\)$')"
119+
jobs=10
119120
if test -n "$MSVC"
120121
then
121122
CC=compat/vcbuild/scripts/clink.pl
122123
jobname=windows-msvc
124+
jobs=4
123125
fi
124126
CC="${CC:-gcc}"
125127

@@ -132,9 +134,9 @@ then
132134
}
133135

134136
BREW_INSTALL_PACKAGES=gcc@8
135-
export GIT_PROVE_OPTS="--timer --jobs 10 --state=failed,slow,save"
137+
export GIT_PROVE_OPTS="--timer --jobs $jobs --state=failed,slow,save"
136138
export GIT_TEST_OPTS="--verbose-log -x --write-junit-xml"
137-
MAKEFLAGS="$MAKEFLAGS --jobs=10"
139+
MAKEFLAGS="$MAKEFLAGS --jobs=$jobs"
138140
test windows_nt != "$CI_OS_NAME" ||
139141
GIT_TEST_OPTS="--no-chain-lint --no-bin-wrappers $GIT_TEST_OPTS"
140142
else

compat/win32/fscache.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,8 @@ static struct fsentry *fsentry_create_list(struct fscache *cache, const struct f
309309
return list;
310310

311311
Error:
312-
errno = (status == ERROR_DIRECTORY) ? ENOTDIR : err_win_to_posix(status);
313-
trace_printf_key(&trace_fscache, "fscache: error(%d) unable to query directory contents '%.*s'\n",
314-
errno, dir->len, dir->name);
312+
trace_printf_key(&trace_fscache, "fscache: status(%ld) unable to query directory contents '%.*s'\n",
313+
status, dir->len, dir->name);
315314
CloseHandle(h);
316315
fsentry_release(list);
317316
return NULL;
@@ -454,8 +453,10 @@ int fscache_enable(size_t initial_size)
454453
if (!initialized) {
455454
if (!dwTlsIndex) {
456455
dwTlsIndex = TlsAlloc();
457-
if (dwTlsIndex == TLS_OUT_OF_INDEXES)
456+
if (dwTlsIndex == TLS_OUT_OF_INDEXES) {
457+
LeaveCriticalSection(&fscache_cs);
458458
return 0;
459+
}
459460
}
460461

461462
/* redirect opendir and lstat to the fscache implementations */

entry.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ static int write_entry(struct cache_entry *ce,
289289
if (!has_symlinks || to_tempfile)
290290
goto write_file_entry;
291291

292-
ret = create_symlink(state ? state->istate : NULL, new_blob, path);
292+
ret = create_symlink(state->istate, new_blob, path);
293293
free(new_blob);
294294
if (ret)
295295
return error_errno("unable to create symlink %s", path);

sequencer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4884,7 +4884,8 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
48844884
struct object_id oid;
48854885
struct stat st;
48864886

4887-
get_oid(onto, &oid);
4887+
if (get_oid(onto, &oid) < 0)
4888+
return error(_("invalid rev: '%s'"), onto);
48884889
shortonto = find_unique_abbrev(&oid, DEFAULT_ABBREV);
48894890

48904891
if (!lstat(todo_file, &st) && st.st_size == 0 &&

0 commit comments

Comments
 (0)