Annotate more functions with _Printf_format_string_

When the stringprintf.h functions were annotated with
_Printf_format_string_ there were some other functions that were
missed. This time I searched on PRINTF_FORMAT to make sure that all
functions annotated with it were annotated for VC++ as well.

The definitions and include for _Printf_format_string_ are also now
in the proper place in compiler_specific.h.

Any bugs that are found by this will show up in the next /analyze
report and will be fixed in a follow-on change. Bugs may be hiding
in Windows specific code or in code that uses unsupported flags such
as %zd.

This is a follow on to change 1372153002.

BUG=512298,427616

Review URL: https://codereview.chromium.org/1408243003

Cr-Commit-Position: refs/heads/master@{#354987}


CrOS-Libchrome-Original-Commit: 6a86501038891fd1633901de1edb5e3cd6af9f66
diff --git a/base/compiler_specific.h b/base/compiler_specific.h
index d5d38b7..402bc5d 100644
--- a/base/compiler_specific.h
+++ b/base/compiler_specific.h
@@ -9,6 +9,9 @@
 
 #if defined(COMPILER_MSVC)
 
+// For _Printf_format_string_.
+#include <sal.h>
+
 // Macros for suppressing and disabling warnings on MSVC.
 //
 // Warning numbers are enumerated at:
@@ -57,6 +60,7 @@
 
 #else  // Not MSVC
 
+#define _Printf_format_string_
 #define MSVC_SUPPRESS_WARNING(n)
 #define MSVC_PUSH_DISABLE_WARNING(n)
 #define MSVC_PUSH_WARNING_LEVEL(n)
diff --git a/base/strings/string_util.h b/base/strings/string_util.h
index 2578569..3976111 100644
--- a/base/strings/string_util.h
+++ b/base/strings/string_util.h
@@ -36,9 +36,14 @@
 
 // We separate the declaration from the implementation of this inline
 // function just so the PRINTF_FORMAT works.
-inline int snprintf(char* buffer, size_t size, const char* format, ...)
-    PRINTF_FORMAT(3, 4);
-inline int snprintf(char* buffer, size_t size, const char* format, ...) {
+inline int snprintf(char* buffer,
+                    size_t size,
+                    _Printf_format_string_ const char* format,
+                    ...) PRINTF_FORMAT(3, 4);
+inline int snprintf(char* buffer,
+                    size_t size,
+                    _Printf_format_string_ const char* format,
+                    ...) {
   va_list arguments;
   va_start(arguments, format);
   int result = vsnprintf(buffer, size, format, arguments);
diff --git a/base/strings/stringprintf.h b/base/strings/stringprintf.h
index 4b2eab1..7a75d89 100644
--- a/base/strings/stringprintf.h
+++ b/base/strings/stringprintf.h
@@ -13,14 +13,6 @@
 #include "base/compiler_specific.h"
 #include "build/build_config.h"
 
-#ifdef COMPILER_MSVC
-// For _Printf_format_string_.
-#include <sal.h>
-#else
-// For nacl builds when sal.h is not available.
-#define _Printf_format_string_
-#endif
-
 namespace base {
 
 // Return a C++ string given printf-like input.