[2/5] gdb: remove some trailing newlines from warning messages

Message ID 665671fabbb2fe3ce05578c0ce26ce7fe3d7f513.1680293848.git.aburgess@redhat.com
State New
Headers
Series gdb/testsuite: stricter matching for gdb_test |

Commit Message

Andrew Burgess March 31, 2023, 8:20 p.m. UTC
  While working on a later patch in this series, which tightens up some
of our pattern matching when using gdb_test, I ran into some failures
caused by some warnings having a trailing newline character.

The warning function already adds a trailing newline, and it is my
understanding that we should not be adding a second by including a
newline at the end of any warning message.

The problem cases I found were in language.c and remote.c, in this
patch I fix these cases, and also audited all the warning() calls in
these two files and fixed any additional problems I found.

In remote.c the warning actually had a newline character in the middle
of the warning message (in addition to the trailing newline), which
I've removed.  I don't think it's helpful to forcibly split a warning
as was done here -- in the middle of a sentence.  Additionally, the
message isn't even that long (71 characters), so I think removing this
newline is an improvement.

None of the expected test result need updating with this commit,
currently the patterns in gdb_test will match one or more newline
sequences, so the tests are as happy with one newline (after this
commit) as they are with two newlines (before this commit).  A later
commit will change gdb_test so that it is not so forgiving, and these
warnings would have caused some failures.
---
 gdb/language.c | 8 ++++----
 gdb/remote.c   | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)
  

Patch

diff --git a/gdb/language.c b/gdb/language.c
index 50a53c647f5..b7beb112702 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -229,7 +229,7 @@  show_range_command (struct ui_file *file, int from_tty,
       || ((range_check == range_check_on)
 	  != current_language->range_checking_on_by_default ()))
     warning (_("the current range check setting "
-	       "does not match the language.\n"));
+	       "does not match the language."));
 }
 
 /* Set command.  Change the setting for range checking.  */
@@ -266,7 +266,7 @@  set_range_command (const char *ignore,
       || ((range_check == range_check_on)
 	  != current_language->range_checking_on_by_default ()))
     warning (_("the current range check setting "
-	       "does not match the language.\n"));
+	       "does not match the language."));
 }
 
 /* Show command.  Display a warning if the case sensitivity setting does
@@ -303,7 +303,7 @@  show_case_command (struct ui_file *file, int from_tty,
 
   if (case_sensitivity != current_language->case_sensitivity ())
     warning (_("the current case sensitivity setting does not match "
-	       "the language.\n"));
+	       "the language."));
 }
 
 /* Set command.  Change the setting for case sensitivity.  */
@@ -335,7 +335,7 @@  set_case_command (const char *ignore, int from_tty, struct cmd_list_element *c)
 
    if (case_sensitivity != current_language->case_sensitivity ())
      warning (_("the current case sensitivity setting does not match "
-		"the language.\n"));
+		"the language."));
 }
 
 /* Set the status of range and type checking and case sensitivity based on
diff --git a/gdb/remote.c b/gdb/remote.c
index 526df313ea7..f436b8714cf 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -11250,8 +11250,8 @@  compare_sections_command (const char *args, int from_tty)
 	}
     }
   if (mismatched > 0)
-    warning (_("One or more sections of the target image does not match\n\
-the loaded file\n"));
+    warning (_("One or more sections of the target image does "
+	       "not match the loaded file"));
   if (args && !matched)
     gdb_printf (_("No loaded section named '%s'.\n"), args);
 }