You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2012/07/09 23:46:49 UTC

svn commit: r1359421 - in /incubator/mesos/trunk/src: common/utils.hpp configurator/configuration.hpp master/master.cpp tests/strings_tests.cpp zookeeper/group.cpp

Author: benh
Date: Mon Jul  9 21:46:48 2012
New Revision: 1359421

URL: http://svn.apache.org/viewvc?rev=1359421&view=rev
Log:
Updated all calls to 'strings::format' to remove need for invoking
'c_str()' on std::string arguments
(https://reviews.apache.org/r/5710).

Modified:
    incubator/mesos/trunk/src/common/utils.hpp
    incubator/mesos/trunk/src/configurator/configuration.hpp
    incubator/mesos/trunk/src/master/master.cpp
    incubator/mesos/trunk/src/tests/strings_tests.cpp
    incubator/mesos/trunk/src/zookeeper/group.cpp

Modified: incubator/mesos/trunk/src/common/utils.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/common/utils.hpp?rev=1359421&r1=1359420&r2=1359421&view=diff
==============================================================================
--- incubator/mesos/trunk/src/common/utils.hpp (original)
+++ incubator/mesos/trunk/src/common/utils.hpp Mon Jul  9 21:46:48 2012
@@ -83,10 +83,10 @@ Try<T> numify(const std::string& s)
   try {
     return boost::lexical_cast<T>(s);
   } catch (const boost::bad_lexical_cast&) {
-    const Try<std::string>& message = strings::format(
-      "Failed to convert '%s' to number", s.c_str());
-    return Try<T>::error(
-      message.isSome() ? message.get() : "Failed to convert to number");
+    const Try<std::string>& message =
+      strings::format("Failed to convert '%s' to number", s);
+    CHECK(message.isSome());
+    return Try<T>::error(message.get());
   }
 }
 
@@ -608,7 +608,7 @@ inline Try<int> shell(std::ostream* os, 
   va_list args;
   va_start(args, fmt);
 
-  const Try<std::string>& cmdline = strings::format(fmt, args);
+  const Try<std::string>& cmdline = strings::internal::format(fmt, args);
 
   va_end(args);
 

Modified: incubator/mesos/trunk/src/configurator/configuration.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/configurator/configuration.hpp?rev=1359421&r1=1359420&r2=1359421&view=diff
==============================================================================
--- incubator/mesos/trunk/src/configurator/configuration.hpp (original)
+++ incubator/mesos/trunk/src/configurator/configuration.hpp Mon Jul  9 21:46:48 2012
@@ -85,7 +85,7 @@ public:
       std::vector<std::string> parts = strings::split(line, "=");
       if (parts.size() != 2) {
         const Try<std::string>& error =
-          strings::format("Failed to parse '%s'", line.c_str());
+          strings::format("Failed to parse '%s'", line);
         throw ParseException(error.isSome() ? error.get() : "Failed to parse");
       }
       params[parts[0]] = parts[1];

Modified: incubator/mesos/trunk/src/master/master.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master/master.cpp?rev=1359421&r1=1359420&r2=1359421&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master/master.cpp (original)
+++ incubator/mesos/trunk/src/master/master.cpp Mon Jul  9 21:46:48 2012
@@ -265,7 +265,7 @@ void Master::initialize()
   // address and port from self() and the OS PID.
 
   Try<string> id =
-    strings::format("%s-%u-%u-%d", DateUtils::currentDate().c_str(),
+    strings::format("%s-%u-%u-%d", DateUtils::currentDate(),
                     self().ip, self().port, getpid());
 
   CHECK(!id.isError()) << id.error();

Modified: incubator/mesos/trunk/src/tests/strings_tests.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/strings_tests.cpp?rev=1359421&r1=1359420&r2=1359421&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/strings_tests.cpp (original)
+++ incubator/mesos/trunk/src/tests/strings_tests.cpp Mon Jul  9 21:46:48 2012
@@ -38,6 +38,12 @@ TEST(StringsTest, Format)
   result = strings::format("hello %s", "fourty-two");
   ASSERT_TRUE(result.isSome());
   EXPECT_EQ("hello fourty-two", result.get());
+
+  string hello = "hello";
+
+  result = strings::format("%s %s", hello, "fourty-two");
+  ASSERT_TRUE(result.isSome());
+  EXPECT_EQ("hello fourty-two", result.get());
 }
 
 

Modified: incubator/mesos/trunk/src/zookeeper/group.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/zookeeper/group.cpp?rev=1359421&r1=1359420&r2=1359421&view=diff
==============================================================================
--- incubator/mesos/trunk/src/zookeeper/group.cpp (original)
+++ incubator/mesos/trunk/src/zookeeper/group.cpp Mon Jul  9 21:46:48 2012
@@ -414,7 +414,7 @@ void GroupProcess::connected(bool reconn
       } else if (code != ZOK && code != ZNODEEXISTS) {
         Try<string> message = strings::format(
             "Failed to create '%s' in ZooKeeper: %s",
-            prefix.c_str(), zk->message(code));
+            prefix, zk->message(code));
         error = message.isSome()
           ? message.get()
           : "Failed to create node in ZooKeeper";
@@ -511,7 +511,7 @@ Result<Group::Membership> GroupProcess::
   } else if (code != ZOK) {
     Try<string> message = strings::format(
         "Failed to create ephemeral node at '%s' in ZooKeeper: %s",
-        znode.c_str(), zk->message(code));
+        znode, zk->message(code));
     return Result<Group::Membership>::error(
         message.isSome() ? message.get()
         : "Failed to create ephemeral node in ZooKeeper");
@@ -557,7 +557,7 @@ Result<bool> GroupProcess::doCancel(cons
   } else if (code != ZOK) {
     Try<string> message = strings::format(
         "Failed to remove ephemeral node '%s' in ZooKeeper: %s",
-        path.c_str(), zk->message(code));
+        path, zk->message(code));
     return Result<bool>::error(
         message.isSome() ? message.get()
         : "Failed to remove ephemeral node in ZooKeeper");
@@ -602,7 +602,7 @@ Result<string> GroupProcess::doData(cons
   } else if (code != ZOK) {
     Try<string> message = strings::format(
         "Failed to get data for ephemeral node '%s' in ZooKeeper: %s",
-        path.c_str(), zk->message(code));
+        path, zk->message(code));
     return Result<string>::error(
         message.isSome() ? message.get()
         : "Failed to get data for ephemeral node in ZooKeeper");
@@ -628,7 +628,7 @@ bool GroupProcess::cache()
   } else if (code != ZOK) {
     Try<string> message = strings::format(
         "Non-retryable error attempting to get children of '%s'"
-        " in ZooKeeper: %s", znode.c_str(), zk->message(code));
+        " in ZooKeeper: %s", znode, zk->message(code));
     error = message.isSome()
       ? message.get()
       : "Non-retryable error attempting to get children in ZooKeeper";