[gem5-dev] Change in gem5/gem5[develop]: base: Fix incorrect use of Logger::print

2021-03-18 Thread Daniel Carvalho (Gerrit) via gem5-dev
Daniel Carvalho has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/41399 )


Change subject: base: Fix incorrect use of Logger::print
..

base: Fix incorrect use of Logger::print

Previously when a formatted message was printed in a
Logger it would use the wrong function, and thus skip
the warning triggered by ccprintf. Fix this by merging
two prints to avoid ambiguity.

Change-Id: Idc51d2ef28ab4721d2be16f3e5fce19c494a0d47
Signed-off-by: Daniel R. Carvalho 
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/41399
Reviewed-by: Giacomo Travaglini 
Maintainer: Giacomo Travaglini 
Tested-by: kokoro 
---
M src/base/logging.hh
1 file changed, 9 insertions(+), 13 deletions(-)

Approvals:
  Giacomo Travaglini: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/base/logging.hh b/src/base/logging.hh
index 29a9563..87bca8e 100644
--- a/src/base/logging.hh
+++ b/src/base/logging.hh
@@ -90,24 +90,20 @@

 virtual ~Logger() {};

-void
-print(const Loc &loc, const std::string &str)
-{
-std::stringstream ss;
-ss << prefix << str;
-if (str.length() && str.back() != '\n' && str.back() != '\r')
-ss << std::endl;
-if (!enabled)
-return;
-log(loc, ss.str());
-}
-
 template void
 print(const Loc &loc, const char *format, const Args &...args)
 {
 std::stringstream ss;
 ccprintf(ss, format, args...);
-print(loc, ss.str());
+const std::string str = ss.str();
+
+std::stringstream ss_formatted;
+ss_formatted << prefix << str;
+if (str.length() && str.back() != '\n' && str.back() != '\r')
+ss_formatted << std::endl;
+if (!enabled)
+return;
+log(loc, ss_formatted.str());
 }

 template void

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/41399
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: Idc51d2ef28ab4721d2be16f3e5fce19c494a0d47
Gerrit-Change-Number: 41399
Gerrit-PatchSet: 7
Gerrit-Owner: Daniel Carvalho 
Gerrit-Reviewer: Bobby R. Bruce 
Gerrit-Reviewer: Daniel Carvalho 
Gerrit-Reviewer: Giacomo Travaglini 
Gerrit-Reviewer: kokoro 
Gerrit-MessageType: merged
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

[gem5-dev] Change in gem5/gem5[develop]: base: Fix incorrect use of Logger::print

2021-02-14 Thread Daniel Carvalho (Gerrit) via gem5-dev
Daniel Carvalho has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/41399 )



Change subject: base: Fix incorrect use of Logger::print
..

base: Fix incorrect use of Logger::print

Previously when a formatted message was printed in a
Logger it would use the wrong function, and thus skip
the warning triggered by ccprintf. Fix this by merging
two prints to avoid ambiguity.

Change-Id: Idc51d2ef28ab4721d2be16f3e5fce19c494a0d47
Signed-off-by: Daniel R. Carvalho 
---
M src/base/logging.hh
M src/base/logging.test.cc
2 files changed, 10 insertions(+), 14 deletions(-)



diff --git a/src/base/logging.hh b/src/base/logging.hh
index e740e1d..4ef700a 100644
--- a/src/base/logging.hh
+++ b/src/base/logging.hh
@@ -90,24 +90,20 @@

 virtual ~Logger() {};

-void
-print(const Loc &loc, const std::string &str)
-{
-std::stringstream ss;
-ss << prefix << str;
-if (str.length() && str.back() != '\n' && str.back() != '\r')
-ss << std::endl;
-if (!enabled)
-return;
-log(loc, ss.str());
-}
-
 template void
 print(const Loc &loc, const char *format, const Args &...args)
 {
 std::stringstream ss;
 ccprintf(ss, format, args...);
-print(loc, ss.str());
+const std::string str = ss.str();
+
+std::stringstream ss_formatted;
+ss_formatted << prefix << str;
+if (str.length() && str.back() != '\n' && str.back() != '\r')
+ss_formatted << std::endl;
+if (!enabled)
+return;
+log(loc, ss_formatted.str());
 }

 template void
diff --git a/src/base/logging.test.cc b/src/base/logging.test.cc
index 3075ab7..c979148 100644
--- a/src/base/logging.test.cc
+++ b/src/base/logging.test.cc
@@ -141,7 +141,7 @@
  * Test the variadic-arg print for strings with arguments missing using
  * TestLogger.
  */
-TEST(LoggingTest, DISABLED_TestLoggerVariadicStringMissingPrint)
+TEST(LoggingTest, TestLoggerVariadicStringMissingPrint)
 {
 TestLogger logger("test: ");


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/41399
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: Idc51d2ef28ab4721d2be16f3e5fce19c494a0d47
Gerrit-Change-Number: 41399
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Carvalho 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s