x86emu: Teach the debug code about varargs
With -Wformat-nonliteral and a debug build you'd get yelled at here: ../hw/xfree86/x86emu/x86emu/debug.h:188:9: warning: format not a string literal, argument types not checked [-Wformat-nonliteral] To fix this, rewrite the printf code to actually use varargs and the appropriate format attribute. All callers of DECODE_PRINTF() pass a string with no % specifiers, so we pass that as the argument to printf("%s"). For DECODE_PRINTF2() we just pass the args through. Signed-off-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
parent
1274015186
commit
15d91df474
|
@ -40,8 +40,8 @@
|
|||
#include "x86emu/x86emui.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifndef NO_SYS_HEADERS
|
||||
#include <stdarg.h>
|
||||
#ifndef NO_SYS_HEADERS
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
|
@ -174,18 +174,14 @@ x86emu_inc_decoded_inst_len(int x)
|
|||
}
|
||||
|
||||
void
|
||||
x86emu_decode_printf(const char *x)
|
||||
{
|
||||
sprintf(M.x86.decoded_buf + M.x86.enc_str_pos, "%s", x);
|
||||
M.x86.enc_str_pos += strlen(x);
|
||||
}
|
||||
|
||||
void
|
||||
x86emu_decode_printf2(const char *x, int y)
|
||||
x86emu_decode_printf(const char *x, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char temp[100];
|
||||
|
||||
snprintf(temp, sizeof(temp), x, y);
|
||||
va_start(ap, x);
|
||||
vsnprintf(temp, sizeof(temp), x, ap);
|
||||
va_end(ap);
|
||||
sprintf(M.x86.decoded_buf + M.x86.enc_str_pos, "%s", temp);
|
||||
M.x86.enc_str_pos += strlen(temp);
|
||||
}
|
||||
|
|
|
@ -102,9 +102,9 @@
|
|||
#ifdef DEBUG
|
||||
|
||||
#define DECODE_PRINTF(x) if (DEBUG_DECODE()) \
|
||||
x86emu_decode_printf(x)
|
||||
x86emu_decode_printf("%s",x)
|
||||
#define DECODE_PRINTF2(x,y) if (DEBUG_DECODE()) \
|
||||
x86emu_decode_printf2(x,y)
|
||||
x86emu_decode_printf(x,y)
|
||||
|
||||
/*
|
||||
* The following allow us to look at the bytes of an instruction. The
|
||||
|
@ -189,8 +189,7 @@ extern "C" { /* Use "C" linkage when in C++ mode */
|
|||
#endif
|
||||
|
||||
extern void x86emu_inc_decoded_inst_len(int x);
|
||||
extern void x86emu_decode_printf(const char *x);
|
||||
extern void x86emu_decode_printf2(const char *x, int y);
|
||||
extern void x86emu_decode_printf(const char *x, ...) _X_ATTRIBUTE_PRINTF(1,2);
|
||||
extern void x86emu_just_disassemble(void);
|
||||
extern void x86emu_single_step(void);
|
||||
extern void x86emu_end_instr(void);
|
||||
|
|
Loading…
Reference in New Issue
Block a user