8737 vi: variable set but not used

Review Request #688 — Created Oct. 27, 2017 and submitted

tsoome
illumos-gate
8737
2392b3b...
general
ex_vmain.c: In function 'vmain':
ex_vmain.c:620:19: error: variable 'tmp1' set but not used [-Werror=unused-but-set-variable]
     unsigned char tmp1;
                   ^~~~
ex_vmain.c:617:19: error: variable 'n' set but not used [-Werror=unused-but-set-variable]
     int tmp, len, n;
                   ^
cc1: all warnings being treated as errors


  • 0
  • 0
  • 1
  • 0
  • 1
Description From Last Updated
seeemef@mac.com
  1. 
      
  2. usr/src/cmd/vi/port/ex_vmain.c (Diff revision 1)
     
     
    For `n' I searched but truly did not find any usage past its assignment. Mightn't it be removed along with line 636?
  3. 
      
jgmills
  1. Yes, you should just remove the declaration of the variable n' along with the line that sets it.n' is truely unused. As well, the variable tmp1' is used only in the PRESUNEUC conditional case, although it's set just before the conditional. If you move the linetmp1 = mbuf[tmp_1]' down one line, so that it's just before where it is used, you can also move the declaration into the correct case. With those changes, you won't need to mark any variables as possibly unused.

    1. yep, this is much better, thanks.

  2. 
      
tsoome
seeemef@mac.com
  1. LGTM

  2. 
      
tsoome
Review request changed

Status: Closed (submitted)

Loading...