OSDN Git Service

Adapt to google::protobuf::int64 type change and scoped_ptr removal
authorColin Cross <ccross@android.com>
Wed, 14 Aug 2019 00:03:15 +0000 (17:03 -0700)
committerColin Cross <ccross@android.com>
Thu, 5 Sep 2019 21:46:16 +0000 (14:46 -0700)
Protobuf 3.9.1 redefines google::protobuf::int64 from long long to
int64_t, which is sometimes long and sometimes long long.  Use
PRId64 to print it.

scoped_ptr has been removed, use std::unique_ptr instead.

Bug: 117607748
Test: m checkbuild
Change-Id: Idfcaba262c27cf2b895a0a6ded8394c8465547e8
Merged-In: Idfcaba262c27cf2b895a0a6ded8394c8465547e8

boottime_tools/bootio/bootio_collector.cpp
libjsonpb/parse/jsonpb.cpp

index 495a9aa..dc13525 100644 (file)
@@ -275,10 +275,8 @@ void PrintPids(DataContainer& data, std::unordered_map<int, uint64_t>& cpuDataMa
             stats.rbytes += (newerSample->readbytes() - olderSample->readbytes());
             stats.wbytes += (newerSample->writebytes() - olderSample->writebytes());
 
-            // Note that all of these are explicitly `long long`s, not int64_t,
-            // so we can't use PRId64 here.
-#define NUMBER "%-13lld"
-            printf("%5lld - %-5lld  " NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER "%-9.2f\n",
+#define NUMBER "%-13" PRId64
+            printf("%5" PRId64 " - %-5" PRId64 "  " NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER "%-9.2f\n",
 #undef NUMBER
                    olderSample->uptime(),
                    newerSample->uptime(),
@@ -292,7 +290,7 @@ void PrintPids(DataContainer& data, std::unordered_map<int, uint64_t>& cpuDataMa
             isFirstSample = false;
         }
         printf("-----------------------------------------------------------------------------\n");
-#define NUMBER "%-13lld"
+#define NUMBER "%-13" PRId64
         printf("%-15s" NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER "\n",
 #undef NUMBER
                "Total",
index bd95dbd..d7feb67 100644 (file)
@@ -27,7 +27,6 @@ namespace jsonpb {
 
 using google::protobuf::DescriptorPool;
 using google::protobuf::Message;
-using google::protobuf::scoped_ptr;
 using google::protobuf::util::NewTypeResolverForDescriptorPool;
 using google::protobuf::util::TypeResolver;
 
@@ -38,7 +37,7 @@ std::string GetTypeUrl(const Message& message) {
 }
 
 ErrorOr<std::string> MessageToJsonString(const Message& message) {
-    scoped_ptr<TypeResolver> resolver(
+    std::unique_ptr<TypeResolver> resolver(
             NewTypeResolverForDescriptorPool(kTypeUrlPrefix, DescriptorPool::generated_pool()));
 
     google::protobuf::util::JsonOptions options;
@@ -56,7 +55,7 @@ ErrorOr<std::string> MessageToJsonString(const Message& message) {
 
 namespace internal {
 ErrorOr<std::monostate> JsonStringToMessage(const std::string& content, Message* message) {
-    scoped_ptr<TypeResolver> resolver(
+    std::unique_ptr<TypeResolver> resolver(
             NewTypeResolverForDescriptorPool(kTypeUrlPrefix, DescriptorPool::generated_pool()));
 
     std::string binary;