From: Simon Marchi Date: Thu, 20 Oct 2022 02:00:59 +0000 (-0400) Subject: gdbsupport: change xml_escape_text_append's parameter from pointer to reference X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=de75275fe54c5536c8238f0f3f88bb7ac2222942;p=binutils-gdb.git gdbsupport: change xml_escape_text_append's parameter from pointer to reference The passed in string can't be nullptr, it makes more sense to pass in a reference. Change-Id: Idc8bd38abe1d6d9b44aa227d7856956848c233b3 --- diff --git a/gdb/unittests/xml-utils-selftests.c b/gdb/unittests/xml-utils-selftests.c index 08a48f686aa..f86e1e1bc07 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 = " &"; const char *expected_output = "foo<this isn't="xml"> &"; - 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 6f96e16d6f0..5e412315e6d 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, "", paddress (lm_addr), paddress (l_addr), diff --git a/gdbserver/netbsd-low.cc b/gdbserver/netbsd-low.cc index f05bcd4e173..af2c6c82b90 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, "", (unsigned long) lm_addr, (unsigned long) l_addr, diff --git a/gdbsupport/xml-utils.cc b/gdbsupport/xml-utils.cc index ec5e943828b..e47e23ced59 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 += "'"; + result += "'"; break; case '\"': - *result += """; + result += """; break; case '&': - *result += "&"; + result += "&"; break; case '<': - *result += "<"; + result += "<"; break; case '>': - *result += ">"; + result += ">"; break; default: - *result += text[i]; + result += text[i]; break; } } diff --git a/gdbsupport/xml-utils.h b/gdbsupport/xml-utils.h index 4df2f8ab6f6..695263c5b37 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 */