[PATCH] getdents: fix typos in array output

Gabriel Laskar gabriel at lse.epita.fr
Thu Nov 19 10:44:30 UTC 2015


Array should be enclosed by square brakets, and elements should be
separated by commas.

* dirent.c: fix typos in array output of getdents()
* tests/getdents.awk: change test to fix typos
* tests/getdents.out: output modified to match output

Signed-off-by: Gabriel Laskar <gabriel at lse.epita.fr>
---
 dirent.c           | 12 ++++++------
 tests/getdents.awk | 34 +++++++++++++++++-----------------
 tests/getdents.out |  4 ++--
 3 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/dirent.c b/dirent.c
index 7b2609e..30570e0 100644
--- a/dirent.c
+++ b/dirent.c
@@ -92,7 +92,7 @@ SYS_FUNC(getdents)
 	}
 
 	if (!abbrev(tcp))
-		tprints("{");
+		tprints("[");
 	for (i = 0; len && i <= len - sizeof(struct kernel_dirent); ) {
 		struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
 
@@ -105,7 +105,7 @@ SYS_FUNC(getdents)
 				d_name_len = D_NAME_LEN_MAX;
 
 			tprintf("%s{d_ino=%lu, d_off=%lu, d_reclen=%u, d_name=",
-				i ? " " : "", d->d_ino, d->d_off, d->d_reclen);
+				i ? ", " : "", d->d_ino, d->d_off, d->d_reclen);
 
 			if (print_quoted_string(d->d_name, d_name_len,
 					        QUOTE_0_TERMINATED) > 0) {
@@ -127,7 +127,7 @@ SYS_FUNC(getdents)
 		i += d->d_reclen;
 	}
 	if (!abbrev(tcp))
-		tprints("}");
+		tprints("]");
 	else
 		tprintf("/* %u entries */", dents);
 	tprintf(", %lu", tcp->u_arg[2]);
@@ -175,7 +175,7 @@ SYS_FUNC(getdents64)
 	}
 
 	if (!abbrev(tcp))
-		tprints("{");
+		tprints("[");
 	for (i = 0; len && i <= len - d_name_offset; ) {
 		struct dirent64 *d = (struct dirent64 *) &buf[i];
 		if (!abbrev(tcp)) {
@@ -191,7 +191,7 @@ SYS_FUNC(getdents64)
 
 			tprintf("%s{d_ino=%" PRIu64 ", d_off=%" PRId64
 				", d_reclen=%u, d_type=",
-				i ? " " : "",
+				i ? ", " : "",
 				d->d_ino,
 				d->d_off,
 				d->d_reclen);
@@ -203,7 +203,7 @@ SYS_FUNC(getdents64)
 				tprints("...");
 			}
 
-			tprints("}");
+			tprints("]");
 		}
 		if (d->d_reclen < d_name_offset) {
 			tprints("/* d_reclen < offsetof(struct dirent64, d_name) */");
diff --git a/tests/getdents.awk b/tests/getdents.awk
index 8a00133..e68999c 100644
--- a/tests/getdents.awk
+++ b/tests/getdents.awk
@@ -20,28 +20,28 @@ BEGIN {
 	dirent64_2 = "\\{" d_ino ", " d_off ", " d_reclen ", " d_type_dir ", " d_name_2 "\\}"
 	dirent64_3 = "\\{" d_ino ", " d_off ", " d_reclen ", " d_type_reg ", " d_name_3 "\\}"
 
-	d_123 = dirent_1 " " dirent_2 " " dirent_3
-	d_213 = dirent_2 " " dirent_1 " " dirent_3
-	d_132 = dirent_1 " " dirent_3 " " dirent_2
-	d_321 = dirent_3 " " dirent_2 " " dirent_1
-	d_231 = dirent_2 " " dirent_3 " " dirent_1
-	d_312 = dirent_3 " " dirent_1 " " dirent_2
-
-	d64_123 = dirent64_1 " " dirent64_2 " " dirent64_3
-	d64_213 = dirent64_2 " " dirent64_1 " " dirent64_3
-	d64_132 = dirent64_1 " " dirent64_3 " " dirent64_2
-	d64_321 = dirent64_3 " " dirent64_2 " " dirent64_1
-	d64_231 = dirent64_2 " " dirent64_3 " " dirent64_1
-	d64_312 = dirent64_3 " " dirent64_1 " " dirent64_2
-
-	dents = "\\{(" d_123 "|" d_213 "|" d_132 "|" d_321 "|" d_231 "|" d_312 ")\\}"
-	dents64 = "\\{(" d64_123 "|" d64_213 "|" d64_132 "|" d64_321 "|" d64_231 "|" d64_312 ")\\}"
+	d_123 = dirent_1 ", " dirent_2 ", " dirent_3
+	d_213 = dirent_2 ", " dirent_1 ", " dirent_3
+	d_132 = dirent_1 ", " dirent_3 ", " dirent_2
+	d_321 = dirent_3 ", " dirent_2 ", " dirent_1
+	d_231 = dirent_2 ", " dirent_3 ", " dirent_1
+	d_312 = dirent_3 ", " dirent_1 ", " dirent_2
+
+	d64_123 = dirent64_1 ", " dirent64_2 ", " dirent64_3
+	d64_213 = dirent64_2 ", " dirent64_1 ", " dirent64_3
+	d64_132 = dirent64_1 ", " dirent64_3 ", " dirent64_2
+	d64_321 = dirent64_3 ", " dirent64_2 ", " dirent64_1
+	d64_231 = dirent64_2 ", " dirent64_3 ", " dirent64_1
+	d64_312 = dirent64_3 ", " dirent64_1 ", " dirent64_2
+
+	dents = "\\[(" d_123 "|" d_213 "|" d_132 "|" d_321 "|" d_231 "|" d_312 ")\\]"
+	dents64 = "\\[(" d64_123 "|" d64_213 "|" d64_132 "|" d64_321 "|" d64_231 "|" d64_312 ")\\]"
 
 	getdents   =   "getdents\\(" i ", " dents   ", " len "\\)"
 	getdents64 = "getdents64\\(" i ", " dents64 ", " len "\\)"
 
 	r[1] = "^(" getdents "|" getdents64 ") += " len "$"
-	r[2] = "^getdents(64)?\\([0-9]+, \\{\\}, [1-9][0-9]+\\) += 0$"
+	r[2] = "^getdents(64)?\\([0-9]+, \\[\\], [1-9][0-9]+\\) += 0$"
 	s[3] = "+++ exited with 0 +++"
 
 	lines = 3
diff --git a/tests/getdents.out b/tests/getdents.out
index d2a9818..d53f32f 100644
--- a/tests/getdents.out
+++ b/tests/getdents.out
@@ -1,3 +1,3 @@
-getdents(3, {{d_ino=123456789, d_off=1, d_reclen=24, d_name=".", d_type=DT_DIR} {d_ino=234567890, d_off=2, d_reclen=24, d_name="..", d_type=DT_DIR} {d_ino=345678901, d_off=3, d_reclen=280, d_name="A\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nZ", d_type=DT_REG}}, 4096) = 328
-getdents(3, {}, 4096)                   = 0
+getdents(3, [{d_ino=4563860, d_off=2846804908124804893, d_reclen=24, d_name="..", d_type=DT_DIR}, {d_ino=4747925, d_off=6563024353077090002, d_reclen=280, d_name="A\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nZ", d_type=DT_REG}, {d_ino=4800518, d_off=9223372036854775807, d_reclen=24, d_name=".", d_type=DT_DIR}], 32768) = 328
+getdents(3, [], 32768)                  = 0
 +++ exited with 0 +++
-- 
2.6.2





More information about the Strace-devel mailing list