Patchwork [04/27] fs-tests: integck: abuse random_offset field nicer

login
register
mail settings
Submitter Artem Bityutskiy
Date April 13, 2011, 3:18 p.m.
Message ID <1302707947-6143-5-git-send-email-dedekind1@gmail.com>
Download mbox | patch
Permalink /patch/91032/
State Accepted
Commit 191071e9fcb711cd89c8c57e51937da525039c8b
Headers show

Comments

Artem Bityutskiy - April 13, 2011, 3:18 p.m.
From: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>

Currently integck uses the 'random_offset' filed to store the new file
length sometimes, thus abusing this field. But we can do this nicer -
introduce an anonymous union and add 'new_length' filed which will be
used instead of 'random_offset' to make the code look nicer.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
---
 tests/fs-tests/integrity/integck.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

Patch

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 0ff94c5..eff7274 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -44,7 +44,10 @@  struct write_info /* Record of random data written into a file */
 	off_t offset; /* Where in the file the data was written */
 	size_t size; /* Number of bytes written */
 	unsigned random_seed; /* Seed for rand() to create random data */
-	off_t random_offset; /* Call rand() this number of times first */
+	union {
+		off_t random_offset; /* Call rand() this number of times first */
+		off_t new_length; /* For truncation records new file length */
+	};
 	int trunc; /* Records a truncation (raw_writes only) */
 };
 
@@ -568,7 +571,7 @@  static void file_info_display(struct file_info *file)
 	while (w) {
 		if (w->trunc)
 			normsg("        Trunc from %u to %u",
-			       (unsigned) w->offset, (unsigned) w->random_offset);
+			       (unsigned) w->offset, (unsigned) w->new_length);
 		else
 			normsg("        Offset: %u  Size: %u  Seed: %u  R.Off: %u",
 			       (unsigned) w->offset, (unsigned) w->size,
@@ -920,7 +923,7 @@  static void file_truncate_info(struct file_info *file, size_t new_length)
 	w = zalloc(sizeof(struct write_info));
 	w->next = file->raw_writes;
 	w->offset = file->length;
-	w->random_offset = new_length; /* Abuse random_offset */
+	w->new_length = new_length;
 	w->trunc = 1;
 	file->raw_writes = w;
 	/* Update file length */