* [PATCH] memory: Remove unecessary variable in memory_region_escape_name()
@ 2023-07-13 6:45 Gavin Shan
0 siblings, 0 replies; only message in thread
From: Gavin Shan @ 2023-07-13 6:45 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-arm, pbonzini, peterx, david, philmd, shan.gavin
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-07-13 6:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-13 6:45 [PATCH] memory: Remove unecessary variable in memory_region_escape_name() Gavin Shan
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).