[Crash-utility] [PATCH v4 03/12] "whatis -m": fix duplications in the output

Alexey Makhalov amakhalov at vmware.com
Sat Mar 20 04:07:27 UTC 2021


"whatis -m" output started to generate duplicated results after GDB update:

crash> whatis -m mm_struct
SIZE  TYPE
   16  tlb_state
...
  256  linux_binprm
  2752  rq
  2752  rq  <<-- duplicated
  2752  rq
  2752  rq
  2752  rq
  4048  task_struct

It was caused by incorrect string comparisons.
Use strcmp for full string comparison instead of just string pointers
comparison.

Signed-off-by: Alexey Makhalov <amakhalov at vmware.com>
Reported-by: Kazuhito Hagio <k-hagio-ab at nec.com>
---
 symbols.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/symbols.c b/symbols.c
index 3321625..4dc50a0 100644
--- a/symbols.c
+++ b/symbols.c
@@ -6988,7 +6988,7 @@ append_struct_symbol (struct gnu_request *req, void *data)
 	long s;
 
 	for (i = 0; i < treq->idx; i++)
-		if (treq->types[i].name == req->name)
+		if (!strcmp(treq->types[i].name, req->name))
 			break;
 
 	if (i < treq->idx) // We've already collected this type
-- 
2.11.0




More information about the Crash-utility mailing list