Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1f40b2c1 authored by Elliott Hughes's avatar Elliott Hughes Committed by android-build-merger
Browse files

Merge "Simplify __attribute__((__printf__)) use."

am: 2aa50ff5

Change-Id: Idbbad879ce10878aef55c4ead9ecaee40a4c1a71
parents 057fb5be 2aa50ff5
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -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)));

+4 −5
Original line number Diff line number Diff line
@@ -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;
+6 −13
Original line number Diff line number Diff line
@@ -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
@@ -205,13 +200,11 @@ 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)));
        __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__(ADB_FORMAT_ARCHETYPE, 2, 3)));
extern int adb_printf(const char *format, ...)
    __attribute__((__format__(ADB_FORMAT_ARCHETYPE, 1, 2)));
        __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);
+2 −3
Original line number Diff line number Diff line
@@ -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.
+3 −7
Original line number Diff line number Diff line
@@ -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
Loading