Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 9ac2013 in mainline


Ignore:
Timestamp:
2010-11-26T01:26:17Z (11 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master
Children:
0b0f4bb
Parents:
04357767
Message:

add format checking to more printf-like functions (fault_if_from_uspace, panic_common, fprintf, snprintf, asprintf)

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/interrupt.h

    r04357767 r9ac2013  
    3737
    3838#include <arch/interrupt.h>
     39#include <print.h>
    3940#include <typedefs.h>
    4041#include <proc/task.h>
     
    5758extern exc_table_t exc_table[];
    5859
    59 extern void fault_if_from_uspace(istate_t *, const char *, ...);
     60extern void fault_if_from_uspace(istate_t *, const char *, ...)
     61    PRINTF_ATTRIBUTE(2, 3);
    6062extern iroutine_t exc_register(unsigned int, const char *, bool, iroutine_t);
    6163extern void exc_dispatch(unsigned int, istate_t *);
  • kernel/generic/include/panic.h

    r04357767 r9ac2013  
    3737
    3838#include <typedefs.h>
     39#include <print.h>
    3940
    4041#define panic(fmt, ...) \
     
    6263
    6364extern void panic_common(panic_category_t, struct istate *, int,
    64     uintptr_t, const char *, ...) __attribute__ ((noreturn));
     65    uintptr_t, const char *, ...) __attribute__ ((noreturn))
     66    PRINTF_ATTRIBUTE(5, 6);
    6567
    6668#endif
  • uspace/lib/c/include/stdio.h

    r04357767 r9ac2013  
    4141#include <adt/list.h>
    4242
     43#ifndef NVERIFY_PRINTF
     44
     45#define PRINTF_ATTRIBUTE(start, end) \
     46        __attribute__((format(gnu_printf, start, end)))
     47
     48#else /* NVERIFY_PRINTF */
     49
     50#define PRINTF_ATTRIBUTE(start, end)
     51
     52#endif /* NVERIFY_PRINTF */
     53
    4354#define EOF  (-1)
    4455
     
    149160
    150161/* Formatted string output functions */
    151 extern int fprintf(FILE *, const char*, ...);
     162extern int fprintf(FILE *, const char*, ...)
     163    PRINTF_ATTRIBUTE(2, 3);
    152164extern int vfprintf(FILE *, const char *, va_list);
    153165
    154 extern int printf(const char *, ...);
     166extern int printf(const char *, ...)
     167    PRINTF_ATTRIBUTE(1, 2);
    155168extern int vprintf(const char *, va_list);
    156169
    157 extern int snprintf(char *, size_t , const char *, ...);
    158 extern int asprintf(char **, const char *, ...);
     170extern int snprintf(char *, size_t , const char *, ...)
     171    PRINTF_ATTRIBUTE(3, 4);
     172extern int asprintf(char **, const char *, ...)
     173    PRINTF_ATTRIBUTE(2, 3);
    159174extern int vsnprintf(char *, size_t, const char *, va_list);
    160175
Note: See TracChangeset for help on using the changeset viewer.