forked from git/git
-
Notifications
You must be signed in to change notification settings - Fork 191
coverity: fix unchecked returns #2179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dscho
wants to merge
11
commits into
gitgitgadget:master
Choose a base branch
from
dscho:coverity-fixes-unchecked-returns
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e653255
http: die on curl_easy_duphandle failure in get_active_slot
dscho 0692704
config: propagate launch_editor() failure in show_editor()
dscho 9bf7e73
reftable/block: check deflateInit() return value
dscho 711671c
reftable tests: check reftable_table_init_ref_iterator() return
dscho f728be4
last-modified: handle repo_parse_commit() failures
dscho b31e032
compat/pread: check initial lseek for errors
dscho 1792042
transport-helper: check dup() return in get_exporter
dscho 13ddcce
transport-helper: warn when export-marks file cannot be finalized
dscho 17c382f
bisect: check strbuf_getline_lf return when reading terms
dscho c0827a7
bisect: check get_terms return at all call sites
dscho 2da452e
bisect: handle dup() failure when redirecting stdout
dscho File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -290,7 +290,8 @@ static void process_parent(struct last_modified *lm, | |
| { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Junio C Hamano wrote on the Git mailing list (how to reply to this email): "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:
> Skip unparsable commits by checking the return value and
> continuing to the next iteration (or returning early in
> process_parent). This matches the defensive pattern used in other
> revision walkers such as limit_list() and get_revision_internal().
> ...
> @@ -414,12 +415,14 @@ static int last_modified_run(struct last_modified *lm)
> * Otherwise, make sure that 'c' isn't reachable from anything
> * in the '--not' queue.
> */
> - repo_parse_commit(lm->rev.repo, c);
> + if (repo_parse_commit(lm->rev.repo, c))
> + continue;
Shouldn't this be
goto cleanup;
instead? 'n' pulled out of not_queue may be unparseable and when we
ignore it, don't we still want to clean up the active_paths slab for
commit 'c'?
> while ((n = prio_queue_get(¬_queue))) {
> struct commit_list *np;
>
> - repo_parse_commit(lm->rev.repo, n);
> + if (repo_parse_commit(lm->rev.repo, n))
> + continue;
>
> for (np = n->parents; np; np = np->next) {
> if (!(np->item->object.flags & PARENT2)) {There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Junio C Hamano wrote on the Git mailing list (how to reply to this email): Junio C Hamano <gitster@pobox.com> writes:
> "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
> writes:
> ...
>> - repo_parse_commit(lm->rev.repo, c);
>> + if (repo_parse_commit(lm->rev.repo, c))
>> + continue;
>
> Shouldn't this be
>
> goto cleanup;
>
> instead? 'n' pulled out of not_queue may be unparseable and when we
> ignore it, don't we still want to clean up the active_paths slab for
> commit 'c'?
--- >8 ---
Subject: [PATCH] fixup! last-modified: handle repo_parse_commit() failures
https://lore.kernel.org/git/xmqqldbdqciy.fsf@gitster.g/
'n' pulled out of not_queue may be unparseable and when we ignore
it, we still want to clean up the active_paths slab for commit 'c'.
diff --git a/builtin/last-modified.c b/builtin/last-modified.c
index fe012b0c2e..3846244dfc 100644
--- a/builtin/last-modified.c
+++ b/builtin/last-modified.c
@@ -416,7 +416,7 @@ static int last_modified_run(struct last_modified *lm)
* in the '--not' queue.
*/
if (repo_parse_commit(lm->rev.repo, c))
- continue;
+ goto cleanup;
while ((n = prio_queue_get(¬_queue))) {
struct commit_list *np; |
||
| struct bitmap *active_p; | ||
|
|
||
| repo_parse_commit(lm->rev.repo, parent); | ||
| if (repo_parse_commit(lm->rev.repo, parent)) | ||
| return; | ||
| active_p = active_paths_for(lm, parent); | ||
|
|
||
| /* | ||
|
|
@@ -414,12 +415,14 @@ static int last_modified_run(struct last_modified *lm) | |
| * Otherwise, make sure that 'c' isn't reachable from anything | ||
| * in the '--not' queue. | ||
| */ | ||
| repo_parse_commit(lm->rev.repo, c); | ||
| if (repo_parse_commit(lm->rev.repo, c)) | ||
| continue; | ||
|
|
||
| while ((n = prio_queue_get(¬_queue))) { | ||
| struct commit_list *np; | ||
|
|
||
| repo_parse_commit(lm->rev.repo, n); | ||
| if (repo_parse_commit(lm->rev.repo, n)) | ||
| continue; | ||
|
|
||
| for (np = n->parents; np; np = np->next) { | ||
| if (!(np->item->object.flags & PARENT2)) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Patrick Steinhardt wrote on the Git mailing list (how to reply to this email):