News for hackers. Stuff that matters.
Re:C++ Quiz by milliams on Thursday September 18, 2014 @10:00AM (#8335217)
The first question it asked me was:

  int SSL_shutdown(SSL *s)
  {
    if (s->handshake_func == 0)
    {
      SSLerr(SSL_F_SSL_SHUTDOWN, SSL_R_UNINITIALIZED);
      return -1;
    }

    if ((s != NULL) && !SSL_in_init(s))
      return(s->method->ssl_shutdown(s));
    else
      return(1);
    }
    ....
  }
so of course the first thing I noticed was the mismatched braces after the 'else'. The 'intended' error was elsewhere (and I agree with it) but to say that the brace isn't an error is a bit much given the sorts of problems that PVS is normally finding.
Re:C++ Quiz by shmerl on Thursday September 18, 2014 @10:29AM (#8335362)
It's hard to say about that, since there is ... which can contain anything (like for example another opening { ).

It's a good practice to always use braces with if / else even if it's just one line in them.

Re:C++ Quiz by _RPM on Thursday September 18, 2014 @11:27AM (#8335736)
I don't think you are right. Regardless if what is after that contained in the `...` wouldn't matter. A lone `{` or `}` would be a syntax error.
Re:C++ Quiz by shmerl on Thursday September 18, 2014 @11:42AM (#8335812)
As I said, it wouldn't be a syntax error if ... contained the matching { somewhere inside.

That lone } which seemingly belongs to if in this case would be closing the function.

Re:C++ Quiz by adm_hn on Thursday September 18, 2014 @11:49AM (#8335855)
They are talking about the } after the return, not the one after the ... i.e. else return(1); }
Re:C++ Quiz by shmerl on Thursday September 18, 2014 @12:46PM (#8336189)
Yes, that's what I understood. That } after return matches to the function opening {. So it's correct syntactically, but is wrong according to intention.
Re:C++ Quiz by rikkus on Thursday September 18, 2014 @11:49AM (#8335853)
Yes there's a typo / mispaste in the code there, but of course that wouldn't compile and they're not asking what wouldn't compile ('....' wouldn't compile either).