public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [pushed] gdbsupport: change xml_escape_text_append's parameter from pointer to reference
Date: Thu, 15 Dec 2022 21:56:48 -0500	[thread overview]
Message-ID: <20221216025648.1186579-1-simon.marchi@polymtl.ca> (raw)

The passed in string can't be nullptr, it makes more sense to pass in a
reference.

Change-Id: Idc8bd38abe1d6d9b44aa227d7856956848c233b3
---
 gdb/unittests/xml-utils-selftests.c |  2 +-
 gdbserver/linux-low.cc              |  2 +-
 gdbserver/netbsd-low.cc             |  2 +-
 gdbsupport/xml-utils.cc             | 16 ++++++++--------
 gdbsupport/xml-utils.h              |  2 +-
 5 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/gdb/unittests/xml-utils-selftests.c b/gdb/unittests/xml-utils-selftests.c
index 08a48f686aa9..f86e1e1bc077 100644
--- a/gdb/unittests/xml-utils-selftests.c
+++ b/gdb/unittests/xml-utils-selftests.c
@@ -40,7 +40,7 @@ static void test_xml_escape_text_append ()
   const char *input = "<this isn't=\"xml\"> &";
   const char *expected_output
     = "foo<xml>&lt;this isn&apos;t=&quot;xml&quot;&gt; &amp;";
-  xml_escape_text_append (&actual_output, input);
+  xml_escape_text_append (actual_output, input);
 
   SELF_CHECK (actual_output == expected_output);
 }
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 6f96e16d6f04..5e412315e6dd 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6520,7 +6520,7 @@ read_link_map (std::string &document, CORE_ADDR lmid, CORE_ADDR lm_addr,
       if (libname[0] != '\0')
 	{
 	  string_appendf (document, "<library name=\"");
-	  xml_escape_text_append (&document, (char *) libname);
+	  xml_escape_text_append (document, (char *) libname);
 	  string_appendf (document, "\" lm=\"0x%s\" l_addr=\"0x%s\" "
 			  "l_ld=\"0x%s\" lmid=\"0x%s\"/>",
 			  paddress (lm_addr), paddress (l_addr),
diff --git a/gdbserver/netbsd-low.cc b/gdbserver/netbsd-low.cc
index f05bcd4e173f..af2c6c82b908 100644
--- a/gdbserver/netbsd-low.cc
+++ b/gdbserver/netbsd-low.cc
@@ -1086,7 +1086,7 @@ netbsd_qxfer_libraries_svr4 (const pid_t pid, const char *annex,
 		}
 
 	      string_appendf (document, "<library name=\"");
-	      xml_escape_text_append (&document, (char *) libname);
+	      xml_escape_text_append (document, (char *) libname);
 	      string_appendf (document, "\" lm=\"0x%lx\" "
 			      "l_addr=\"0x%lx\" l_ld=\"0x%lx\"/>",
 			      (unsigned long) lm_addr, (unsigned long) l_addr,
diff --git a/gdbsupport/xml-utils.cc b/gdbsupport/xml-utils.cc
index ec5e943828b7..e47e23ced590 100644
--- a/gdbsupport/xml-utils.cc
+++ b/gdbsupport/xml-utils.cc
@@ -27,7 +27,7 @@ xml_escape_text (const char *text)
 {
   std::string result;
 
-  xml_escape_text_append (&result, text);
+  xml_escape_text_append (result, text);
 
   return result;
 }
@@ -35,29 +35,29 @@ xml_escape_text (const char *text)
 /* See xml-utils.h.  */
 
 void
-xml_escape_text_append (std::string *result, const char *text)
+xml_escape_text_append (std::string &result, const char *text)
 {
   /* Expand the result.  */
   for (int i = 0; text[i] != '\0'; i++)
     switch (text[i])
       {
       case '\'':
-	*result += "&apos;";
+	result += "&apos;";
 	break;
       case '\"':
-	*result += "&quot;";
+	result += "&quot;";
 	break;
       case '&':
-	*result += "&amp;";
+	result += "&amp;";
 	break;
       case '<':
-	*result += "&lt;";
+	result += "&lt;";
 	break;
       case '>':
-	*result += "&gt;";
+	result += "&gt;";
 	break;
       default:
-	*result += text[i];
+	result += text[i];
 	break;
       }
 }
diff --git a/gdbsupport/xml-utils.h b/gdbsupport/xml-utils.h
index 4df2f8ab6f62..695263c5b379 100644
--- a/gdbsupport/xml-utils.h
+++ b/gdbsupport/xml-utils.h
@@ -28,6 +28,6 @@ extern std::string xml_escape_text (const char *text);
 /* Append TEXT to RESULT, with special characters replaced by entity
    references.  */
 
-extern void xml_escape_text_append (std::string *result, const char *text);
+extern void xml_escape_text_append (std::string &result, const char *text);
 
 #endif /* COMMON_XML_UTILS_H */

base-commit: f8631e5e04dbef678323e9be6b7329f39049d2c4
-- 
2.38.1


                 reply	other threads:[~2022-12-16  2:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221216025648.1186579-1-simon.marchi@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).