[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r23993 - trunk/subversion/bindings/java/javahl/native

From: Hyrum K. Wright <hyrum_wright_at_mail.utexas.edu>
Date: 2007-07-23 13:32:55 CEST

Blair Zajac wrote:
>
> On Mar 21, 2007, at 6:42 PM, hwright@tigris.org wrote:
>
>> Author: hwright
>> Date: Wed Mar 21 18:42:31 2007
>> New Revision: 23993
>>
>> Log:
>> JavaHL: Introduce a macro to check for NULL pointers in the C++ layer and
>> throw the appropriate Java exception.
>>
>> * subversion/bindings/java/javahl/native/SVNBase.
>> (SVN_JNI_NULL_PTR_EX): New macro, styled after SVN_ERR(), which checks
>> its arguments for NULL, and throws a NullPointerException if so.
>>
>> * subversion/bindings/java/javahl/native/SVNClient.cpp,
>> subversion/bindings/java/javahl/native/SVNAdmin.cpp:
>> Use the new macro to check for null pointers.
>>
>>
>> Modified:
>> trunk/subversion/bindings/java/javahl/native/SVNAdmin.cpp
>> trunk/subversion/bindings/java/javahl/native/SVNBase.h
>> trunk/subversion/bindings/java/javahl/native/SVNClient.cpp
>>
>
>
>
>> +
>> +/**
>> + * A statement macro used for checking NULL pointers, in the style of
>> + * SVN_ERR().
>> + *
>> + * Evaluate @a expr. If it equals NULL, throw an
>> NullPointerException with
>> + * the value @a str, and return the @a ret_val. Otherwise, continue.
>> + *
>> + * Note that if the enclosing function returns <tt>void</tt>, @a
>> ret_val may
>> + * be blank.
>> + */
>> +
>> +#define SVN_JNI_NULL_PTR_EX(expr, str, ret_val) \
>> + if (expr == NULL) { \
>> + JNIUtil::throwNullPointerException(str); \
>> + return ret_val ; \
>> + }
>> +
>> //
>> !defined(AFX_SVNBASE_H__ABF82C7E_0C50_40EA_8C88_2DFDF20B3A47__INCLUDED_)
>> #endif
>>
>
> Shouldn't we put this in the do { } while(0) loop, otherwise we replace
> this
>
> SVN_JNI_NULL_PTR_EX(path, "path", );
>
> with
>
> if (path == NULL) {
> JNIUtil::throwNullPointerException("path");
> return ;
> };
>
> with the trailing ; at the end of the } ?
>
> Don't some compilers complain about empty statements?

We can use a do { } while(0) wrapper. Do we have any examples of
compilers complaining here, or is this a theoretical problem?

-Hyrum

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Jul 23 13:28:14 2007

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.