From: Gavin Shan <gshan@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org, pbonzini@redhat.com, peterx@redhat.com,
david@redhat.com, philmd@linaro.org, shan.gavin@gmail.com
Subject: [PATCH] memory: Remove unecessary variable in memory_region_escape_name()
Date: Thu, 13 Jul 2023 16:45:45 +1000 [thread overview]
Message-ID: <20230713064545.427768-1-gshan@redhat.com> (raw)
The variable 'c' isn't needed because it can be replaced by '*p'
completely. Remove the unecessary variable 'c' to simplify the
function a bit.
No functional change intended.
Signed-off-by: Gavin Shan <gshan@redhat.com>
---
softmmu/memory.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/softmmu/memory.c b/softmmu/memory.c
index 7d9494ce70..1ae285bab8 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -1151,7 +1151,6 @@ static char *memory_region_escape_name(const char *name)
{
const char *p;
char *escaped, *q;
- uint8_t c;
size_t bytes = 0;
for (p = name; *p; p++) {
@@ -1163,14 +1162,14 @@ static char *memory_region_escape_name(const char *name)
escaped = g_malloc(bytes + 1);
for (p = name, q = escaped; *p; p++) {
- c = *p;
- if (unlikely(memory_region_need_escape(c))) {
+ if (likely(!memory_region_need_escape(*p))) {
+ *q++ = *p;
+ } else {
*q++ = '\\';
*q++ = 'x';
- *q++ = "0123456789abcdef"[c >> 4];
- c = "0123456789abcdef"[c & 15];
+ *q++ = "0123456789abcdef"[*p >> 4];
+ *q++ = "0123456789abcdef"[*p & 15];
}
- *q++ = c;
}
*q = 0;
return escaped;
--
2.41.0
reply other threads:[~2023-07-13 6:47 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=20230713064545.427768-1-gshan@redhat.com \
--to=gshan@redhat.com \
--cc=david@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=shan.gavin@gmail.com \
/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 NNTP newsgroup(s).