mirror of
https://github.com/netwide-assembler/nasm.git
synced 2024-11-21 03:14:19 +08:00
Add [v]printf_func() attributes where appropriate
Add a new macro vprintf_func() for vprintf-style functions, and add printf_func() and vprintf_func() attribute arguments whereever meaningful. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
parent
ed47b8ce3e
commit
c9467688b4
@ -337,7 +337,7 @@ static void list_downlevel(int type)
|
||||
}
|
||||
}
|
||||
|
||||
static void list_error(errflags severity, const char *fmt, ...)
|
||||
static void printf_func(2, 3) list_error(errflags severity, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
|
@ -326,6 +326,8 @@ static inline void *mempcpy(void *dst, const void *src, size_t n)
|
||||
*/
|
||||
#define printf_func(fmt, list) format_func3(printf,fmt,list)
|
||||
#define printf_func_ptr(fmt, list) format_func3_ptr(printf,fmt,list)
|
||||
#define vprintf_func(fmt) format_func3(printf,fmt,0)
|
||||
#define vprintf_func_ptr(fmt) format_func3_ptr(printf,fmt,0)
|
||||
|
||||
/* Determine probabilistically if something is a compile-time constant */
|
||||
#ifdef HAVE___BUILTIN_CONSTANT_P
|
||||
|
@ -72,8 +72,8 @@ fatal_func printf_func(2, 3) nasm_panicf(errflags flags, const char *fmt, ...);
|
||||
fatal_func nasm_panic_from_macro(const char *file, int line);
|
||||
#define panic() nasm_panic_from_macro(__FILE__, __LINE__);
|
||||
|
||||
void nasm_verror(errflags severity, const char *fmt, va_list ap);
|
||||
fatal_func nasm_verror_critical(errflags severity, const char *fmt, va_list ap);
|
||||
void vprintf_func(2) nasm_verror(errflags severity, const char *fmt, va_list ap);
|
||||
fatal_func vprintf_func(2) nasm_verror_critical(errflags severity, const char *fmt, va_list ap);
|
||||
|
||||
/*
|
||||
* These are the error severity codes which get passed as the first
|
||||
|
@ -83,9 +83,9 @@ char * safe_alloc end_with_null nasm_strcatn(const char *one, ...);
|
||||
* this additional storage.
|
||||
*/
|
||||
char * safe_alloc printf_func(1, 2) nasm_asprintf(const char *fmt, ...);
|
||||
char * safe_alloc nasm_vasprintf(const char *fmt, va_list ap);
|
||||
char * safe_alloc vprintf_func(1) nasm_vasprintf(const char *fmt, va_list ap);
|
||||
void * safe_alloc printf_func(2, 3) nasm_axprintf(size_t extra, const char *fmt, ...);
|
||||
void * safe_alloc nasm_vaxprintf(size_t extra, const char *fmt, va_list ap);
|
||||
void * safe_alloc vprintf_func(2) nasm_vaxprintf(size_t extra, const char *fmt, va_list ap);
|
||||
|
||||
/*
|
||||
* nasm_last_string_len() returns the length of the last string allocated
|
||||
|
@ -81,7 +81,7 @@ struct strlist * safe_alloc strlist_alloc(bool uniq);
|
||||
const struct strlist_entry *strlist_add(struct strlist *list, const char *str);
|
||||
const struct strlist_entry * printf_func(2, 3)
|
||||
strlist_printf(struct strlist *list, const char *fmt, ...);
|
||||
const struct strlist_entry *
|
||||
const struct strlist_entry * vprintf_func(2)
|
||||
strlist_vprintf(struct strlist *list, const char *fmt, va_list ap);
|
||||
const struct strlist_entry *
|
||||
strlist_find(const struct strlist *list, const char *str);
|
||||
|
@ -1128,15 +1128,15 @@ static void ieee_write_dword(struct ieeeSection *seg, int32_t data)
|
||||
ieee_write_byte(seg, (data >> 16) & 0xFF);
|
||||
ieee_write_byte(seg, (data >> 24) & 0xFF);
|
||||
}
|
||||
static void ieee_putascii(char *format, ...)
|
||||
static void printf_func(1, 2) ieee_putascii(char *format, ...)
|
||||
{
|
||||
char buffer[256];
|
||||
int i, l;
|
||||
size_t i, l;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
vsnprintf(buffer, sizeof(buffer), format, ap);
|
||||
l = strlen(buffer);
|
||||
l = vsnprintf(buffer, sizeof(buffer), format, ap);
|
||||
nasm_assert(l < sizeof(buffer));
|
||||
for (i = 0; i < l; i++)
|
||||
if ((uint8_t)buffer[i] > 31)
|
||||
checksum += buffer[i];
|
||||
|
Loading…
Reference in New Issue
Block a user