add attributes to printf functions

Tue, 20 Dec 2022 15:08:08 +0100

author
Mike Becker <universe@uap-core.de>
date
Tue, 20 Dec 2022 15:08:08 +0100
changeset 635
d4845058239a
parent 634
f78d3b77d456
child 636
cfcc8cf0168c

add attributes to printf functions

src/cx/printf.h file | annotate | diff | comparison | revisions
--- 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

mercurial