scudo/standalone: prepare for enabling format string checking
Move __attribute__((format)) to the function declarations in the header file.
It's almost pointless in the source file.
But disable the warning with -Wno-format for now
since there is a number of existing warnings.
Depends on D107984.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D108014
GitOrigin-RevId: 1fbe5fb81c80ebd481430cbe0b457d3726329b29
diff --git a/string_utils.cpp b/string_utils.cpp
index acf8588..13fdb9c 100644
--- a/string_utils.cpp
+++ b/string_utils.cpp
@@ -236,7 +236,6 @@
va_end(ArgsCopy);
}
-FORMAT(2, 3)
void ScopedString::append(const char *Format, ...) {
va_list Args;
va_start(Args, Format);
@@ -244,7 +243,6 @@
va_end(Args);
}
-FORMAT(1, 2)
void Printf(const char *Format, ...) {
va_list Args;
va_start(Args, Format);
diff --git a/string_utils.h b/string_utils.h
index 06d23d4..dd6ff78 100644
--- a/string_utils.h
+++ b/string_utils.h
@@ -26,15 +26,16 @@
String.push_back('\0');
}
void append(const char *Format, va_list Args);
- void append(const char *Format, ...);
+ void append(const char *Format, ...) FORMAT(2, 3);
void output() const { outputRaw(String.data()); }
private:
Vector<char> String;
};
-int formatString(char *Buffer, uptr BufferLength, const char *Format, ...);
-void Printf(const char *Format, ...);
+int formatString(char *Buffer, uptr BufferLength, const char *Format, ...)
+ FORMAT(3, 4);
+void Printf(const char *Format, ...) FORMAT(1, 2);
} // namespace scudo