apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cliff Woolley <jwool...@virginia.edu>
Subject Re: [PATCH] Fix assumptions about value of APR_SUCCESS being zero
Date Mon, 27 Dec 2004 18:23:30 GMT
On Mon, 27 Dec 2004, Mihai Limbasan wrote:

> In reply to my earlier question - went ahead and did it.
> What this patch does is fix all conditionals that depend implicitely
> on APR_SUCCESS being zero to perform an explicit test against its
> *macro definition* and not against the numeric literal or the C
> expression evaluation.

Mostly looks okay to me, but as we've already established, there's a bit
of disagreement among the developers as to which version (the original or
the patched) is preferable.  ;)

> generate the same code, and in the few cases where I added something a
> la rv = rv ? rv : APR_SUCCESS any optimizer will happily remove the
> small redundancy.

These constructs I wasn't such a fan of.

One that seemed particularly pointless was this one:

@@ -32,7 +34,8 @@

     (*key)->pool = pool;

-    return pthread_key_create(&(*key)->key, dest);
+    rv = pthread_key_create(&(*key)->key, dest);
+    return rv ? rv : APR_SUCCESS;


Just return it.  You don't have to try to convert the return value into an
apr_status_t somehow... the equivalence of retvals is provided for within
the definition of apr_status_t.  Just pretend that pthread_key_create()
returns an apr_status_t.


View raw message