Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4118333

NET_ERROR bad macro usage

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.1.4
    • core-libs
    • beta
    • sparc
    • solaris_2.5.1



      Name: mf23781 Date: 03/10/98


      This is a bug seen by looking at the source code.

      In src/unix/net/socket.c in JDK 1.1.4 there is
      a macro called NET_ERROR() defined.

      The definition is as follows:

      ============================================
      #define NET_ERROR(_ee, _ex, _msg) if (!exceptionOccurred(EE())) SignalError(_ee, _ex, _msg)
      ============================================

      This is prone to the classic macro bug of wrong binding
      to the "else" in an "if() else" clause if curly braces are
      not used:

      if (predicate)
      NET_ERROR();
      else
      somethingElse();

      The else binds to the if() of the macro which is not intended.

      There are several instances where there this occurs in
      socket.c eg in
      java_net_PlainSocketImpl_socketAccept() for one.

      NET_ERROR() should either be defined protectively eg
      with "do { } while (0)" construct, or all using instances
      should ensure curly braces.

      ======================================================================

            ywangsunw Yingxian Wang (Inactive)
            miflemi Mick Fleming
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: