[DTrace-devel] [PATCH v4 12/23] dof_parser: a bit of const-correctness

Nick Alcock nick.alcock at oracle.com
Wed Feb 21 20:48:06 UTC 2024


dof_parser_host_write does not change its dh argument, so make it const.

Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
---
 libcommon/dof_parser.h      | 2 +-
 libcommon/dof_parser_host.c | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/libcommon/dof_parser.h b/libcommon/dof_parser.h
index 3373999376909..d3a6836f15fd8 100644
--- a/libcommon/dof_parser.h
+++ b/libcommon/dof_parser.h
@@ -111,7 +111,7 @@ typedef struct dof_parsed {
  *
  * Returns 0 on success or a positive errno value on error.
  */
-int dof_parser_host_write(int out, dof_helper_t *dh, dof_hdr_t *dof);
+int dof_parser_host_write(int out, const dof_helper_t *dh, dof_hdr_t *dof);
 
 /*
  * Read a single DOF structure from a parser pipe.  Wait at most TIMEOUT seconds
diff --git a/libcommon/dof_parser_host.c b/libcommon/dof_parser_host.c
index 4cf5b63b4eb6f..5a7546af1a5db 100644
--- a/libcommon/dof_parser_host.c
+++ b/libcommon/dof_parser_host.c
@@ -1,6 +1,6 @@
 /*
  * Oracle Linux DTrace; DOF-consumption and USDT-probe-creation daemon.
- * Copyright (c) 2022, 2023, 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.
  */
@@ -51,15 +51,15 @@ dof_parser_write_one(int out, const void *buf_, size_t size)
  * Returns 0 on success or a positive errno value on error.
  */
 int
-dof_parser_host_write(int out, dof_helper_t *dh, dof_hdr_t *dof)
+dof_parser_host_write(int out, const dof_helper_t *dh, dof_hdr_t *dof)
 {
 	int err;
 
-	if ((err = dof_parser_write_one(out, (char *)dh,
+	if ((err = dof_parser_write_one(out, (const char *)dh,
 					sizeof(dof_helper_t))) < 0)
 		return err;
 
-	return dof_parser_write_one(out, (char *)dof,
+	return dof_parser_write_one(out, (const char *)dof,
 				    dof->dofh_loadsz);
 }
 
-- 
2.43.0.272.gce700b77fd




More information about the DTrace-devel mailing list