From 43b95eae1e56d289640160a451acc3a8fbfe15b2 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 13 Aug 2019 17:03:15 -0700 Subject: [PATCH] Adapt to google::protobuf::int64 type change and scoped_ptr removal 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 | 8 +++----- libjsonpb/parse/jsonpb.cpp | 5 ++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/boottime_tools/bootio/bootio_collector.cpp b/boottime_tools/bootio/bootio_collector.cpp index 495a9aa4..dc13525e 100644 --- a/boottime_tools/bootio/bootio_collector.cpp +++ b/boottime_tools/bootio/bootio_collector.cpp @@ -275,10 +275,8 @@ void PrintPids(DataContainer& data, std::unordered_map& 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& cpuDataMa isFirstSample = false; } printf("-----------------------------------------------------------------------------\n"); -#define NUMBER "%-13lld" +#define NUMBER "%-13" PRId64 printf("%-15s" NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER "\n", #undef NUMBER "Total", diff --git a/libjsonpb/parse/jsonpb.cpp b/libjsonpb/parse/jsonpb.cpp index bd95dbdf..d7feb670 100644 --- a/libjsonpb/parse/jsonpb.cpp +++ b/libjsonpb/parse/jsonpb.cpp @@ -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 MessageToJsonString(const Message& message) { - scoped_ptr resolver( + std::unique_ptr resolver( NewTypeResolverForDescriptorPool(kTypeUrlPrefix, DescriptorPool::generated_pool())); google::protobuf::util::JsonOptions options; @@ -56,7 +55,7 @@ ErrorOr MessageToJsonString(const Message& message) { namespace internal { ErrorOr JsonStringToMessage(const std::string& content, Message* message) { - scoped_ptr resolver( + std::unique_ptr resolver( NewTypeResolverForDescriptorPool(kTypeUrlPrefix, DescriptorPool::generated_pool())); std::string binary; -- 2.11.0