qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 01/20] disas/nanomips: Remove namespace img


From: Thomas Huth
Subject: Re: [PATCH 01/20] disas/nanomips: Remove namespace img
Date: Mon, 15 Aug 2022 15:55:45 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0

On 15/08/2022 09.26, Milica Lazarevic wrote:
Since there's no namespace feature in C, namespace img has been replaced
with adding the prefix "img" to the namespace members.

Prefix "img" has been added to the function names of functions that used
to be wrapped in namespace img. Those are img::format() functions.
I.e. replaced img::format with the img_format.

Typedef address that used to belong to namespace img now is called
img_address.

Signed-off-by: Milica Lazarevic <milica.lazarevic@syrmia.com>
---
  disas/nanomips.cpp | 1433 ++++++++++++++++++++++----------------------
  disas/nanomips.h   |   10 +-
  2 files changed, 713 insertions(+), 730 deletions(-)

diff --git a/disas/nanomips.cpp b/disas/nanomips.cpp
index 9be8df75dd..96b7bfd83b 100644
--- a/disas/nanomips.cpp
+++ b/disas/nanomips.cpp
@@ -137,131 +137,118 @@ int print_insn_nanomips(bfd_vma memaddr, struct 
disassemble_info *info)
  }
-namespace img
+std::string img_format(const char *format, ...)
  {
-    address addr32(address a)
-    {
-        return a;
+    char buffer[256];
+    va_list args;
+    va_start(args, format);
+    int err = vsprintf(buffer, format, args);
+    if (err < 0) {
+        perror(buffer);
      }
+    va_end(args);
+    return buffer;
+}
- std::string format(const char *format, ...)
-    {
-        char buffer[256];
-        va_list args;
-        va_start(args, format);
-        int err = vsprintf(buffer, format, args);
-        if (err < 0) {
-            perror(buffer);
-        }
-        va_end(args);
-        return buffer;
-    }
-
-    std::string format(const char *format,
-                       std::string s)
-    {
-        char buffer[256];
-
-        sprintf(buffer, format, s.c_str());
+std::string img_format(const char *format,
+                   std::string s)
+{
+    char buffer[256];
- return buffer;
-    }
+    sprintf(buffer, format, s.c_str());
- std::string format(const char *format,
-                       std::string s1,
-                       std::string s2)
-    {
-        char buffer[256];
+    return buffer;
+}
- sprintf(buffer, format, s1.c_str(), s2.c_str());
+std::string img_format(const char *format,
+                   std::string s1,
+                   std::string s2)
+{
+    char buffer[256];
- return buffer;
-    }
+    sprintf(buffer, format, s1.c_str(), s2.c_str());
- std::string format(const char *format,
-                       std::string s1,
-                       std::string s2,
-                       std::string s3)
-    {
-        char buffer[256];
+    return buffer;
+}
- sprintf(buffer, format, s1.c_str(), s2.c_str(), s3.c_str());
+std::string img_format(const char *format,
+                   std::string s1,
+                   std::string s2,
+                   std::string s3)
+{
+    char buffer[256];
- return buffer;
-    }
+    sprintf(buffer, format, s1.c_str(), s2.c_str(), s3.c_str());
- std::string format(const char *format,
-                       std::string s1,
-                       std::string s2,
-                       std::string s3,
-                       std::string s4)
-    {
-        char buffer[256];
+    return buffer;
+}
- sprintf(buffer, format, s1.c_str(), s2.c_str(), s3.c_str(),
-                                s4.c_str());
+std::string img_format(const char *format,
+                   std::string s1,
+                   std::string s2,
+                   std::string s3,
+                   std::string s4)
+{
+    char buffer[256];
- return buffer;
-    }
+    sprintf(buffer, format, s1.c_str(), s2.c_str(), s3.c_str(),
+                            s4.c_str());
- std::string format(const char *format,
-                       std::string s1,
-                       std::string s2,
-                       std::string s3,
-                       std::string s4,
-                       std::string s5)
-    {
-        char buffer[256];
+    return buffer;
+}
- sprintf(buffer, format, s1.c_str(), s2.c_str(), s3.c_str(),
-                                s4.c_str(), s5.c_str());
+std::string img_format(const char *format,
+                   std::string s1,
+                   std::string s2,
+                   std::string s3,
+                   std::string s4,
+                   std::string s5)
+{
+    char buffer[256];
- return buffer;
-    }
+    sprintf(buffer, format, s1.c_str(), s2.c_str(), s3.c_str(),
+                            s4.c_str(), s5.c_str());
- std::string format(const char *format,
-                       uint64 d,
-                       std::string s2)
-    {
-        char buffer[256];
+    return buffer;
+}
- sprintf(buffer, format, d, s2.c_str());
+std::string img_format(const char *format,
+                   uint64 d,
+                   std::string s2)
+{
+    char buffer[256];
- return buffer;
-    }
+    sprintf(buffer, format, d, s2.c_str());
- std::string format(const char *format,
-                       std::string s1,
-                       uint64 d,
-                       std::string s2)
-    {
-        char buffer[256];
+    return buffer;
+}
- sprintf(buffer, format, s1.c_str(), d, s2.c_str());
+std::string img_format(const char *format,
+                   std::string s1,
+                   uint64 d,
+                   std::string s2)
+{
+    char buffer[256];
- return buffer;
-    }
+    sprintf(buffer, format, s1.c_str(), d, s2.c_str());
- std::string format(const char *format,
-                       std::string s1,
-                       std::string s2,
-                       uint64 d)
-    {
-        char buffer[256];
+    return buffer;
+}
- sprintf(buffer, format, s1.c_str(), s2.c_str(), d);
+std::string img_format(const char *format,
+                   std::string s1,
+                   std::string s2,
+                   uint64 d)
+{
+    char buffer[256];
- return buffer;
-    }
+    sprintf(buffer, format, s1.c_str(), s2.c_str(), d);
- char as_char(int c)
-    {
-        return static_cast<char>(c);
-    }
-};

Since you've removed the (unused) as_char() function here...

@@ -764,9 +751,9 @@ std::string NMD::ADDRESS(uint64 value, int instruction_size)
  {
      /* token for string replace */
      /* const char TOKEN_REPLACE = (char)0xa2; */
-    img::address address = m_pc + value + instruction_size;
+    img_address address = m_pc + value + instruction_size;
      /* symbol replacement */
-    /* return img::as_char(TOKEN_REPLACE) + to_string(address); */
+    /* return img_as_char(TOKEN_REPLACE) + to_string(address); */
      return to_string(address);
  }

... you also might want to remove the comment that is using it here (including the TOKEN_REPLACE comment above)?

Anyway, the patch looks fine to me, so:
Reviewed-by: Thomas Huth <thuth@redhat.com>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]