[PATCH v4 02/20] libtraceeval: Reverse params of copy_traceeval_data()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx>

Most C library functions copy data from "dst", "src" order, but
copy_traceeval_data() does it as "src", "dst", and I already made one bug
because of this. Reverse the order of the copy_traceeval_data()
parameters, and also rename them to match standard library names "dst" and
"src".

Link: https://lore.kernel.org/linux-trace-devel/20230817192926.GA73817@xxxxxxxxxx/

Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
---
 src/histograms.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/histograms.c b/src/histograms.c
index d22d15238616..071e30e73768 100644
--- a/src/histograms.c
+++ b/src/histograms.c
@@ -560,25 +560,25 @@ static int get_entry(struct traceeval *teval, const union traceeval_data *keys,
 }
 
 /*
- * Copy @orig to @copy with respect to @type.
+ * Copy @src to @dst with respect to @type.
  *
  * Return 0 on success, -1 on error.
  */
 static int copy_traceeval_data(struct traceeval_type *type,
-				const union traceeval_data *orig,
-				union traceeval_data *copy)
+				union traceeval_data *dst,
+				const union traceeval_data *src)
 {
-	*copy = *orig;
+	*dst = *src;
 
 	if (type->type == TRACEEVAL_TYPE_STRING) {
-		copy->string = NULL;
+		dst->string = NULL;
 
-		if (orig->string)
-			copy->string = strdup(orig->string);
+		if (src->string)
+			dst->string = strdup(src->string);
 		else
 			return 0;
 
-		if (!copy->string)
+		if (!dst->string)
 			return -1;
 	}
 
@@ -621,7 +621,7 @@ static int copy_traceeval_data_set(size_t size, struct traceeval_type *type,
 		return -1;
 
 	for (i = 0; i < size; i++) {
-		if (copy_traceeval_data(type + i, orig + i, (*copy) + i))
+		if (copy_traceeval_data(type + i, (*copy) + i, orig + i))
 			goto fail;
 	}
 
-- 
2.40.1




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux