Linux DTrace development list
 help / color / mirror / Atom feed
* [PATCH] test: ensure casting does not affect value
@ 2024-07-31 19:01 Kris Van Hees
  2024-07-31 19:51 ` Eugene Loh
  2024-08-01 18:44 ` Nick Alcock
  0 siblings, 2 replies; 5+ messages in thread
From: Kris Van Hees @ 2024-07-31 19:01 UTC (permalink / raw)
  To: dtrace, dtrace-devel

On systems without CTF, we do not know the type of kernel variables.
By doing an explicit cast to int64_t a negative int is converted into a
large positive integer.  The proper cast is 'int' of course.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
---
 test/unittest/codegen/tst.kernel_read_neg_small_scalar.d | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/unittest/codegen/tst.kernel_read_neg_small_scalar.d b/test/unittest/codegen/tst.kernel_read_neg_small_scalar.d
index 7c585d1b..cda6649b 100644
--- a/test/unittest/codegen/tst.kernel_read_neg_small_scalar.d
+++ b/test/unittest/codegen/tst.kernel_read_neg_small_scalar.d
@@ -1,6 +1,6 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
@@ -11,10 +11,10 @@ BEGIN
 {
 	/*
 	 * Unless we are actually crashing, the `crashing_cpu int will be -1.
-	 * We cast it to int64_t to ensure that the value read from the kernel
+	 * We cast it to int to ensure that the value read from the kernel
 	 * is sign-extended.
 	 */
-	trace((int64_t)`crashing_cpu);
+	trace((int)`crashing_cpu);
 	exit(0);
 }
 
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-08-01 19:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-31 19:01 [PATCH] test: ensure casting does not affect value Kris Van Hees
2024-07-31 19:51 ` Eugene Loh
2024-07-31 20:04   ` Kris Van Hees
2024-08-01 18:44 ` Nick Alcock
2024-08-01 19:03   ` Kris Van Hees

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox