Add Add-missing-parentheses-to-SRL_ENC_HAVE_OPTION-argum patch

This commit is contained in:
Petr Písař 2015-11-27 12:44:08 +01:00
parent 83adc6169a
commit 7ad005b197

View File

@ -0,0 +1,41 @@
From 38b829d8845fc795d9404cd0e24b21c5b06f0a6e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Fri, 27 Nov 2015 11:17:25 +0100
Subject: [PATCH] Add missing parentheses to SRL_ENC_HAVE_OPTION arguments
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
GCC warns about missing parentheses:
In file included from srl_encoder.c:50:0:
srl_encoder.c: In function srl_dump_hv:
srl_encoder.h:141:58: warning: suggest parentheses around arithmetic in operand of | [-Wparentheses]
#define SRL_ENC_HAVE_OPTION(enc, flag_num) ((enc)->flags & flag_num)
^
srl_encoder.c:1431:18: note: in expansion of macro SRL_ENC_HAVE_OPTION
if ( SRL_ENC_HAVE_OPTION(enc, SRL_F_SORT_KEYS|SRL_F_SORT_KEYS_PERL) ) {
And indeed this is a bug.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
Perl/Encoder/srl_encoder.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Perl/Encoder/srl_encoder.h b/Perl/Encoder/srl_encoder.h
index 12ca951..639f220 100644
--- a/Perl/Encoder/srl_encoder.h
+++ b/Perl/Encoder/srl_encoder.h
@@ -140,7 +140,7 @@ SV *srl_dump_data_structure_mortal_sv(pTHX_ srl_encoder_t *enc, SV *src, SV *use
/* Set while the encoder is in active use / dirty */
#define SRL_OF_ENCODER_DIRTY 1UL
-#define SRL_ENC_HAVE_OPTION(enc, flag_num) ((enc)->flags & flag_num)
+#define SRL_ENC_HAVE_OPTION(enc, flag_num) ((enc)->flags & (flag_num))
#define SRL_ENC_SET_OPTION(enc, flag_num) STMT_START {(enc)->flags |= (flag_num);}STMT_END
#define SRL_ENC_RESET_OPTION(enc, flag_num) STMT_START {(enc)->flags &= ~(flag_num);}STMT_END
--
2.4.3