Skip to contentSkip to conversation

tests: fix format string mismatches on s390x/ppc64le

PATCH In review Pablo Alessandro Santos Hugen 3 participants 4 messages Oct 18 – Oct 20 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests: fix format string mismatches on s390x/ppc64le

Cast printf arguments to match format specifiers across filesystem/statfs_test.c, binder/{binder_common,client,manager, service_provider}.c, and perf_event/perf_event.c. Types like __fsword_t, binder_uintptr_t, binder_size_t and __s64 differ in width across architectures, triggering -Wformat under -Werror.

Fixes cb49040 ("tests: fail on compiler warnings and enable Wextra")
---
 tests/binder/binder_common.c    | 10 +++++-----
 tests/binder/client.c           |  4 ++--
 tests/binder/manager.c          |  2 +-
 tests/binder/service_provider.c |  4 ++--
 tests/filesystem/statfs_test.c  |  2 +-
 tests/perf_event/perf_event.c   |  4 ++--
 6 files changed, 13 insertions(+), 13 deletions(-)
tests/binder/binder_common.c +5 -5
index 7cf6c74..6f7e5b3 100644
@@ -65,7 +65,7 @@ void print_trans_data(const struct binder_transaction_data *txn_in)
 	size_t count = txn_in->offsets_size / sizeof(binder_size_t);
 
 	printf("\thandle: %d\n", (uint32_t)txn_in->target.handle);
-	printf("\tcookie: %lld\n", txn_in->cookie);
+	printf("\tcookie: %lld\n", (long long)txn_in->cookie);
 	switch (txn_in->code) {
 	case TEST_SERVICE_ADD:
 		printf("\tcode: TEST_SERVICE_ADD\n");
@@ -101,8 +101,8 @@ void print_trans_data(const struct binder_transaction_data *txn_in)
 	}
 	printf("\tsender pid: %u\n", txn_in->sender_pid);
 	printf("\tsender euid: %u\n", txn_in->sender_euid);
-	printf("\tdata_size: %llu\n", txn_in->data_size);
-	printf("\toffsets_size: %llu\n", txn_in->offsets_size);
+	printf("\tdata_size: %llu\n", (unsigned long long)txn_in->data_size);
+	printf("\toffsets_size: %llu\n", (unsigned long long)txn_in->offsets_size);
 
 	while (count--) {
 		obj = (const struct flat_binder_object *)
@@ -111,7 +111,7 @@ void print_trans_data(const struct binder_transaction_data *txn_in)
 		switch (obj->hdr.type) {
 		case BINDER_TYPE_BINDER:
 			printf("\thdr: BINDER_TYPE_BINDER\n");
-			printf("\tbinder: %llx\n", obj->binder);
+			printf("\tbinder: %llx\n", (unsigned long long)obj->binder);
 			break;
 		case BINDER_TYPE_HANDLE:
 			printf("\thdr: BINDER_TYPE_HANDLE\n");
@@ -135,7 +135,7 @@ void print_trans_data(const struct binder_transaction_data *txn_in)
 		       obj->flags & FLAT_BINDER_FLAG_PRIORITY_MASK,
 		       obj->flags & FLAT_BINDER_FLAG_ACCEPTS_FDS ? "YES" : "NO");
 #endif
-		printf("\tcookie: %llx\n", obj->cookie);
+		printf("\tcookie: %llx\n", (unsigned long long)obj->cookie);
 	}
 	fflush(stdout);
 }
tests/binder/client.c +2 -2
index 220d37a..a35fd7b 100644
@@ -111,7 +111,7 @@ static void extract_fd_and_respond(const struct binder_transaction_data *txn_in)
 
 	if (verbose)
 		printf("Client read_consumed: %lld\n",
-		       bwr.read_consumed);
+		       (long long)bwr.read_consumed);
 
 	cmd = binder_parse(obj->fd, (binder_uintptr_t)readbuf,
 			   bwr.read_consumed);
@@ -435,7 +435,7 @@ int main(int argc, char **argv)
 
 		if (verbose)
 			printf("Client read_consumed: %lld\n",
-			       bwr.read_consumed);
+			       (long long)bwr.read_consumed);
 
 		cmd = binder_parse(fd, (binder_uintptr_t)readbuf,
 				   bwr.read_consumed);
