[Crash-utility] [PATCH 3/6] do_list_no_hash: factor out structure output into static function

Dave Wysochanski dwysocha at redhat.com
Tue Jul 10 22:24:36 UTC 2018


Create do_list_output_struct function to dump out the structure name
and members.  No functional change.

Signed-off-by: Dave Wysochanski <dwysocha at redhat.com>
---
 tools.c | 42 +++++++++++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 17 deletions(-)

diff --git a/tools.c b/tools.c
index 2af114f..f9bf56f 100644
--- a/tools.c
+++ b/tools.c
@@ -3914,6 +3914,30 @@ static void do_list_debug_entry(struct list_data *ld)
 	}
 }
 
+
+static void do_list_output_struct(struct list_data *ld, ulong next, ulong offset,
+				  unsigned int radix, struct req_entry **e)
+{
+	int i;
+
+	for (i = 0; i < ld->structname_args; i++) {
+		switch (count_chars(ld->structname[i], '.'))
+		{
+			case 0:
+				dump_struct(ld->structname[i],
+					    next - offset, radix);
+				break;
+			default:
+				if (ld->flags & LIST_PARSE_MEMBER)
+					dump_struct_members(ld, i, next);
+				else if (ld->flags & LIST_READ_MEMBER)
+					dump_struct_members_fast(e[i],
+						 radix, next - offset);
+				break;
+		}
+	}
+}
+
 /*
  * Similar to do_list() but without the hash_table or LIST_ALLOCATE.
  * Useful for the 'list' command and other callers needing faster list
@@ -3964,24 +3988,8 @@ do_list_no_hash(struct list_data *ld)
 	while (1) {
 		if (ld->flags & VERBOSE) {
 			fprintf(fp, "%lx\n", next - ld->list_head_offset);
-
 			if (ld->structname) {
-				for (i = 0; i < ld->structname_args; i++) {
-					switch (count_chars(ld->structname[i], '.'))
-					{
-					case 0:
-						dump_struct(ld->structname[i],
-							next - offset, radix);
-						break;
-					default:
-						if (ld->flags & LIST_PARSE_MEMBER)
-							dump_struct_members(ld, i, next);
-						else if (ld->flags & LIST_READ_MEMBER)
-							dump_struct_members_fast(e[i],
-								radix, next - offset);
-						break;
-					}
-				}
+				do_list_output_struct(ld, next, offset, radix, e);
 			}
 		}
 
-- 
1.8.3.1




More information about the Crash-utility mailing list