9756 tests: badseg.c error: variable 'rc' set but not used

Review Request #1171 — Created Aug. 18, 2018 and submitted

tsoome
illumos-gate
9756
7862fdb...
general
badseg.c: In function 'resetseg':
badseg.c:62:6: error: variable 'rc' set but not used [-Werror=unused-but-set-variable]
  int rc = getcontext(&ucp);
      ^~
cc1: all warnings being treated as errors

build is OK...

  • 0
  • 0
  • 2
  • 0
  • 2
Description From Last Updated
marcel
  1. 
      
  2. Here 'volatile' is missing.

  3. variable 'rc' set but not used. Why do we need this call at all?

    1. The getcontext() function initializes the structure pointed to by ucp
      to the current user context of the calling process.  The ucontext_t
      type that ucp points to defines the user context and includes the
      contents of the calling process' machine registers, the signal mask,
      and the current execution stack.
      

      The manual is a bit confusing there as it is also referring to makecontext, but also makecontext is expecting the context initialized by getcontext.

    2. Okay, but why do we need to call getcontext() here?

    3. I think, thats the question for original author:)

    4. Then: variables 'rc' and 'ucp' set but not used. While you are fixing one similar case in this function, please fix this other case too. Thanks.

    5. Thats not what compiler is telling us, especially since ucp is used with both getcontext() and setcontext().

    6. Both rc and ucp set at line 62 are used, but line 64 looks like a noop. Or, do I miss something?

    7. lines 70 and 71?:)

    8. Lines 70 and 71 uses rc and ucp set at line 62, but not those set at line 64, IMHO. Once you reached line 64 you will just return with unused rc and ucp and there seems to be no way how you can reach lines 70 and 71 from here. If there is, please explain how. Thanks.

    9. Ah, I see what you mean, well, in case of "done", this code is just calling the getcontext() and obviously we are just trying to see if we will crash during the call. Anyhow, we really only care about not calling setcontext() when ucp is in fact not set up and incidentally this also will calm the compiler.

    10. Hm, I thought the possible crash would happen during setcontext(), not setcontext(). To avoid confusion this deserves some comment (and replacement of rc = by (void)).

    11. I'd leave commenting for original author:D but void cast is fair suggestion, done.

  4. 
      
tsoome
jlevon
  1. Ship It!
  2. 
      
marcel
  1. Ship It!
  2. 
      
tsoome
tsoome
Review request changed

Status: Closed (submitted)

Loading...