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
     1.1 --- a/src/cx/printf.h	Tue Dec 20 14:14:09 2022 +0100
     1.2 +++ b/src/cx/printf.h	Tue Dec 20 15:08:08 2022 +0100
     1.3 @@ -55,7 +55,13 @@
     1.4   * @param ... additional arguments
     1.5   * @return the total number of bytes written
     1.6   */
     1.7 -int cx_fprintf(void *stream, cx_write_func wfc, char const *fmt, ...);
     1.8 +__attribute__((__nonnull__(1, 2, 3), __format__(printf, 3, 4)))
     1.9 +int cx_fprintf(
    1.10 +        void *stream,
    1.11 +        cx_write_func wfc,
    1.12 +        char const *fmt,
    1.13 +        ...
    1.14 +);
    1.15  
    1.16  /**
    1.17   * A \c vfprintf like function which writes the output to a stream by
    1.18 @@ -68,7 +74,13 @@
    1.19   * @return the total number of bytes written
    1.20   * @see cx_fprintf()
    1.21   */
    1.22 -int cx_vfprintf(void *stream, cx_write_func wfc, char const *fmt, va_list ap);
    1.23 +__attribute__((__nonnull__))
    1.24 +int cx_vfprintf(
    1.25 +        void *stream,
    1.26 +        cx_write_func wfc,
    1.27 +        char const *fmt,
    1.28 +        va_list ap
    1.29 +);
    1.30  
    1.31  /**
    1.32   * A \c asprintf like function which allocates space for a string
    1.33 @@ -82,7 +94,12 @@
    1.34   * @return the formatted string
    1.35   * @see cx_strfree_a()
    1.36   */
    1.37 -cxmutstr cx_asprintf_a(CxAllocator *allocator, char const *fmt, ...);
    1.38 +__attribute__((__nonnull__(1, 2), __format__(printf, 2, 3)))
    1.39 +cxmutstr cx_asprintf_a(
    1.40 +        CxAllocator *allocator,
    1.41 +        char const *fmt,
    1.42 +        ...
    1.43 +);
    1.44  
    1.45  /**
    1.46   * A \c asprintf like function which allocates space for a string
    1.47 @@ -110,7 +127,12 @@
    1.48   * @return the formatted string
    1.49   * @see cx_asprintf_a()
    1.50   */
    1.51 -cxmutstr cx_vasprintf_a(CxAllocator *allocator, char const *fmt, va_list ap);
    1.52 +__attribute__((__nonnull__))
    1.53 +cxmutstr cx_vasprintf_a(
    1.54 +        CxAllocator *allocator,
    1.55 +        char const *fmt,
    1.56 +        va_list ap
    1.57 +);
    1.58  
    1.59  /**
    1.60  * A \c vasprintf like function which allocates space for a string
    1.61 @@ -128,7 +150,7 @@
    1.62  /**
    1.63   * A \c printf like function which writes the output to a CxBuffer.
    1.64   *
    1.65 - * @param buffer the buffer the data is written to
    1.66 + * @param buffer a pointer to the buffer the data is written to
    1.67   * @param fmt the format string
    1.68   * @param ... additional arguments
    1.69   * @return the total number of bytes written

mercurial