[MPlayer-dev-eng] cleanups of a few macros in Gui/
pl
p_l at gmx.fr
Mon Oct 8 14:53:40 CEST 2001
Hi,
Several macros don't use "()" around arguments or don't use a "do { }
while(0)" construction. It's not a real trouble since it works but it
may avoid future bugs :)
Attached is a few cleanups/fixes for the Gui/ subdir against CVS. It
should not break anything (well at least here it doesn't with gcc3).
--
Regards,
pl
-------------- next part --------------
Index: mplayer/mw.h
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/mplayer/mw.h,v
retrieving revision 1.27
diff -u -r1.27 mw.h
--- mplayer/mw.h 2 Oct 2001 15:01:36 -0000 1.27
+++ mplayer/mw.h 8 Oct 2001 12:37:53 -0000
@@ -204,7 +204,7 @@
XFlush( wsDisplay );
}
-#define IZE(x) printf("@@@ " x " @@@\n");
+#define IZE(x) do { printf("@@@ " x " @@@\n"); } while(0)
extern void exit_player(char* how);
Index: mplayer/psignal.c
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/mplayer/psignal.c,v
retrieving revision 1.15
diff -u -r1.15 psignal.c
--- mplayer/psignal.c 20 Sep 2001 10:27:24 -0000 1.15
+++ mplayer/psignal.c 8 Oct 2001 12:37:53 -0000
@@ -19,7 +19,7 @@
#include "./mplayer.h"
-#define gtkShow( w ) gtkShMem->vs.window=w; gtkSendMessage( evShowWindow );
+#define gtkShow( w ) do { gtkShMem->vs.window=(w); gtkSendMessage( evShowWindow ); } while(0)
pid_t mplMPlayerPID = 0;
pid_t mplParentPID = 0;
Index: skin/skin.c
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/skin/skin.c,v
retrieving revision 1.7
diff -u -r1.7 skin.c
--- skin/skin.c 1 Oct 2001 09:30:46 -0000 1.7
+++ skin/skin.c 8 Oct 2001 12:37:53 -0000
@@ -33,22 +33,22 @@
}
#define CHECKDEFLIST( str ) \
-{ \
+do { \
if ( defList == NULL ) \
{ \
- message( False,MSGTR_SKIN_WARNING1,linenumber,str ); \
+ message( False,MSGTR_SKIN_WARNING1,linenumber,(str) ); \
return 1; \
} \
-}
+} while (0)
#define CHECKWINLIST( str ) \
-{ \
+do { \
if ( !strlen( winList ) ) \
{ \
- message( False,MSGTR_SKIN_WARNING2,linenumber,str ); \
+ message( False,MSGTR_SKIN_WARNING2,linenumber,(str) ); \
return 1; \
} \
-}
+} while (0)
char * strlower( char * in )
{
Index: wm/widget.h
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/wm/widget.h,v
retrieving revision 1.2
diff -u -r1.2 widget.h
--- wm/widget.h 4 Oct 2001 20:33:29 -0000 1.2
+++ wm/widget.h 8 Oct 2001 12:37:53 -0000
@@ -1,3 +1,3 @@
-#define wgIsRect( X,Y,tX,tY,bX,bY ) ( ( X > tX )&&( Y > tY )&&( X < bX )&&( Y < bY ) )
+#define wgIsRect( X,Y,tX,tY,bX,bY ) ( ( (X) > (tX) )&&( (Y) > (tY) )&&( (X) < (bX) )&&( (Y) < (bY) ) )
Index: wm/ws.h
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/wm/ws.h,v
retrieving revision 1.7
diff -u -r1.7 ws.h
--- wm/ws.h 4 Oct 2001 20:33:29 -0000 1.7
+++ wm/ws.h 8 Oct 2001 12:37:53 -0000
@@ -204,7 +204,7 @@
extern void wsSetBackground( wsTWindow * win,int color );
extern void wsSetForegroundRGB( wsTWindow * win,int r,int g,int b );
extern void wsSetBackgroundRGB( wsTWindow * win,int r,int g,int b );
-#define wsClearWindow( win ); XClearWindow( wsDisplay,win.WindowID );
+#define wsClearWindow( win ) XClearWindow( wsDisplay,(win).WindowID )
extern void wsSetTitle( wsTWindow * win,char * name );
extern void wsVisibleWindow( wsTWindow * win,int show );
extern void wsWindowDecoration( wsTWindow * win,long d );
Index: wm/wsconv.c
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/wm/wsconv.c,v
retrieving revision 1.2
diff -u -r1.2 wsconv.c
--- wm/wsconv.c 4 Oct 2001 20:33:29 -0000 1.2
+++ wm/wsconv.c 8 Oct 2001 12:37:53 -0000
@@ -14,9 +14,9 @@
// ---
-#define COPY_RGB_24(src,dst) dst[0]=src[0];dst[1]=src[1];dst[2]=src[2]
+#define COPY_RGB_24(src,dst) do { (dst)[0]=(src)[0];(dst)[1]=(src)[1];(dst)[2]=(src)[2]; } while(0)
-#define SWAP_RGB_24(src,dst) dst[1]=src[0];dst[1]=src[1];dst[2]=src[0]
+#define SWAP_RGB_24(src,dst) do { (dst)[1]=(src)[0];(dst)[1]=(src)[1];(dst)[2]=(src)[0]; } while(0)
void BGR8880_to_RGB555_c( unsigned char * in_pixels, unsigned char * out_pixels, int num_pixels)
{
@@ -111,10 +111,10 @@
unsigned char * map_5_to_8[32];
unsigned char * map_6_to_8[64];
-#define POINTER_TO_GUINT16(a) *((unsigned short*)a)
-#define RGB16_TO_R(pixel) map_5_to_8[pixel & RGB16_LOWER_MASK]
-#define RGB16_TO_G(pixel) map_6_to_8[(pixel & RGB16_MIDDLE_MASK)>>5]
-#define RGB16_TO_B(pixel) map_5_to_8[(pixel & RGB16_UPPER_MASK)>>11]
+#define POINTER_TO_GUINT16(a) (*((unsigned short*)(a)))
+#define RGB16_TO_R(pixel) map_5_to_8[(pixel) & RGB16_LOWER_MASK]
+#define RGB16_TO_G(pixel) map_6_to_8[((pixel) & RGB16_MIDDLE_MASK)>>5]
+#define RGB16_TO_B(pixel) map_5_to_8[((pixel) & RGB16_UPPER_MASK)>>11]
#define RGB16_LOWER_MASK 0x001f
#define RGB16_MIDDLE_MASK 0x07e0
#define RGB16_UPPER_MASK 0xf800
Index: wm/wsconv.h
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/wm/wsconv.h,v
retrieving revision 1.2
diff -u -r1.2 wsconv.h
--- wm/wsconv.h 4 Oct 2001 20:33:29 -0000 1.2
+++ wm/wsconv.h 8 Oct 2001 12:37:53 -0000
@@ -4,17 +4,17 @@
#include "../../config.h"
-#define PACK_RGB16(r,g,b,pixel) pixel=(b>>3);\
+#define PACK_RGB16(r,g,b,pixel) do { pixel=(b>>3);\
pixel<<=6;\
pixel|=(g>>2);\
pixel<<=5;\
- pixel|=(r>>3)
+ pixel|=(r>>3); } while(0)
-#define PACK_RGB15(r,g,b,pixel) pixel=(b>>3);\
+#define PACK_RGB15(r,g,b,pixel) do { pixel=(b>>3);\
pixel<<=5;\
pixel|=(g>>3);\
pixel<<=5;\
- pixel|=(r>>3)
+ pixel|=(r>>3); } while(0)
typedef void(*wsTConvFunc)( unsigned char * in_pixels, unsigned char * out_pixels, int num_pixels );
extern wsTConvFunc wsConvFunc;
? .depend
? Gui-macros-cleanups.txt
? config.mak
? mplayer/.depend
Index: mplayer/mw.h
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/mplayer/mw.h,v
retrieving revision 1.27
diff -u -r1.27 mw.h
--- mplayer/mw.h 2 Oct 2001 15:01:36 -0000 1.27
+++ mplayer/mw.h 8 Oct 2001 12:44:45 -0000
@@ -204,7 +204,7 @@
XFlush( wsDisplay );
}
-#define IZE(x) printf("@@@ " x " @@@\n");
+#define IZE(x) do { printf("@@@ " x " @@@\n"); } while(0)
extern void exit_player(char* how);
Index: mplayer/psignal.c
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/mplayer/psignal.c,v
retrieving revision 1.15
diff -u -r1.15 psignal.c
--- mplayer/psignal.c 20 Sep 2001 10:27:24 -0000 1.15
+++ mplayer/psignal.c 8 Oct 2001 12:44:45 -0000
@@ -19,7 +19,7 @@
#include "./mplayer.h"
-#define gtkShow( w ) gtkShMem->vs.window=w; gtkSendMessage( evShowWindow );
+#define gtkShow( w ) do { gtkShMem->vs.window=(w); gtkSendMessage( evShowWindow ); } while(0)
pid_t mplMPlayerPID = 0;
pid_t mplParentPID = 0;
Index: skin/skin.c
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/skin/skin.c,v
retrieving revision 1.7
diff -u -r1.7 skin.c
--- skin/skin.c 1 Oct 2001 09:30:46 -0000 1.7
+++ skin/skin.c 8 Oct 2001 12:44:45 -0000
@@ -33,22 +33,22 @@
}
#define CHECKDEFLIST( str ) \
-{ \
+do { \
if ( defList == NULL ) \
{ \
- message( False,MSGTR_SKIN_WARNING1,linenumber,str ); \
+ message( False,MSGTR_SKIN_WARNING1,linenumber,(str) ); \
return 1; \
} \
-}
+} while (0)
#define CHECKWINLIST( str ) \
-{ \
+do { \
if ( !strlen( winList ) ) \
{ \
- message( False,MSGTR_SKIN_WARNING2,linenumber,str ); \
+ message( False,MSGTR_SKIN_WARNING2,linenumber,(str) ); \
return 1; \
} \
-}
+} while (0)
char * strlower( char * in )
{
Index: wm/widget.h
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/wm/widget.h,v
retrieving revision 1.2
diff -u -r1.2 widget.h
--- wm/widget.h 4 Oct 2001 20:33:29 -0000 1.2
+++ wm/widget.h 8 Oct 2001 12:44:45 -0000
@@ -1,3 +1,3 @@
-#define wgIsRect( X,Y,tX,tY,bX,bY ) ( ( X > tX )&&( Y > tY )&&( X < bX )&&( Y < bY ) )
+#define wgIsRect( X,Y,tX,tY,bX,bY ) ( ( (X) > (tX) )&&( (Y) > (tY) )&&( (X) < (bX) )&&( (Y) < (bY) ) )
Index: wm/ws.h
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/wm/ws.h,v
retrieving revision 1.7
diff -u -r1.7 ws.h
--- wm/ws.h 4 Oct 2001 20:33:29 -0000 1.7
+++ wm/ws.h 8 Oct 2001 12:44:46 -0000
@@ -204,7 +204,7 @@
extern void wsSetBackground( wsTWindow * win,int color );
extern void wsSetForegroundRGB( wsTWindow * win,int r,int g,int b );
extern void wsSetBackgroundRGB( wsTWindow * win,int r,int g,int b );
-#define wsClearWindow( win ); XClearWindow( wsDisplay,win.WindowID );
+#define wsClearWindow( win ) XClearWindow( wsDisplay,(win).WindowID )
extern void wsSetTitle( wsTWindow * win,char * name );
extern void wsVisibleWindow( wsTWindow * win,int show );
extern void wsWindowDecoration( wsTWindow * win,long d );
Index: wm/wsconv.c
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/wm/wsconv.c,v
retrieving revision 1.2
diff -u -r1.2 wsconv.c
--- wm/wsconv.c 4 Oct 2001 20:33:29 -0000 1.2
+++ wm/wsconv.c 8 Oct 2001 12:44:46 -0000
@@ -14,9 +14,9 @@
// ---
-#define COPY_RGB_24(src,dst) dst[0]=src[0];dst[1]=src[1];dst[2]=src[2]
+#define COPY_RGB_24(src,dst) do { (dst)[0]=(src)[0];(dst)[1]=(src)[1];(dst)[2]=(src)[2]; } while(0)
-#define SWAP_RGB_24(src,dst) dst[1]=src[0];dst[1]=src[1];dst[2]=src[0]
+#define SWAP_RGB_24(src,dst) do { (dst)[1]=(src)[0];(dst)[1]=(src)[1];(dst)[2]=(src)[0]; } while(0)
void BGR8880_to_RGB555_c( unsigned char * in_pixels, unsigned char * out_pixels, int num_pixels)
{
@@ -111,10 +111,10 @@
unsigned char * map_5_to_8[32];
unsigned char * map_6_to_8[64];
-#define POINTER_TO_GUINT16(a) *((unsigned short*)a)
-#define RGB16_TO_R(pixel) map_5_to_8[pixel & RGB16_LOWER_MASK]
-#define RGB16_TO_G(pixel) map_6_to_8[(pixel & RGB16_MIDDLE_MASK)>>5]
-#define RGB16_TO_B(pixel) map_5_to_8[(pixel & RGB16_UPPER_MASK)>>11]
+#define POINTER_TO_GUINT16(a) (*((unsigned short*)(a)))
+#define RGB16_TO_R(pixel) map_5_to_8[(pixel) & RGB16_LOWER_MASK]
+#define RGB16_TO_G(pixel) map_6_to_8[((pixel) & RGB16_MIDDLE_MASK)>>5]
+#define RGB16_TO_B(pixel) map_5_to_8[((pixel) & RGB16_UPPER_MASK)>>11]
#define RGB16_LOWER_MASK 0x001f
#define RGB16_MIDDLE_MASK 0x07e0
#define RGB16_UPPER_MASK 0xf800
Index: wm/wsconv.h
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/wm/wsconv.h,v
retrieving revision 1.2
diff -u -r1.2 wsconv.h
--- wm/wsconv.h 4 Oct 2001 20:33:29 -0000 1.2
+++ wm/wsconv.h 8 Oct 2001 12:44:46 -0000
@@ -4,17 +4,17 @@
#include "../../config.h"
-#define PACK_RGB16(r,g,b,pixel) pixel=(b>>3);\
- pixel<<=6;\
- pixel|=(g>>2);\
- pixel<<=5;\
- pixel|=(r>>3)
+#define PACK_RGB16(r,g,b,pixel) do { (pixel)=((b)>>3);\
+ (pixel)<<=6;\
+ (pixel)|=((g)>>2);\
+ (pixel)<<=5;\
+ (pixel)|=((r)>>3); } while(0)
-#define PACK_RGB15(r,g,b,pixel) pixel=(b>>3);\
- pixel<<=5;\
- pixel|=(g>>3);\
- pixel<<=5;\
- pixel|=(r>>3)
+#define PACK_RGB15(r,g,b,pixel) do { (pixel)=((b)>>3);\
+ (pixel)<<=5;\
+ (pixel)|=((g)>>3);\
+ (pixel)<<=5;\
+ (pixel)|=(r>>3); } while(0)
typedef void(*wsTConvFunc)( unsigned char * in_pixels, unsigned char * out_pixels, int num_pixels );
extern wsTConvFunc wsConvFunc;
More information about the MPlayer-dev-eng
mailing list