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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/24/2019 10:01 PM, Alex Henrie wrote:
> Signed-off-by: Alex Henrie <alexhenrie24@xxxxxxxxx>
> ---
>  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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux