[OpenSmalltalk/opensmalltalk-vm] 14b6d3: Fix suspiscious logical construction

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[OpenSmalltalk/opensmalltalk-vm] 14b6d3: Fix suspiscious logical construction

Eliot Miranda-3
 
  Branch: refs/heads/Cog
  Home:   https://github.com/OpenSmalltalk/opensmalltalk-vm
  Commit: 14b6d3645d44e1b69301d5b477d514a1dfb0d1fa
      https://github.com/OpenSmalltalk/opensmalltalk-vm/commit/14b6d3645d44e1b69301d5b477d514a1dfb0d1fa
  Author: Nicolas Cellier <[hidden email]>
  Date:   2018-12-10 (Mon, 10 Dec 2018)

  Changed paths:
    M platforms/win32/plugins/SocketPlugin/sqWin32NewNet.c

  Log Message:
  -----------
  Fix suspiscious logical construction

In code we find this flag:

    #define SOCK_BOUND_UDP     0x00040000

and test of this flag in socket state:

    if(pss->sockState & SOCK_BOUND_UDP)

We also find the negation:

    if(!pss->sockState & SOCK_BOUND_UDP)

But there is a precedenc eproblem in above expression, as reported by the compiler

    ../../platforms/win32/plugins/SocketPlugin/sqWin32NewNet.c:872:8: warning: logical not is only applied to the left hand side of this bitwise operator [-Wlogical-not-parentheses]
  if(!pss->sockState & SOCK_BOUND_UDP) {
     ^               ~
    ../../platforms/win32/plugins/SocketPlugin/sqWin32NewNet.c:872:8: note: add parentheses after the '!' to evaluate the bitwise operator first
  if(!pss->sockState & SOCK_BOUND_UDP) {
     ^
      (                              )
    ../../platforms/win32/plugins/SocketPlugin/sqWin32NewNet.c:872:8: note: add parentheses around left hand side expression to silence this warning
  if(!pss->sockState & SOCK_BOUND_UDP) {
     ^
     (              )

Above code is interpreted as  `if( (!pss->sockState) & SOCK_BOUND_UDP)` which does not mean much...

Please, read C compiler warnings, they are a companion tool !



      **NOTE:** This service has been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/

      Functionality will be removed from GitHub.com on January 31st, 2019.