tests/binder/manager.c +1 -1
index f7f1723..14e3e0c 100644
@@ -349,7 +349,7 @@ int main(int argc, char **argv)
 
 		if (verbose)
 			printf("Manager read_consumed: %lld\n",
-			       bwr.read_consumed);
+			       (long long)bwr.read_consumed);
 
 		binder_parse(fd, (binder_uintptr_t)readbuf, bwr.read_consumed);
 	}
tests/binder/service_provider.c +2 -2
index 1e6b490..40734a2 100644
@@ -384,7 +384,7 @@ int main(int argc, char **argv)
 
 	if (verbose)
 		printf("Service Provider read_consumed: %lld\n",
-		       bwr.read_consumed);
+		       (long long)bwr.read_consumed);
 
 	cmd = binder_parse(fd, (binder_uintptr_t)readbuf,
 			   bwr.read_consumed);
@@ -455,7 +455,7 @@ int main(int argc, char **argv)
 
 		if (verbose)
 			printf("Service Provider read_consumed: %lld\n",
-			       bwr.read_consumed);
+			       (long long)bwr.read_consumed);
 
 		cmd = binder_parse(fd, (binder_uintptr_t)readbuf, bwr.read_consumed);
 
tests/filesystem/statfs_test.c +1 -1
index 310b66d..4a318d2 100644
@@ -59,7 +59,7 @@ int main(int argc, char *argv[])
 
 	if (verbose)
 		printf("statfs(2) returned magic filesystem: 0x%lx\n",
-		       statfs_t.f_type);
+		       (unsigned long)statfs_t.f_type);
 
 	return 0;
 }
tests/perf_event/perf_event.c +2 -2
index 0e8bdce..b8d3dae 100644
@@ -161,7 +161,7 @@ int main(int argc, char **argv)
 		if (verbose) {
 			pe_page = base;
 			printf("perf mmap(2) return value: %lld\n",
-			       pe_page->offset);
+			       (long long)pe_page->offset);
 		}
 
 		munmap(base, mmap_size);
@@ -178,7 +178,7 @@ int main(int argc, char **argv)
 		}
 
 		if (verbose)
-			printf("perf read(2) return value: %lld\n", count);
+			printf("perf read(2) return value: %lld\n", (long long)count);
 
 		close(fd);
 	}
Signature · 1 line
2.56.0
maintainer
#1 lore raw
Quoted 9 lines · Pablo Alessandro Santos Hugen

Cast printf arguments to match format specifiers across filesystem/statfs_test.c, binder/{binder_common,client,manager, service_provider}.c, and perf_event/perf_event.c. Types like __fsword_t, binder_uintptr_t, binder_size_t and __s64 differ in width across architectures, triggering -Wformat under -Werror.

Fixes cb49040 ("tests: fail on compiler warnings and enable Wextra")

This looks like it was prepared against a tree before Ondrej's series landed. As far as I can tell, all of these fixes are already addressed on the main branch except for one residual cast that isn't actually needed.

#2 lore raw
Quoted 10 lines · Stephen Smalley
Quoted 7 lines · Pablo Alessandro Santos Hugen

Cast printf arguments to match format specifiers across filesystem/statfs_test.c, binder/{binder_common,client,manager, service_provider}.c, and perf_event/perf_event.c. Types like __fsword_t, binder_uintptr_t, binder_size_t and __s64 differ in width across architectures, triggering -Wformat under -Werror.

Quoted 6 lines
Quoted 2 lines
Fixes cb49040 ("tests: fail on compiler warnings and enable Wextra")

This looks like it was prepared against a tree before Ondrej's series landed. As far as I can tell, all of these fixes are already addressed on the main branch except for one residual cast that isn't actually needed.

Yes, this is already fixed by:
https://github.com/SELinuxProject/selinux-testsuite/commit/705ddfdc5ae5217344eecc8d4352e7f3dc52e772
https://github.com/SELinuxProject/selinux-testsuite/commit/6fa2143aec27d0ac3ad4cb3fd76f747ab198ac1f
https://github.com/SELinuxProject/selinux-testsuite/commit/bf477b4e3df60b63553712fce6e07c97881dc6b6

#3 lore raw

Yes that was the case. I've created the patches from an mirror which I thought was updated.

Anyways, thanks for the reviews!!!

Best,
Pablo