From f02251190f5908d2078e9fc11b92375dfc3a3054 Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Wed, 10 Oct 2018 09:47:43 -0700 Subject: Correct a couple of format strings Change a couple of fscanf-style format strings to use the format macro constants defined in cinttypes. This quashes -Wformat. PiperOrigin-RevId: 216545604 --- tensorflow/core/lib/strings/numbers.cc | 3 ++- tensorflow/core/util/command_line_flags.cc | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tensorflow/core/lib/strings/numbers.cc b/tensorflow/core/lib/strings/numbers.cc index 87aa5915ff..fff6f1fedc 100644 --- a/tensorflow/core/lib/strings/numbers.cc +++ b/tensorflow/core/lib/strings/numbers.cc @@ -19,6 +19,7 @@ limitations under the License. #include #include #include +#include #include #include #include @@ -391,7 +392,7 @@ string FpToString(Fprint fp) { bool StringToFp(const string& s, Fprint* fp) { char junk; uint64_t result; - if (sscanf(s.c_str(), "%lx%c", &result, &junk) == 1) { + if (sscanf(s.c_str(), "%" SCNx64 "%c", &result, &junk) == 1) { *fp = result; return true; } else { diff --git a/tensorflow/core/util/command_line_flags.cc b/tensorflow/core/util/command_line_flags.cc index 55f1e30880..f1196fdfec 100644 --- a/tensorflow/core/util/command_line_flags.cc +++ b/tensorflow/core/util/command_line_flags.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ +#include #include #include @@ -70,7 +71,7 @@ bool ParseInt64Flag(tensorflow::StringPiece arg, tensorflow::StringPiece flag, str_util::ConsumePrefix(&arg, "=")) { char extra; int64_t parsed_int64; - if (sscanf(arg.data(), "%ld%c", &parsed_int64, &extra) != 1) { + if (sscanf(arg.data(), "%" SCNd64 "%c", &parsed_int64, &extra) != 1) { LOG(ERROR) << "Couldn't interpret value " << arg << " for flag " << flag << "."; *value_parsing_ok = false; -- cgit v1.2.3