Per the code, -r(LIST_HEAD_REVERSE) only work with LIST_HEAD_FORMAT which is set by -H or -h. Previously, if LIST_HEAD_FORMAT was not set, `list -r` will traverse the list in order, that doesn't obey the -r(reverse) semantics. Add a further check to ensure -r is used in conjunction with -H or -h. Signed-off-by: Li Zhijian <lizhijian@xxxxxxxxxxx> --- help.c | 3 ++- tools.c | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/help.c b/help.c index d80e843703c1..6f7e093cbef1 100644 --- a/help.c +++ b/help.c @@ -5977,7 +5977,8 @@ char *help__list[] = { " ", " -x Override the default output format with hexadecimal format.", " -d Override the default output format with decimal format.", -" -r For a list linked with list_head structures, traverse the list", +" -r Must be used in conjunction with either -H or -h.", +" For a list linked with list_head structures, traverse the list", " in the reverse order by using the \"prev\" pointer instead", " of \"next\".", " -B Use the algorithm from R. P. Brent to detect loops instead of", diff --git a/tools.c b/tools.c index 0f2db108838a..67977605c276 100644 --- a/tools.c +++ b/tools.c @@ -3451,6 +3451,9 @@ cmd_list(void) } } + if (ld->flags & LIST_HEAD_REVERSE && !(ld->flags & LIST_HEAD_FORMAT)) + error(FATAL, "-r must be used in conjunction with -H or -h\n"); + if (argerrs) cmd_usage(pc->curcmd, SYNOPSIS); -- 2.29.2 -- Crash-utility mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxxxxxx https://${domain_name}/admin/lists/devel.lists.crash-utility.osci.io/ Contribution Guidelines: https://github.com/crash-utility/crash/wiki