Skip to content

sectransp.c compiler errors since #8180 #8197

Closed

Description

@bagder

In #8180 we removed != NULL from the checks and now clang on macOS instead reports the errors below. It is not clear to me why.

vtls/sectransp.c:1000:6: error: address of function 'SecCertificateCopyLongDescription' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
  if(SecCertificateCopyLongDescription)
  ~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vtls/sectransp.c:1000:6: note: prefix with the address-of operator to silence this warning
  if(SecCertificateCopyLongDescription)
     ^
     &
vtls/sectransp.c:1007:6: error: address of function 'SecCertificateCopySubjectSummary' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
  if(SecCertificateCopySubjectSummary)
  ~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vtls/sectransp.c:1007:6: note: prefix with the address-of operator to silence this warning
  if(SecCertificateCopySubjectSummary)
     ^
     &
vtls/sectransp.c:1121:6: error: address of function 'SecItemCopyMatching' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
  if(SecItemCopyMatching && kSecClassIdentity) {
     ^~~~~~~~~~~~~~~~~~~ ~~
vtls/sectransp.c:1121:6: note: prefix with the address-of operator to silence this warning
  if(SecItemCopyMatching && kSecClassIdentity) {
     ^
     &
vtls/sectransp.c:1409:6: error: address of function 'SSLSetProtocolVersionMax' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
  if(SSLSetProtocolVersionMax) {
  ~~ ^~~~~~~~~~~~~~~~~~~~~~~~
vtls/sectransp.c:1409:6: note: prefix with the address-of operator to silence this warning
  if(SSLSetProtocolVersionMax) {
     ^
     &
vtls/sectransp.c:1691:6: error: address of function 'SSLCreateContext' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
  if(SSLCreateContext) {  /* use the newer API if available */
  ~~ ^~~~~~~~~~~~~~~~
vtls/sectransp.c:1691:6: note: prefix with the address-of operator to silence this warning
  if(SSLCreateContext) {  /* use the newer API if available */
     ^
     &
vtls/sectransp.c:1725:6: error: address of function 'SSLSetProtocolVersionMax' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
  if(SSLSetProtocolVersionMax) {
  ~~ ^~~~~~~~~~~~~~~~~~~~~~~~
vtls/sectransp.c:1725:6: note: prefix with the address-of operator to silence this warning
  if(SSLSetProtocolVersionMax) {
     ^
     &
vtls/sectransp.c:1983:6: error: address of function 'SSLSetSessionOption' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
  if(SSLSetSessionOption && darwinver_maj >= 13) {
     ^~~~~~~~~~~~~~~~~~~ ~~
vtls/sectransp.c:1983:6: note: prefix with the address-of operator to silence this warning
  if(SSLSetSessionOption && darwinver_maj >= 13) {
     ^
     &
vtls/sectransp.c:2068:6: error: address of function 'SSLSetSessionOption' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
  if(SSLSetSessionOption) {
  ~~ ^~~~~~~~~~~~~~~~~~~
vtls/sectransp.c:2068:6: note: prefix with the address-of operator to silence this warning
  if(SSLSetSessionOption) {
     ^
     &
vtls/sectransp.c:2950:6: error: address of function 'SecTrustEvaluateAsync' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
  if(SecTrustEvaluateAsync) {
  ~~ ^~~~~~~~~~~~~~~~~~~~~
vtls/sectransp.c:2950:6: note: prefix with the address-of operator to silence this warning
  if(SecTrustEvaluateAsync) {
     ^
     &
vtls/sectransp.c:3168:8: error: address of function 'SSLCreateContext' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
    if(SSLCreateContext)
    ~~ ^~~~~~~~~~~~~~~~
vtls/sectransp.c:3168:8: note: prefix with the address-of operator to silence this warning
    if(SSLCreateContext)
       ^
       &
vtls/sectransp.c:3332:6: error: address of function 'SSLSetSessionOption' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
  if(SSLSetSessionOption)
  ~~ ^~~~~~~~~~~~~~~~~~~
vtls/sectransp.c:3332:6: note: prefix with the address-of operator to silence this warning
  if(SSLSetSessionOption)
     ^
     &
11 errors generated.

Activity

  1. jay commented on Dec 28, 2021

    @jay
    Member

    however it's being compiled I guess those function addresses are always going to evaluate as true. why it warns on that particular style but not if(func != NULL) or if(&func) I don't know. we had a similar constant expression warning with visual studio a while back and i disabled it entirely 9c1806a

  2. bagder commented on Dec 28, 2021

    @bagder
    MemberAuthor

    I believe adding -Wno-pointer-bool-conversion will do the job.

  3. added a commit that references this issue on Dec 28, 2021
    b210e43
  4. gvanem commented on Dec 29, 2021

    @gvanem
    Contributor

    why it warns on that particular style but not if(func != NULL) or if(&func) I don't know.

    Probably since those functions always exist and returns CFString values. Which could include a CFNull.

  5. bagder commented on Dec 29, 2021

    @bagder
    MemberAuthor

    My assumption has been that they aren't always present and that's why the check is there. Because why else check for it?

  6. nickzman commented on Dec 30, 2021

    @nickzman
    Member

    The checks for null in sectransp.c are there to check for a function's presence for weak-linking on old iOS and macOS versions. They have to be there; weak-linking doesn't work without the explicit check for null.

    A lot of those checks are quite old, though, and I wonder if many people care if we still support macOS 10.6. 10.6 was released over twelve years ago.

  7. bagder commented on Dec 30, 2021

    @bagder
    MemberAuthor

    I wonder if many people care if we still support macOS 10.6. 10.6 was released over twelve years ago.

    Everything older than 10 years are usually safe to drop, I think. Often we can draw the line earlier as well.

  8. mback2k commented on Jan 2, 2022

    @mback2k
    Member

    As mentioned in 21248e0#r62803533 this is also now triggering warning C4706: assignment within conditional expression.

  9. bagder commented on Jan 2, 2022

    @bagder
    MemberAuthor

    That is not the only assignment we do within a conditional expression in the source code, and the assignment was already there before we removed != NULL !!

    Can we perhaps just silence warning C4706 with MSVC?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions