VLC 2.1.0

Tijl Coosemans tijl at FreeBSD.org
Wed Oct 23 10:12:42 UTC 2013


On Tue, 22 Oct 2013 23:23:27 +0200 Jilles Tjoelker wrote:
> On Tue, Oct 22, 2013 at 05:47:15PM +0200, Tijl Coosemans wrote:
>> Summarised: the idiom that VLC uses is this:
>> 
>> pthread_cleanup_push(...);
>> ...
>> if (error) goto cleanup;
>> ...
>> cleanup:
>> pthread_cleanup_pop(...);
>> 
>> Because the definition of the pthread_cleanup_pop macro starts with }
>> clang complains.
> 
> glibc has  do { } while (0);  at the start of the pthread_cleanup_pop
> define. I think this is a better option than  ;  or  (void)0;  as it
> minimizes the wrong things it can combine with.
> 
> Reading POSIX, it seems valid to put a label right before an invocation
> of pthread_cleanup_pop. In such a case, the invocation still appears as
> a statement and can be paired with a pthread_cleanup_push in the same
> lexical scope.
> 
> Therefore the following patch to src seems appropriate.
> 
> Index: include/pthread.h
> ===================================================================
> --- include/pthread.h	(revision 256728)
> +++ include/pthread.h	(working copy)
> @@ -175,6 +175,7 @@
>  			{
>  
>  #define		pthread_cleanup_pop(execute)					\
> +				do { } while (0);				\
>  			}							\
>  			__pthread_cleanup_pop_imp(execute);			\
>  		}

I had to think a bit about what could combine with (void)0; but not
do-while, but ?: can, so I agree.  I've extended your patch further
to force the use of ;.  Please review.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pthread_cleanup.patch
Type: text/x-patch
Size: 872 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-multimedia/attachments/20131023/6cdef475/attachment.bin>


More information about the freebsd-multimedia mailing list