8760 troff: variable 'type' set but not used

Review Request #701 — Created Nov. 4, 2017 and submitted

tsoome
illumos-gate
8760
13c81fc...
general

../n9.c: In function 'setdraw':
../n9.c:314:44: error: variable 'type' set but not used [-Werror=unused-but-set-variable]
int i, j, k, dx[NPAIR], dy[NPAIR], delim, type;
^~
cc1: all warnings being treated as errors



seeemef@mac.com
  1. Hi. The description also describes n6.c as affected, but it is not in the diff.

    1. aye, that one got fixed in "8485 Remove set but unused variables in usr/src/cmd".

  2. 
      
rm
  1. 
      
  2. usr/src/cmd/troff/n9.c (Diff revision 1)
     
     
    Maybe we should cast this to (void) rather than assign it to a variable, but leave a comment saying that this is important for making sure that we properly consume the input?
    1. I was considering it, but below is the code segment using type == DRAWELLIPSE and I would rather avoid going too invasive with this patch.

    2. Ah, I missed that. I guess we don't define NROFF?

    3. Actually we do, but only in nroff.d directory - the troff.d case does not define it.

  3. 
      
tsoome
tsoome
seeemef@mac.com
  1. LGTM

  2. 
      
yuripv
  1. Ship It!
  2. 
      
aeon
  1. Will we now get an error if we don't define NROFF, which will cause 'type' to be used?
    The "problem" is the warning there is not really an error.
    
    (FWIW, Heirloom's troff added type DRAWPOLYGON in addition to type DRAWELLIPSE, plus type DRAWTHICKNESS.)
    
    -- John
    1. Technically it is warning, just that we do interpret all warnings as errors. And indeed, in case of nroff, we wont get that warning. However, since we do know this is an problem, we tell compiler to switch the warning off for this variable.

  2. 
      
aeon
  1. Ship It!
  2. 
      
tsoome
Review request changed

Status: Closed (submitted)

Loading...