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

Re: [PATCH 3/3] wrapper: use a loop instead of repetitive statements

From
Derrick Stolee <stolee@gmail.com>
Date
Sep 26, 2019, 13:13 UTC
Message-ID
<03e509db-942e-4538-4729-4e345df82a7e@gmail.com>
In-Reply-To
<20190925020158.751492-4-alexhenrie24@gmail.com>
On 9/24/2019 10:01 PM, Alex Henrie wrote:
Show 29 quoted lines
> Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
> ---
>  wrapper.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/wrapper.c b/wrapper.c
> index c55d7722d7..c23ac6adcd 100644
> --- a/wrapper.c
> +++ b/wrapper.c
> @@ -469,13 +469,12 @@ int git_mkstemps_mode(char *pattern, int suffix_len, int mode)
>  	filename_template = &pattern[len - 6 - suffix_len];
>  	for (count = 0; count < TMP_MAX; ++count) {
>  		uint64_t v = value;
> +		int i;
>  		/* Fill in the random bits. */
> -		filename_template[0] = letters[v % num_letters]; v /= num_letters;
> -		filename_template[1] = letters[v % num_letters]; v /= num_letters;
> -		filename_template[2] = letters[v % num_letters]; v /= num_letters;
> -		filename_template[3] = letters[v % num_letters]; v /= num_letters;
> -		filename_template[4] = letters[v % num_letters]; v /= num_letters;
> -		filename_template[5] = letters[v % num_letters]; v /= num_letters;
> +		for (i = 0; i < 6; i++) {
> +			filename_template[i] = letters[v % num_letters];
> +			v /= num_letters;
> +		}
>  
>  		fd = open(pattern, O_CREAT | O_EXCL | O_RDWR, mode);
>  		if (fd >= 0)
> 
This change is clear.

Thanks, -Stolee

Previous: Alex HenrieNext: Johannes Schindelin
Message 8 of 13 in “scan-build fixes”
  1. 0/3 scan-build fixesAlex Henrie, Sep 25, 2019
  2. 1/3 commit-graph: remove a duplicate assignmentAlex Henrie, Sep 25, 2019
  3. Derrick StoleeSep 26, 2019
  4. Alex HenrieSep 26, 2019
  5. 2/3 diffcore-break: use a goto instead of a redundant if statementAlex Henrie, Sep 25, 2019
  6. Derrick StoleeSep 26, 2019
  7. 3/3 wrapper: use a loop instead of repetitive statementsAlex Henrie, Sep 25, 2019
  8. Derrick StoleeSep 26, 2019
  9. Johannes SchindelinSep 26, 2019
  10. Jeff KingSep 27, 2019
  11. Alex HenrieSep 29, 2019
  12. Jeff KingSep 27, 2019
  13. Derrick StoleeSep 27, 2019

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.