Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1854)

Unified Diff: base/strings/safe_sprintf_unittest.cc

Issue 310323003: Fix SafeSPrintfTest.Truncation in base_unittests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change to uintptr_t Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/strings/safe_sprintf_unittest.cc
diff --git a/base/strings/safe_sprintf_unittest.cc b/base/strings/safe_sprintf_unittest.cc
index 937fa4eca2329342377ce1596199b62bf3b37935..c2033f32bc88b03afbeefd977a55c8a7d89f605f 100644
--- a/base/strings/safe_sprintf_unittest.cc
+++ b/base/strings/safe_sprintf_unittest.cc
@@ -4,6 +4,7 @@
#include "base/strings/safe_sprintf.h"
+#include <inttypes.h>
Mark Mentovai 2014/06/15 12:27:26 Does MSVC even have this header?
Yang Gu 2014/06/16 10:39:09 Not quite sure about MSVC. I searched the web and
#include <stdio.h>
#include <string.h>
@@ -424,9 +425,9 @@ void PrintLongString(char* buf, size_t sz) {
// are all really awkward.
char ref[256];
CHECK_LE(sz, sizeof(ref));
- sprintf(ref, "A long string: %%d 00DEADBEEF %lld 0x%llX <NULL>",
+ sprintf(ref, "A long string: %%d 00DEADBEEF %lld 0x%" PRIXPTR " <NULL>",
Mark Mentovai 2014/06/15 12:19:21 Why can’t you use %p here?
Yang Gu 2014/06/16 10:39:09 The actual format is in SafeSNPrintf(), where %p i
static_cast<long long>(std::numeric_limits<intptr_t>::min()),
Mark Mentovai 2014/06/15 12:19:22 Wouldn’t PRIdPTR (and no cast) be better here and
Mark Mentovai 2014/06/15 12:23:02 Mark Mentovai wrote:
Mark Mentovai 2014/06/15 12:27:26 Mark Mentovai wrote:
Yang Gu 2014/06/16 10:39:09 PRIdPTR is in decimal format, but we actually need
- (long long)PrintLongString);
+ (uintptr_t)PrintLongString);
ref[sz-1] = '\000';
#if defined(NDEBUG)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698