Convert flag variables in cmd_datatype_common() to flag values, so that fewer values have to be passed when the main printing loop is converted to a standalone function. Signed-off-by: Petr Tesarik <ptesarik@xxxxxxx>
[PATCH 6/11] Convert cmd_datatype_common variables to flags Convert flag variables in cmd_datatype_common() to flag values, so that fewer values have to be passed when the main printing loop is converted to a standalone function. Signed-off-by: Petr Tesarik <ptesarik@xxxxxxx> --- symbols.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) --- a/symbols.c +++ b/symbols.c @@ -117,6 +117,8 @@ static int show_member_offset(FILE *, st #define IN_STRUCT (0x40000) #define DATATYPE_QUERY (0x80000) #define ANON_MEMBER_QUERY (0x100000) +#define SHOW_RAW_DATA (0x200000) +#define DEREF_POINTERS (0x400000) #define INTEGER_TYPE (UINT8|INT8|UINT16|INT16|UINT32|INT32|UINT64|INT64) @@ -5708,10 +5710,9 @@ cmd_datatype_common(ulong flags) int i, c; ulong addr, aflag; struct syment *sp; - int rawdata; long len; ulong list_head_offset; - int count, pflag; + int count; int argc_members; int optind_save; unsigned int radix, restore_radix; @@ -5722,19 +5723,17 @@ cmd_datatype_common(ulong flags) dm = &datatype_member; count = 0xdeadbeef; - rawdata = 0; aflag = addr = 0; list_head_offset = 0; argc_members = 0; radix = restore_radix = 0; separator = members = NULL; - pflag = 0; while ((c = getopt(argcnt, args, "pxdhfuc:rvol:")) != EOF) { switch (c) { case 'p': - pflag++; + flags |= DEREF_POINTERS; break; case 'd': @@ -5757,7 +5756,7 @@ cmd_datatype_common(ulong flags) break; case 'r': - rawdata = 1; + flags |= SHOW_RAW_DATA; break; case 'v': @@ -5854,7 +5853,7 @@ cmd_datatype_common(ulong flags) else if (!aflag) error(FATAL, "no kernel virtual address argument entered\n"); - if (pflag && !aflag) + if ((flags & DEREF_POINTERS) && !aflag) error(FATAL, "-p option requires address argument\n"); if (list_head_offset) @@ -5920,7 +5919,7 @@ cmd_datatype_common(ulong flags) structname); break; case 1: break; - case 2: if (rawdata) + case 2: if (flags & SHOW_RAW_DATA) error(FATAL, "member-specific output not allowed with -r\n"); break; @@ -5952,9 +5951,9 @@ cmd_datatype_common(ulong flags) /* * Display data. */ - if (rawdata) + if (flags & SHOW_RAW_DATA) raw_data_dump(addr, len, flags & STRUCT_VERBOSE); - else if (pflag && !dm->member) { + else if ((flags & DEREF_POINTERS) && !dm->member) { set_temporary_radix(radix, &restore_radix); print_struct_with_dereference(addr, dm, flags); restore_current_radix(restore_radix); @@ -5970,7 +5969,7 @@ cmd_datatype_common(ulong flags) print_struct(dm->name, addr); if (dm->member) { - if (!(pflag && + if (!((flags & DEREF_POINTERS) && dereference_pointer(addr, dm, flags))) parse_for_member(dm, PARSE_FOR_DATA); close_tmpfile(); @@ -6960,6 +6959,10 @@ dump_datatype_flags(ulong flags, FILE *o fprintf(ofp, "%sDATATYPE_QUERY", others++ ? "|" : ""); if (flags & ANON_MEMBER_QUERY) fprintf(ofp, "%sANON_MEMBER_QUERY", others++ ? "|" : ""); + if (flags & SHOW_RAW_DATA) + fprintf(ofp, "%sSHOW_RAW_DATA", others++ ? "|" : ""); + if (flags & DEREF_POINTERS) + fprintf(ofp, "%sDEREF_POINTERS", others++ ? "|" : ""); fprintf(ofp, ")\n"); }
-- Crash-utility mailing list Crash-utility@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/crash-utility