This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA/JVMTI] New JVMTI Environment Initialization/Allocation


Tom Tromey writes:
 > >>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:
 > 
 > Keith> I've also snuck in another little patch which adds another common test
 > Keith> macro, this time for JVMTI_ERROR_ILLEGAL_ARGUMENT.
 > 
 > I noticed that this macro has no trailing ';' but NULL_CHECK does have
 > one.  The semicolon should probably be removed from NULL_CHECK.

These macros are dangerous because of hidden dangling else:

#define NULL_CHECK(Ptr)					\
  if (Ptr == NULL) return JVMTI_ERROR_NULL_POINTER;

They should be, e.g.,

#define NULL_CHECK(Ptr)
do						\
  {						\
    if (Ptr == NULL)				\
      return JVMTI_ERROR_NULL_POINTER;		\
  }						\
while (0)

Otherwise, something like

  if (poo)
    NULL_CHECK (p);
  else
    barf ();

may not do as you expected.

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]