[DTrace-devel] [PATCH] test: ensure casting does not affect value

Kris Van Hees kris.van.hees at oracle.com
Wed Jul 31 19:01:42 UTC 2024


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 at 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




More information about the DTrace-devel mailing list