Gabe Black has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/48423 )

Change subject: base: Fix base/cprintftime.cc.
......................................................................

base: Fix base/cprintftime.cc.

The compiler is unhappy that one of the parameters in a call to sprintf
is also the buffer it's supposed to output to, when that parameter is
marked "restrict", which means it shouldn't alias to other arguments.

Also, this code can't go inside the gem5 namespace, since it has a
main() function in it. The linker will look for main(), not
gem5::main().

Change-Id: Ib17c601aefdc3e7201eba021dafb1c51204d54bc
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48423
Maintainer: Gabe Black <[email protected]>
Reviewed-by: Daniel Carvalho <[email protected]>
Tested-by: kokoro <[email protected]>
---
M src/base/cprintftime.cc
1 file changed, 9 insertions(+), 11 deletions(-)

Approvals:
  Daniel Carvalho: Looks good to me, approved
  Gabe Black: Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/base/cprintftime.cc b/src/base/cprintftime.cc
index abd20fe..7700c38 100644
--- a/src/base/cprintftime.cc
+++ b/src/base/cprintftime.cc
@@ -36,9 +36,6 @@

 #include "base/cprintf.hh"

-namespace gem5
-{
-
 volatile int stop = false;

 void
@@ -65,30 +62,31 @@
     do_test(10);
     while (!stop) {
         std::stringstream result;
-        ccprintf(result,
-                 "this is a %s of %d iterations %3.2f %p\n",
-                 "test", iterations, 51.934, &result);
+        gem5::ccprintf(result,
+                       "this is a %s of %d iterations %3.2f %p\n",
+                       "test", iterations, 51.934, &result);

         iterations += 1;
     }

- cprintf("completed %d iterations of ccprintf in 10s, %f iterations/s\n",
+    gem5::cprintf(
+ "completed %d iterations of ccprintf in 10s, %f iterations/s\n",
             iterations, iterations / 10.0);

     do_test(10);
     while (!stop) {
         char result[1024];
+        int dummy;
         sprintf(result,
                  "this is a %s of %d iterations %3.2f %p\n",
-                 "test", iterations, 51.934, &result);
+                 "test", iterations, 51.934, &dummy);

         iterations += 1;
     }

-    cprintf("completed %d iterations of sprintf in 10s, %f iterations/s\n",
+    gem5::cprintf(
+            "completed %d iterations of sprintf in 10s, %f iterations/s\n",
             iterations, iterations / 10.0);

     return 0;
 }
-
-} // namespace gem5

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/48423
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ib17c601aefdc3e7201eba021dafb1c51204d54bc
Gerrit-Change-Number: 48423
Gerrit-PatchSet: 2
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Daniel Carvalho <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to