Skip to contentSkip to conversation

tests/binder: add missing parentheses in print_trans_data()

PATCH In review Ondrej Mosnáček 2 participants 4 messages Oct 20 – Oct 21 SELinux security module

lore
Share & tools
lore

Ondrej Mosnáček

author reviewer
#0 lore raw

PATCH 1/1 tests/binder: add missing parentheses in print_trans_data()

The newly added casts were meant to convert the result of the '&' operation, not just the left operand. Add parentheses to fix that.

Fixes 705ddfdc5ae5 ("tests/binder: fix compiler warnings on ppc64le")
---
 tests/binder/binder_common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/binder/binder_common.c +2 -2
index 62af7b6..891ce9d 100644
@@ -127,12 +127,12 @@ void print_trans_data(const struct binder_transaction_data *txn_in)
 		}
 #if HAVE_BINDERFS
 		printf("\tflags: priority: 0x%lx accept FDS: %s request security CTX: %s\n",
-		       (long unsigned)obj->flags & FLAT_BINDER_FLAG_PRIORITY_MASK,
+		       (long unsigned)(obj->flags & FLAT_BINDER_FLAG_PRIORITY_MASK),
 		       obj->flags & FLAT_BINDER_FLAG_ACCEPTS_FDS ? "YES" : "NO",
 		       obj->flags & FLAT_BINDER_FLAG_TXN_SECURITY_CTX ? "YES" : "NO");
 #else
 		printf("\tflags: priority: 0x%lx accept FDS: %s\n",
-		       (long unsigned)obj->flags & FLAT_BINDER_FLAG_PRIORITY_MASK,
+		       (long unsigned)(obj->flags & FLAT_BINDER_FLAG_PRIORITY_MASK),
 		       obj->flags & FLAT_BINDER_FLAG_ACCEPTS_FDS ? "YES" : "NO");
 #endif
 		printf("\tcookie: %llx\n", (long long unsigned)obj->cookie);
Signature · 1 line
2.54.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Ondrej Mosnáček

The newly added casts were meant to convert the result of the '&' operation, not just the left operand. Add parentheses to fix that.

Fixes 705ddfdc5ae5 ("tests/binder: fix compiler warnings on ppc64le")

Not new to this but I did wonder - why "long unsigned" rather than " unsigned long"? No real difference, just used to seeing it the other way around.

author reviewer
#2 lore raw
Quoted 6 lines · Stephen Smalley
Quoted 4 lines · Ondrej Mosnáček

The newly added casts were meant to convert the result of the '&' operation, not just the left operand. Add parentheses to fix that.

Quoted 8 lines
Quoted 2 lines
Fixes 705ddfdc5ae5 ("tests/binder: fix compiler warnings on ppc64le")

Not new to this but I did wonder - why "long unsigned" rather than " unsigned long"? No real difference, just used to seeing it the other way around.

Just to make it match the order in the format string (%llu -> long long unsigned). I admit it looks a bit weird, but at least it emphasizes that the cast corresponds to what is in the format string (and makes it a bit easier to visually verify that they match).

author reviewer
#3 lore raw
In reply to Stephen Smalley
Quoted 10 lines · Stephen Smalley
Quoted 6 lines · Ondrej Mosnáček

The newly added casts were meant to convert the result of the '&' operation, not just the left operand. Add parentheses to fix that.

Fixes 705ddfdc5ae5 ("tests/binder: fix compiler warnings on ppc64le")

Applied: https://github.com/SELinuxProject/selinux-testsuite/commit/3d95be0e967bb088aae6989fa283ecd07bc833e1