* [PATCH] SAP: Make PADDING4 macro a bit more robust
@ 2012-03-02 14:58 Szymon Janc
2012-03-02 23:11 ` Johan Hedberg
0 siblings, 1 reply; 2+ messages in thread
From: Szymon Janc @ 2012-03-02 14:58 UTC (permalink / raw)
To: linux-bluetooth; +Cc: kanak.gupta, Szymon Janc
Bitwise operations are done before arithmetic operations and this might
cause undesired results if macro is called with parameter of form x+y.
---
sap/server.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/sap/server.c b/sap/server.c
index b8aa8a5..b5abd70 100644
--- a/sap/server.c
+++ b/sap/server.c
@@ -49,7 +49,7 @@
#define SAP_UUID "0000112D-0000-1000-8000-00805F9B34FB"
#define SAP_SERVER_CHANNEL 8
-#define PADDING4(x) ((4 - (x & 0x03)) & 0x03)
+#define PADDING4(x) ((4 - ((x) & 0x03)) & 0x03)
#define PARAMETER_SIZE(x) (sizeof(struct sap_parameter) + x + PADDING4(x))
#define SAP_NO_REQ 0xFF
--
on behalf of ST-Ericsson
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] SAP: Make PADDING4 macro a bit more robust
2012-03-02 14:58 [PATCH] SAP: Make PADDING4 macro a bit more robust Szymon Janc
@ 2012-03-02 23:11 ` Johan Hedberg
0 siblings, 0 replies; 2+ messages in thread
From: Johan Hedberg @ 2012-03-02 23:11 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth, kanak.gupta
Hi Szymon,
On Fri, Mar 02, 2012, Szymon Janc wrote:
> Bitwise operations are done before arithmetic operations and this might
> cause undesired results if macro is called with parameter of form x+y.
> ---
> sap/server.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
Applied. Thanks.
Johan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-03-02 23:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-02 14:58 [PATCH] SAP: Make PADDING4 macro a bit more robust Szymon Janc
2012-03-02 23:11 ` Johan Hedberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).