From 5b763a470886fb9f24b8a75f38e6b252a2c127a7 Mon Sep 17 00:00:00 2001 From: Guinevere Larsen Date: Tue, 22 Jul 2025 11:35:15 -0300 Subject: [PATCH] gdb: Remove redundant parameter for filename completion As I was working on an unrelated patch, I noticed that all calls to make_source_files_completion_list had both parameters of the function call being the same pointer. I think we can remove that redundancy and make that call with just one parameter. Approved-By: Andrew Burgess --- gdb/completer.c | 6 +++--- gdb/symtab.c | 8 ++++---- gdb/symtab.h | 3 +-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/gdb/completer.c b/gdb/completer.c index 0d68e76b6f4..deecbc209f7 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -1008,7 +1008,7 @@ complete_files_symbols (completion_tracker &tracker, name, they cannot be asking for completion on files. */ if (strcspn (text, gdb_completer_file_name_break_characters) == text_len) - fn_list = make_source_files_completion_list (text, text); + fn_list = make_source_files_completion_list (text); } if (!fn_list.empty () && !tracker.have_completions ()) @@ -1059,7 +1059,7 @@ complete_source_filenames (const char *text) the user cannot be asking for completion on files. */ if (strcspn (text, gdb_completer_file_name_break_characters) == text_len) - return make_source_files_completion_list (text, text); + return make_source_files_completion_list (text); return {}; } @@ -1142,7 +1142,7 @@ collect_explicit_location_matches (completion_tracker &tracker, const char *source = string_or_empty (explicit_loc->source_filename.get ()); completion_list matches - = make_source_files_completion_list (source, source); + = make_source_files_completion_list (source); tracker.add_completions (std::move (matches)); } break; diff --git a/gdb/symtab.c b/gdb/symtab.c index 7d1a0b066c7..160a465b676 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -6402,7 +6402,7 @@ add_partial_filename_data::operator() (const char *filename, program. */ completion_list -make_source_files_completion_list (const char *text, const char *word) +make_source_files_completion_list (const char *text) { size_t text_len = strlen (text); completion_list list; @@ -6428,7 +6428,7 @@ make_source_files_completion_list (const char *text, const char *word) { /* This file matches for a completion; add it to the current list of matches. */ - add_filename_to_list (s->filename, text, word, &list); + add_filename_to_list (s->filename, text, text, &list); } else { @@ -6440,7 +6440,7 @@ make_source_files_completion_list (const char *text, const char *word) if (base_name != s->filename && !filenames_seen.seen (base_name) && filename_ncmp (base_name, text, text_len) == 0) - add_filename_to_list (base_name, text, word, &list); + add_filename_to_list (base_name, text, text, &list); } } } @@ -6448,7 +6448,7 @@ make_source_files_completion_list (const char *text, const char *word) datum.filename_seen_cache = &filenames_seen; datum.text = text; - datum.word = word; + datum.word = text; datum.text_len = text_len; datum.list = &list; map_symbol_filenames (datum, false /*need_fullname*/); diff --git a/gdb/symtab.h b/gdb/symtab.h index 0a57be5ed80..a71195313a1 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -2482,8 +2482,7 @@ extern void collect_file_symbol_completion_matches symbol_name_match_type name_match_type, const char *, const char *, const char *); -extern completion_list - make_source_files_completion_list (const char *, const char *); +extern completion_list make_source_files_completion_list (const char *); /* Return whether SYM is a function/method, as opposed to a data symbol. */ -- 2.47.2