From 377954fdc63626359a56f1f8cf82fdb264004831 Mon Sep 17 00:00:00 2001 From: zijunzhao Date: Thu, 16 Feb 2023 23:29:54 +0000 Subject: [PATCH] Nullability check for error module Bugs: b/245972273 Test: adb shell Change-Id: I9d1c20cf2a7e1e4201c3c54a321c9d9f896c92e2 --- libc/include/err.h | 16 ++++++++-------- libc/include/errno.h | 2 +- libc/include/error.h | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libc/include/err.h b/libc/include/err.h index e91dac90b..af44514e9 100644 --- a/libc/include/err.h +++ b/libc/include/err.h @@ -50,7 +50,7 @@ __BEGIN_DECLS * * New code should consider error() in ``. */ -__noreturn void err(int __status, const char* __fmt, ...) __printflike(2, 3); +__noreturn void err(int __status, const char* _Nullable __fmt, ...) __printflike(2, 3); /** * [verr(3)](http://man7.org/linux/man-pages/man3/verr.3.html) outputs the program name, @@ -60,7 +60,7 @@ __noreturn void err(int __status, const char* __fmt, ...) __printflike(2, 3); * * New code should consider error() in ``. */ -__noreturn void verr(int __status, const char* __fmt, va_list __args) __printflike(2, 0); +__noreturn void verr(int __status, const char* _Nullable __fmt, va_list __args) __printflike(2, 0); /** * [errx(3)](http://man7.org/linux/man-pages/man3/errx.3.html) outputs the program name, and @@ -70,7 +70,7 @@ __noreturn void verr(int __status, const char* __fmt, va_list __args) __printfli * * New code should consider error() in ``. */ -__noreturn void errx(int __status, const char* __fmt, ...) __printflike(2, 3); +__noreturn void errx(int __status, const char* _Nullable __fmt, ...) __printflike(2, 3); /** * [verrx(3)](http://man7.org/linux/man-pages/man3/err.3.html) outputs the program name, and @@ -80,7 +80,7 @@ __noreturn void errx(int __status, const char* __fmt, ...) __printflike(2, 3); * * New code should consider error() in ``. */ -__noreturn void verrx(int __status, const char* __fmt, va_list __args) __printflike(2, 0); +__noreturn void verrx(int __status, const char* _Nullable __fmt, va_list __args) __printflike(2, 0); /** * [warn(3)](http://man7.org/linux/man-pages/man3/warn.3.html) outputs the program name, @@ -88,7 +88,7 @@ __noreturn void verrx(int __status, const char* __fmt, va_list __args) __printfl * * New code should consider error() in ``. */ -void warn(const char* __fmt, ...) __printflike(1, 2); +void warn(const char* _Nullable __fmt, ...) __printflike(1, 2); /** * [vwarn(3)](http://man7.org/linux/man-pages/man3/vwarn.3.html) outputs the program name, @@ -96,7 +96,7 @@ void warn(const char* __fmt, ...) __printflike(1, 2); * * New code should consider error() in ``. */ -void vwarn(const char* __fmt, va_list __args) __printflike(1, 0); +void vwarn(const char* _Nullable __fmt, va_list __args) __printflike(1, 0); /** * [warnx(3)](http://man7.org/linux/man-pages/man3/warnx.3.html) outputs the program name, and @@ -104,7 +104,7 @@ void vwarn(const char* __fmt, va_list __args) __printflike(1, 0); * * New code should consider error() in ``. */ -void warnx(const char* __fmt, ...) __printflike(1, 2); +void warnx(const char* _Nullable __fmt, ...) __printflike(1, 2); /** * [vwarnx(3)](http://man7.org/linux/man-pages/man3/warn.3.html) outputs the program name, and @@ -112,6 +112,6 @@ void warnx(const char* __fmt, ...) __printflike(1, 2); * * New code should consider error() in ``. */ -void vwarnx(const char* __fmt, va_list __args) __printflike(1, 0); +void vwarnx(const char* _Nullable __fmt, va_list __args) __printflike(1, 0); __END_DECLS diff --git a/libc/include/errno.h b/libc/include/errno.h index b6a4c7e14..d481cfc7b 100644 --- a/libc/include/errno.h +++ b/libc/include/errno.h @@ -49,7 +49,7 @@ __BEGIN_DECLS * * @private */ -int* __errno(void) __attribute_const__; +int* _Nonnull __errno(void) __attribute_const__; /** * [errno(3)](http://man7.org/linux/man-pages/man3/errno.3.html) is the last error on the calling diff --git a/libc/include/error.h b/libc/include/error.h index 036a8313c..187ee17e2 100644 --- a/libc/include/error.h +++ b/libc/include/error.h @@ -44,7 +44,7 @@ __BEGIN_DECLS * * Available since API level 23. */ -extern void (*error_print_progname)(void) __INTRODUCED_IN(23); +extern void (* _Nullable error_print_progname)(void) __INTRODUCED_IN(23); /** * [error_message_count(3)](http://man7.org/linux/man-pages/man3/error_message_count.3.html) is @@ -70,7 +70,7 @@ extern int error_one_per_line __INTRODUCED_IN(23); * * Available since API level 23. */ -void error(int __status, int __errno, const char* __fmt, ...) __printflike(3, 4) __INTRODUCED_IN(23); +void error(int __status, int __errno, const char* _Nonnull __fmt, ...) __printflike(3, 4) __INTRODUCED_IN(23); /** * [error_at_line(3)](http://man7.org/linux/man-pages/man3/error_at_line.3.html) formats the given @@ -80,6 +80,6 @@ void error(int __status, int __errno, const char* __fmt, ...) __printflike(3, 4) * * Available since API level 23. */ -void error_at_line(int __status, int __errno, const char* __filename, unsigned int __line_number, const char* __fmt, ...) __printflike(5, 6) __INTRODUCED_IN(23); +void error_at_line(int __status, int __errno, const char* _Nonnull __filename, unsigned int __line_number, const char* _Nonnull __fmt, ...) __printflike(5, 6) __INTRODUCED_IN(23); __END_DECLS