Later we will need to call readmem with more than one address variable. For clarity and simplicity, factor out the function. Signed-off-by: Dave Wysochanski <dwysocha@xxxxxxxxxx> --- tools.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tools.c b/tools.c index f9bf56f..0d4b8e5 100644 --- a/tools.c +++ b/tools.c @@ -3938,6 +3938,17 @@ static void do_list_output_struct(struct list_data *ld, ulong next, ulong offset } } +static int do_list_no_hash_readmem(struct list_data *ld, ulong *next_ptr, + ulong readflag) +{ + if (!readmem(*next_ptr + ld->member_offset, KVADDR, next_ptr, + sizeof(void *), "list entry", readflag)) { + error(INFO, "\ninvalid list entry: %lx\n", *next_ptr); + return -1; + } + return 0; +} + /* * Similar to do_list() but without the hash_table or LIST_ALLOCATE. * Useful for the 'list' command and other callers needing faster list @@ -3948,7 +3959,7 @@ do_list_no_hash(struct list_data *ld) { ulong next, last, first, offset; ulong searchfor, readflag; - int i, count; + int i, count, ret; unsigned int radix; struct req_entry **e = NULL; @@ -4015,11 +4026,9 @@ do_list_no_hash(struct list_data *ld) ld->callback_data) && (ld->flags & CALLBACK_RETURN)) break; - if (!readmem(next + ld->member_offset, KVADDR, &next, - sizeof(void *), "list entry", readflag)) { - error(INFO, "\ninvalid list entry: %lx\n", next); + ret = do_list_no_hash_readmem(ld, &next, readflag); + if (ret == -1) return -1; - } if (next == 0) { if (ld->flags & LIST_HEAD_FORMAT) { -- 1.8.3.1 -- Crash-utility mailing list Crash-utility@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/crash-utility