"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: Fix llvm 13 warning/error
To:
Christian Weisgerber <naddy@mips.inka.de>
Cc:
gameoftrees@openbsd.org
Date:
Wed, 27 Oct 2021 15:34:46 +0200

Download raw body.

Thread
On Wed, Oct 27, 2021 at 01:23:50PM +0200, Christian Weisgerber wrote:
> LLVM 13 complains about two variables that are set but never read:
> 
> ------------------->
> cc -O2 -pipe -O0 -g -Werror -Wall -Wstrict-prototypes -Wunused-variable  -MD -MP -I/home/naddy/got/got/../include -I/home/naddy/got/got/../lib -DGOT_LIBEXECDIR=/home/naddy/bin -DGOT_VERSION=0.64-current -c /home/naddy/got/got/../lib/blame.c
> /home/naddy/got/got/../lib/blame.c:127:16: error: variable 'left_start' set but not used [-Werror,-Wunused-but-set-variable]
>                 unsigned int left_start, left_count;
>                              ^
> /home/naddy/got/got/../lib/blame.c:128:16: error: variable 'right_start' set but not used [-Werror,-Wunused-but-set-variable]
>                 unsigned int right_start, right_count;
>                              ^
> 2 errors generated.
> *** Error 1 in got (<sys.mk>:87 'blame.o')
> <-------------------
> 
> I think we can simply delete those variables and the function calls
> that assign values to them.  Or does diff_chunk_get_*_start() have
> any side effects that we need?  The regression tests don't show any
> problems.
> 

Should be fine. ok stsp@

> diff refs/heads/main refs/heads/llvm13
> blob - 783c434b33577727fafbf7589d751e7601a9dcf7
> blob + d2db8c1e2cd6a46130821551a293b51fa2c841b9
> --- lib/blame.c
> +++ lib/blame.c
> @@ -124,8 +124,7 @@ blame_changes(struct got_blame *blame, struct diff_res
>  	for (i = 0; i < diff_result->chunks.len &&
>  	    blame->nannotated < blame->nlines; i++) {
>  		struct diff_chunk *c = diff_chunk_get(diff_result, i);
> -		unsigned int left_start, left_count;
> -		unsigned int right_start, right_count;
> +		unsigned int left_count, right_count;
>  		int j;
>  
>  		/*
> @@ -134,9 +133,7 @@ blame_changes(struct got_blame *blame, struct diff_res
>  		 * that chunk ranges never exceed the number of lines
>  		 * in the left/right input files.
>  		 */
> -		left_start = diff_chunk_get_left_start(c, diff_result, 0);
>  		left_count = diff_chunk_get_left_count(c);
> -		right_start = diff_chunk_get_right_start(c, diff_result, 0);
>  		right_count = diff_chunk_get_right_count(c);
>  
>  		if (left_count == right_count) {
> -- 
> Christian "naddy" Weisgerber                          naddy@mips.inka.de
> 
>