From 379f68fe4fa656bb717eee23e9415cfb6660744b Mon Sep 17 00:00:00 2001 From: akr Date: Mon, 20 Dec 2010 22:39:55 +0000 Subject: [PATCH] * pack.c: parenthesize macro arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ pack.c | 72 +++++++++++++++++++++++++++---------------------------- 2 files changed, 40 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index a1636f1133..35c5edfde5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Tue Dec 21 07:39:12 2010 Tanaka Akira + + * pack.c: parenthesize macro arguments. + Tue Dec 21 06:25:43 2010 Nobuyoshi Nakada * test/rexml/test_contrib.rb (ContribTester#test_pos): should not diff --git a/pack.c b/pack.c index 39a5922661..9df3706f44 100644 --- a/pack.c +++ b/pack.c @@ -213,22 +213,22 @@ TOKEN_PASTE(swap,x)(xtype z) \ #ifdef FLOAT_SWAPPER # define FLOAT_CONVWITH(y) FLOAT_SWAPPER y; -# define HTONF(x,y) (memcpy(&y,&x,sizeof(float)), \ - y = rb_htonf((FLOAT_SWAPPER)y), \ - memcpy(&x,&y,sizeof(float)), \ - x) -# define HTOVF(x,y) (memcpy(&y,&x,sizeof(float)), \ - y = rb_htovf((FLOAT_SWAPPER)y), \ - memcpy(&x,&y,sizeof(float)), \ - x) -# define NTOHF(x,y) (memcpy(&y,&x,sizeof(float)), \ - y = rb_ntohf((FLOAT_SWAPPER)y), \ - memcpy(&x,&y,sizeof(float)), \ - x) -# define VTOHF(x,y) (memcpy(&y,&x,sizeof(float)), \ - y = rb_vtohf((FLOAT_SWAPPER)y), \ - memcpy(&x,&y,sizeof(float)), \ - x) +# define HTONF(x,y) (memcpy(&(y),&(x),sizeof(float)), \ + (y) = rb_htonf((FLOAT_SWAPPER)(y)), \ + memcpy(&(x),&(y),sizeof(float)), \ + (x)) +# define HTOVF(x,y) (memcpy(&(y),&(x),sizeof(float)), \ + (y) = rb_htovf((FLOAT_SWAPPER)(y)), \ + memcpy(&(x),&(y),sizeof(float)), \ + (x)) +# define NTOHF(x,y) (memcpy(&(y),&(x),sizeof(float)), \ + (y) = rb_ntohf((FLOAT_SWAPPER)(y)), \ + memcpy(&(x),&(y),sizeof(float)), \ + (x)) +# define VTOHF(x,y) (memcpy(&(y),&(x),sizeof(float)), \ + (y) = rb_vtohf((FLOAT_SWAPPER)(y)), \ + memcpy(&(x),&(y),sizeof(float)), \ + (x)) #else # define FLOAT_CONVWITH(y) # define HTONF(x,y) rb_htonf(x) @@ -239,22 +239,22 @@ TOKEN_PASTE(swap,x)(xtype z) \ #ifdef DOUBLE_SWAPPER # define DOUBLE_CONVWITH(y) DOUBLE_SWAPPER y; -# define HTOND(x,y) (memcpy(&y,&x,sizeof(double)), \ - y = rb_htond((DOUBLE_SWAPPER)y), \ - memcpy(&x,&y,sizeof(double)), \ - x) -# define HTOVD(x,y) (memcpy(&y,&x,sizeof(double)), \ - y = rb_htovd((DOUBLE_SWAPPER)y), \ - memcpy(&x,&y,sizeof(double)), \ - x) -# define NTOHD(x,y) (memcpy(&y,&x,sizeof(double)), \ - y = rb_ntohd((DOUBLE_SWAPPER)y), \ - memcpy(&x,&y,sizeof(double)), \ - x) -# define VTOHD(x,y) (memcpy(&y,&x,sizeof(double)), \ - y = rb_vtohd((DOUBLE_SWAPPER)y), \ - memcpy(&x,&y,sizeof(double)), \ - x) +# define HTOND(x,y) (memcpy(&(y),&(x),sizeof(double)), \ + (y) = rb_htond((DOUBLE_SWAPPER)(y)), \ + memcpy(&(x),&(y),sizeof(double)), \ + (x)) +# define HTOVD(x,y) (memcpy(&(y),&(x),sizeof(double)), \ + (y) = rb_htovd((DOUBLE_SWAPPER)(y)), \ + memcpy(&(x),&(y),sizeof(double)), \ + (x)) +# define NTOHD(x,y) (memcpy(&(y),&(x),sizeof(double)), \ + (y) = rb_ntohd((DOUBLE_SWAPPER)(y)), \ + memcpy(&(x),&(y),sizeof(double)), \ + (x)) +# define VTOHD(x,y) (memcpy(&(y),&(x),sizeof(double)), \ + (y) = rb_vtohd((DOUBLE_SWAPPER)(y)), \ + memcpy(&(x),&(y),sizeof(double)), \ + (x)) #else # define DOUBLE_CONVWITH(y) # define HTOND(x,y) rb_htond(x) @@ -1212,11 +1212,11 @@ hex2num(char c) #define PACK_LENGTH_ADJUST_SIZE(sz) do { \ tmp_len = 0; \ - if (len > (long)((send-s)/sz)) { \ + if (len > (long)((send-s)/(sz))) { \ if (!star) { \ - tmp_len = len-(send-s)/sz; \ + tmp_len = len-(send-s)/(sz); \ } \ - len = (send-s)/sz; \ + len = (send-s)/(sz); \ } \ } while (0) @@ -1855,7 +1855,7 @@ pack_unpack(VALUE str, VALUE fmt) PACK_LENGTH_ADJUST_SIZE(sizeof(float)); while (len-- > 0) { float tmp; - FLOAT_CONVWITH(ftmp;) + FLOAT_CONVWITH(ftmp); memcpy(&tmp, s, sizeof(float)); s += sizeof(float);