# HG changeset patch # User Mike Becker # Date 1671545288 -3600 # Node ID d4845058239a26c879c54cddddce922b9c03e944 # Parent f78d3b77d4563dc6adbb90b6c2ed95938698522a add attributes to printf functions diff -r f78d3b77d456 -r d4845058239a src/cx/printf.h --- a/src/cx/printf.h Tue Dec 20 14:14:09 2022 +0100 +++ b/src/cx/printf.h Tue Dec 20 15:08:08 2022 +0100 @@ -55,7 +55,13 @@ * @param ... additional arguments * @return the total number of bytes written */ -int cx_fprintf(void *stream, cx_write_func wfc, char const *fmt, ...); +__attribute__((__nonnull__(1, 2, 3), __format__(printf, 3, 4))) +int cx_fprintf( + void *stream, + cx_write_func wfc, + char const *fmt, + ... +); /** * A \c vfprintf like function which writes the output to a stream by @@ -68,7 +74,13 @@ * @return the total number of bytes written * @see cx_fprintf() */ -int cx_vfprintf(void *stream, cx_write_func wfc, char const *fmt, va_list ap); +__attribute__((__nonnull__)) +int cx_vfprintf( + void *stream, + cx_write_func wfc, + char const *fmt, + va_list ap +); /** * A \c asprintf like function which allocates space for a string @@ -82,7 +94,12 @@ * @return the formatted string * @see cx_strfree_a() */ -cxmutstr cx_asprintf_a(CxAllocator *allocator, char const *fmt, ...); +__attribute__((__nonnull__(1, 2), __format__(printf, 2, 3))) +cxmutstr cx_asprintf_a( + CxAllocator *allocator, + char const *fmt, + ... +); /** * A \c asprintf like function which allocates space for a string @@ -110,7 +127,12 @@ * @return the formatted string * @see cx_asprintf_a() */ -cxmutstr cx_vasprintf_a(CxAllocator *allocator, char const *fmt, va_list ap); +__attribute__((__nonnull__)) +cxmutstr cx_vasprintf_a( + CxAllocator *allocator, + char const *fmt, + va_list ap +); /** * A \c vasprintf like function which allocates space for a string @@ -128,7 +150,7 @@ /** * A \c printf like function which writes the output to a CxBuffer. * - * @param buffer the buffer the data is written to + * @param buffer a pointer to the buffer the data is written to * @param fmt the format string * @param ... additional arguments * @return the total number of bytes written