Mailing List Archive

Patch: fix ath_mutex_destroy
Hi,

As Marcus Brinkmann asked, here is the patch against ath_mutex_destroy().

New function code:
======================== 8< ================================
int
ath_mutex_destroy (ath_mutex_t *lock)
{
int err;
if (!ops_set || !ops.mutex_destroy)
return 0;

/* if mutex isn't initialiased, just exit */
(*ops.mutex_lock) (&check_init_lock);
if (*lock == ATH_MUTEX_INITIALIZER) {
(*ops.mutex_unlock) (&check_init_lock);
return 0;
}
(*ops.mutex_unlock) (&check_init_lock);

err = (*ops.mutex_destroy) (lock);
#ifndef NDEBUG
assert (*lock == MUTEX_UNLOCKED);
*lock = MUTEX_DESTROYED;
#endif
return err;
}
======================== 8< ================================

Main change: if the lock is not initialized, just skip the function.

Victor Stinner
Re: Patch: fix ath_mutex_destroy [ In reply to ]
At Mon, 10 Jul 2006 10:16:55 +0200 (CEST),
haypo@inl.fr wrote:
>
> As Marcus Brinkmann asked, here is the patch against ath_mutex_destroy().

I put in a slightly different change. Here are a couple of
suggestions: Keep the coding style according to the surrounding code
(or use the GNU coding standard, which is the same in this case). Do
not make gratuitous style changes. In this case, the admittedly
awkward layout of the user-specific path vs the generic path is
consistent across the file. It is helpful if you submit a changelog
entry as well.

Thanks,
Marcus

2006-07-12 Marcus Brinkmann <marcus@g10code.de>

* ath.c (ath_mutex_destroy): Microoptimize destruction of unused
statitically initialized mutexes. Suggested by Victor Stinner
<haypo@inl.fr>.


_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel