git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] blame: report correct number of lines in progress when using ranges

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 4, 2022, 16:34 UTC
Message-ID
<xmqq5ynost82.fsf@gitster.g>
In-Reply-To
<220404.8635itl6h0.gmgdl@evledraar.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 13 quoted lines
>> diff --git a/builtin/blame.c b/builtin/blame.c
>> index 8d15b68afc..e33372c56b 100644
>> --- a/builtin/blame.c
>> +++ b/builtin/blame.c
>> @@ -898,6 +898,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
>>  	unsigned int range_i;
>>  	long anchor;
>>  	const int hexsz = the_hash_algo->hexsz;
>> +	long num_lines = 0;
>
> Here ranges's nr is unsigned int, and the "num_lines" is an int, and the
> argument to start_delayed_progress() is uint64_t, but both of "start"
> and "end" are "long".

I see num_lines is a long, which I am guessing was made to match what start and end are, which in turn is to use parse_range_arg().

> But we appand multiple differences to num_lines, are we sure we won't
> overflow here?

Looking at members of blame_entry and blame_scoreboard structures, I think we make liberal use of "int" in the blame codepath without worrying about those with 16-bit int, or those with files longer than 2G lines, and progress meter showing incorrect values to them is probably the least of our worries ;-)

Previous: Ævar Arnfjörð Bjarmason
Message 6 of 6 in “blame: report correct number of lines in progress when using ranges”
  1. blame: report correct number of lines in progress when using rangesEdmundo Carmona Antoranz, Apr 3, 2022
  2. Junio C HamanoApr 3, 2022
  3. Edmundo Carmona AntoranzApr 4, 2022
  4. Ævar Arnfjörð BjarmasonApr 4, 2022
  5. Ævar Arnfjörð BjarmasonApr 4, 2022
  6. Junio C HamanoApr 4, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.