diff options
author | Elliott Hughes <enh@google.com> | 2018-06-26 13:06:15 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2018-06-26 13:07:21 -0700 |
commit | d8a4c60276667f6f08d02314da4eb6f0f741fb5d (patch) | |
tree | a1e47bcb7c2101647ef4f5bcb6b23c75a1730bf2 | |
parent | b8f4fe4fd46fb9c5e1f53d4f3fcc87c7bd63ee7d (diff) | |
download | system_core-d8a4c60276667f6f08d02314da4eb6f0f741fb5d.tar.gz system_core-d8a4c60276667f6f08d02314da4eb6f0f741fb5d.tar.bz2 system_core-d8a4c60276667f6f08d02314da4eb6f0f741fb5d.zip |
Simplify __attribute__((__printf__)) use.
We don't need this now everyone's using clang...
Bug: http://b/69933068
Test: ran tests
Change-Id: I88f0cf03981ade47e210387fd6f3a2706dfeb9b8
-rw-r--r-- | adb/adb.h | 2 | ||||
-rw-r--r-- | adb/client/file_sync_client.cpp | 9 | ||||
-rw-r--r-- | adb/sysdeps.h | 19 | ||||
-rw-r--r-- | adb/sysdeps_win32.cpp | 5 | ||||
-rw-r--r-- | base/include/android-base/stringprintf.h | 10 | ||||
-rw-r--r-- | fastboot/fastboot.h | 6 |
6 files changed, 17 insertions, 34 deletions
@@ -124,8 +124,6 @@ inline bool ConnectionStateIsOnline(ConnectionState state) { void print_packet(const char* label, apacket* p); -// These use the system (v)fprintf, not the adb prefixed ones defined in sysdeps.h, so they -// shouldn't be tagged with ADB_FORMAT_ARCHETYPE. void fatal(const char* fmt, ...) __attribute__((noreturn, format(__printf__, 1, 2))); void fatal_errno(const char* fmt, ...) __attribute__((noreturn, format(__printf__, 1, 2))); diff --git a/adb/client/file_sync_client.cpp b/adb/client/file_sync_client.cpp index 26f8d831c..12756413e 100644 --- a/adb/client/file_sync_client.cpp +++ b/adb/client/file_sync_client.cpp @@ -510,8 +510,7 @@ class SyncConnection { return false; } - - void Printf(const char* fmt, ...) __attribute__((__format__(ADB_FORMAT_ARCHETYPE, 2, 3))) { + void Printf(const char* fmt, ...) __attribute__((__format__(__printf__, 2, 3))) { std::string s; va_list ap; @@ -522,7 +521,7 @@ class SyncConnection { line_printer_.Print(s, LinePrinter::INFO); } - void Println(const char* fmt, ...) __attribute__((__format__(ADB_FORMAT_ARCHETYPE, 2, 3))) { + void Println(const char* fmt, ...) __attribute__((__format__(__printf__, 2, 3))) { std::string s; va_list ap; @@ -534,7 +533,7 @@ class SyncConnection { line_printer_.KeepInfoLine(); } - void Error(const char* fmt, ...) __attribute__((__format__(ADB_FORMAT_ARCHETYPE, 2, 3))) { + void Error(const char* fmt, ...) __attribute__((__format__(__printf__, 2, 3))) { std::string s = "adb: error: "; va_list ap; @@ -545,7 +544,7 @@ class SyncConnection { line_printer_.Print(s, LinePrinter::ERROR); } - void Warning(const char* fmt, ...) __attribute__((__format__(ADB_FORMAT_ARCHETYPE, 2, 3))) { + void Warning(const char* fmt, ...) __attribute__((__format__(__printf__, 2, 3))) { std::string s = "adb: warning: "; va_list ap; diff --git a/adb/sysdeps.h b/adb/sysdeps.h index fe0ecd6ea..f1197d74c 100644 --- a/adb/sysdeps.h +++ b/adb/sysdeps.h @@ -39,11 +39,6 @@ #include "sysdeps/network.h" #include "sysdeps/stat.h" -// Some printf-like functions are implemented in terms of -// android::base::StringAppendV, so they should use the same attribute for -// compile-time format string checking. -#define ADB_FORMAT_ARCHETYPE __printf__ - #ifdef _WIN32 // Clang-only nullability specifiers @@ -204,14 +199,12 @@ extern int adb_closedir(DIR* dir); extern int adb_utime(const char *, struct utimbuf *); extern int adb_chmod(const char *, int); -extern int adb_vfprintf(FILE *stream, const char *format, va_list ap) - __attribute__((__format__(ADB_FORMAT_ARCHETYPE, 2, 0))); -extern int adb_vprintf(const char *format, va_list ap) - __attribute__((__format__(ADB_FORMAT_ARCHETYPE, 1, 0))); -extern int adb_fprintf(FILE *stream, const char *format, ...) - __attribute__((__format__(ADB_FORMAT_ARCHETYPE, 2, 3))); -extern int adb_printf(const char *format, ...) - __attribute__((__format__(ADB_FORMAT_ARCHETYPE, 1, 2))); +extern int adb_vfprintf(FILE* stream, const char* format, va_list ap) + __attribute__((__format__(__printf__, 2, 0))); +extern int adb_vprintf(const char* format, va_list ap) __attribute__((__format__(__printf__, 1, 0))); +extern int adb_fprintf(FILE* stream, const char* format, ...) + __attribute__((__format__(__printf__, 2, 3))); +extern int adb_printf(const char* format, ...) __attribute__((__format__(__printf__, 1, 2))); extern int adb_fputs(const char* buf, FILE* stream); extern int adb_fputc(int ch, FILE* stream); diff --git a/adb/sysdeps_win32.cpp b/adb/sysdeps_win32.cpp index bfac34208..52f586ca2 100644 --- a/adb/sysdeps_win32.cpp +++ b/adb/sysdeps_win32.cpp @@ -2455,9 +2455,8 @@ static int _console_write_utf8(const char* const buf, const size_t buf_size, FIL } // Function prototype because attributes cannot be placed on func definitions. -static int _console_vfprintf(const HANDLE console, FILE* stream, - const char *format, va_list ap) - __attribute__((__format__(ADB_FORMAT_ARCHETYPE, 3, 0))); +static int _console_vfprintf(const HANDLE console, FILE* stream, const char* format, va_list ap) + __attribute__((__format__(__printf__, 3, 0))); // Internal function to format a UTF-8 string and write it to a Win32 console. // Returns -1 on error. diff --git a/base/include/android-base/stringprintf.h b/base/include/android-base/stringprintf.h index 517e69e17..c13d25d37 100644 --- a/base/include/android-base/stringprintf.h +++ b/base/include/android-base/stringprintf.h @@ -25,21 +25,17 @@ namespace base { // These printf-like functions are implemented in terms of vsnprintf, so they // use the same attribute for compile-time format string checking. -#define ANDROID_BASE_FORMAT_ARCHETYPE __printf__ // Returns a string corresponding to printf-like formatting of the arguments. -std::string StringPrintf(const char* fmt, ...) - __attribute__((__format__(ANDROID_BASE_FORMAT_ARCHETYPE, 1, 2))); +std::string StringPrintf(const char* fmt, ...) __attribute__((__format__(__printf__, 1, 2))); // Appends a printf-like formatting of the arguments to 'dst'. void StringAppendF(std::string* dst, const char* fmt, ...) - __attribute__((__format__(ANDROID_BASE_FORMAT_ARCHETYPE, 2, 3))); + __attribute__((__format__(__printf__, 2, 3))); // Appends a printf-like formatting of the arguments to 'dst'. void StringAppendV(std::string* dst, const char* format, va_list ap) - __attribute__((__format__(ANDROID_BASE_FORMAT_ARCHETYPE, 2, 0))); - -#undef ANDROID_BASE_FORMAT_ARCHETYPE + __attribute__((__format__(__printf__, 2, 0))); } // namespace base } // namespace android diff --git a/fastboot/fastboot.h b/fastboot/fastboot.h index dc822e8bf..50c70f325 100644 --- a/fastboot/fastboot.h +++ b/fastboot/fastboot.h @@ -79,11 +79,9 @@ void set_verbose(); // These printf-like functions are implemented in terms of vsnprintf, so they // use the same attribute for compile-time format string checking. -#define FASTBOOT_FORMAT_ARCHETYPE __printf__ void die(const char* fmt, ...) __attribute__((__noreturn__)) -__attribute__((__format__(FASTBOOT_FORMAT_ARCHETYPE, 1, 2))); -void verbose(const char* fmt, ...) __attribute__((__format__(FASTBOOT_FORMAT_ARCHETYPE, 1, 2))); -#undef FASTBOOT_FORMAT_ARCHETYPE +__attribute__((__format__(__printf__, 1, 2))); +void verbose(const char* fmt, ...) __attribute__((__format__(__printf__, 1, 2))); /* Current product */ extern char cur_product[FB_RESPONSE_SZ + 1]; |