diff options
author | blueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-08-21 17:58:08 +0000 |
---|---|---|
committer | blueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-08-21 17:58:08 +0000 |
commit | 40e2f1cef09a948617b37be99006d47783957230 (patch) | |
tree | 35ce1129736b9c6833c2e5eda5c6015b7897c67f /i386-dis.c | |
parent | 6f7301abc2fa7e4e56e6cbe2d28b17e65cb715ec (diff) | |
download | qemu-40e2f1cef09a948617b37be99006d47783957230.tar.gz qemu-40e2f1cef09a948617b37be99006d47783957230.tar.bz2 qemu-40e2f1cef09a948617b37be99006d47783957230.zip |
Fix OpenBSD linker warnings
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5044 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'i386-dis.c')
-rw-r--r-- | i386-dis.c | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/i386-dis.c b/i386-dis.c index f8abf74b9b..0c97e1c7d1 100644 --- a/i386-dis.c +++ b/i386-dis.c @@ -37,6 +37,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <stdlib.h> #include "dis-asm.h" +#include "qemu-common.h" #define MAXLEN 20 @@ -59,7 +60,8 @@ static int putop PARAMS ((const char *, int)); static void oappend PARAMS ((const char *)); static void append_seg PARAMS ((void)); static void OP_indirE PARAMS ((int, int)); -static void print_operand_value PARAMS ((char *, int, bfd_vma)); +static void print_operand_value (char *buf, size_t bufsize, int hex, + bfd_vma disp); static void OP_E PARAMS ((int, int)); static void OP_G PARAMS ((int, int)); static bfd_vma get64 PARAMS ((void)); @@ -2512,7 +2514,7 @@ dofloat (sizeflag) /* Instruction fnstsw is only one with strange arg. */ if (floatop == 0xdf && codep[-1] == 0xe0) - strcpy (op1out, names16[0]); + pstrcpy (op1out, sizeof(op1out), names16[0]); } else { @@ -2540,7 +2542,7 @@ OP_STi (bytemode, sizeflag) int bytemode; int sizeflag; { - sprintf (scratchbuf, "%%st(%d)", rm); + snprintf (scratchbuf, sizeof(scratchbuf), "%%st(%d)", rm); oappend (scratchbuf + intel_syntax); } @@ -2573,7 +2575,7 @@ putop (template, sizeflag) if (*p == '}') { /* Alternative not valid. */ - strcpy (obuf, "(bad)"); + pstrcpy (obuf, sizeof(obuf), "(bad)"); obufp = obuf + 5; return 1; } @@ -2824,7 +2826,7 @@ static void oappend (s) const char *s; { - strcpy (obufp, s); + pstrcpy (obufp, (size_t)(obufp - obuf), s); obufp += strlen (s); } @@ -2874,10 +2876,7 @@ OP_indirE (bytemode, sizeflag) } static void -print_operand_value (buf, hex, disp) - char *buf; - int hex; - bfd_vma disp; +print_operand_value (char *buf, size_t bufsize, int hex, bfd_vma disp) { if (mode_64bit) { @@ -2887,9 +2886,9 @@ print_operand_value (buf, hex, disp) int i; buf[0] = '0'; buf[1] = 'x'; - sprintf_vma (tmp, disp); + snprintf_vma (tmp, sizeof(tmp), disp); for (i = 0; tmp[i] == '0' && tmp[i + 1]; i++); - strcpy (buf + 2, tmp + i); + pstrcpy (buf + 2, bufsize - 2, tmp + i); } else { @@ -2903,13 +2902,13 @@ print_operand_value (buf, hex, disp) /* Check for possible overflow on 0x8000000000000000. */ if (v < 0) { - strcpy (buf, "9223372036854775808"); + pstrcpy (buf, bufsize, "9223372036854775808"); return; } } if (!v) { - strcpy (buf, "0"); + pstrcpy (buf, bufsize, "0"); return; } @@ -2921,15 +2920,15 @@ print_operand_value (buf, hex, disp) v /= 10; i++; } - strcpy (buf, tmp + 29 - i); + pstrcpy (buf, bufsize, tmp + 29 - i); } } else { if (hex) - sprintf (buf, "0x%x", (unsigned int) disp); + snprintf (buf, bufsize, "0x%x", (unsigned int) disp); else - sprintf (buf, "%d", (int) disp); + snprintf (buf, bufsize, "%d", (int) disp); } } @@ -3054,7 +3053,7 @@ OP_E (bytemode, sizeflag) if (!intel_syntax) if (mod != 0 || (base & 7) == 5) { - print_operand_value (scratchbuf, !riprel, disp); + print_operand_value (scratchbuf, sizeof(scratchbuf), !riprel, disp); oappend (scratchbuf); if (riprel) { @@ -3115,14 +3114,14 @@ OP_E (bytemode, sizeflag) *obufp++ = separator_char; *obufp = '\0'; } - sprintf (scratchbuf, "%s", - mode_64bit && (sizeflag & AFLAG) - ? names64[index] : names32[index]); + snprintf (scratchbuf, sizeof(scratchbuf), "%s", + mode_64bit && (sizeflag & AFLAG) + ? names64[index] : names32[index]); } else - sprintf (scratchbuf, ",%s", - mode_64bit && (sizeflag & AFLAG) - ? names64[index] : names32[index]); + snprintf (scratchbuf, sizeof(scratchbuf), ",%s", + mode_64bit && (sizeflag & AFLAG) + ? names64[index] : names32[index]); oappend (scratchbuf); } if (!intel_syntax @@ -3133,7 +3132,7 @@ OP_E (bytemode, sizeflag) { *obufp++ = scale_char; *obufp = '\0'; - sprintf (scratchbuf, "%d", 1 << scale); + snprintf (scratchbuf, sizeof(scratchbuf), "%d", 1 << scale); oappend (scratchbuf); } } @@ -3149,7 +3148,8 @@ OP_E (bytemode, sizeflag) *obufp = '\0'; } - print_operand_value (scratchbuf, 0, disp); + print_operand_value (scratchbuf, sizeof(scratchbuf), 0, + disp); oappend (scratchbuf); } } @@ -3169,7 +3169,7 @@ OP_E (bytemode, sizeflag) oappend (names_seg[ds_reg - es_reg]); oappend (":"); } - print_operand_value (scratchbuf, 1, disp); + print_operand_value (scratchbuf, sizeof(scratchbuf), 1, disp); oappend (scratchbuf); } } @@ -3202,7 +3202,7 @@ OP_E (bytemode, sizeflag) if (!intel_syntax) if (mod != 0 || (rm & 7) == 6) { - print_operand_value (scratchbuf, 0, disp); + print_operand_value (scratchbuf, sizeof(scratchbuf), 0, disp); oappend (scratchbuf); } @@ -3504,7 +3504,7 @@ OP_I (bytemode, sizeflag) op &= mask; scratchbuf[0] = '$'; - print_operand_value (scratchbuf + 1, 1, op); + print_operand_value (scratchbuf + 1, sizeof(scratchbuf) - 1, 1, op); oappend (scratchbuf + intel_syntax); scratchbuf[0] = '\0'; } @@ -3557,7 +3557,7 @@ OP_I64 (bytemode, sizeflag) op &= mask; scratchbuf[0] = '$'; - print_operand_value (scratchbuf + 1, 1, op); + print_operand_value (scratchbuf + 1, sizeof(scratchbuf) - 1, 1, op); oappend (scratchbuf + intel_syntax); scratchbuf[0] = '\0'; } @@ -3609,7 +3609,7 @@ OP_sI (bytemode, sizeflag) } scratchbuf[0] = '$'; - print_operand_value (scratchbuf + 1, 1, op); + print_operand_value (scratchbuf + 1, sizeof(scratchbuf) - 1, 1, op); oappend (scratchbuf + intel_syntax); } @@ -3647,7 +3647,7 @@ OP_J (bytemode, sizeflag) } disp = (start_pc + codep - start_codep + disp) & mask; set_op (disp, 0); - print_operand_value (scratchbuf, 1, disp); + print_operand_value (scratchbuf, sizeof(scratchbuf), 1, disp); oappend (scratchbuf); } @@ -3678,9 +3678,9 @@ OP_DIR (dummy, sizeflag) } used_prefixes |= (prefixes & PREFIX_DATA); if (intel_syntax) - sprintf (scratchbuf, "0x%x,0x%x", seg, offset); + snprintf (scratchbuf, sizeof(scratchbuf), "0x%x,0x%x", seg, offset); else - sprintf (scratchbuf, "$0x%x,$0x%x", seg, offset); + snprintf (scratchbuf, sizeof(scratchbuf), "$0x%x,$0x%x", seg, offset); oappend (scratchbuf); } @@ -3707,7 +3707,7 @@ OP_OFF (bytemode, sizeflag) oappend (":"); } } - print_operand_value (scratchbuf, 1, off); + print_operand_value (scratchbuf, sizeof(scratchbuf), 1, off); oappend (scratchbuf); } @@ -3737,7 +3737,7 @@ OP_OFF64 (bytemode, sizeflag) oappend (":"); } } - print_operand_value (scratchbuf, 1, off); + print_operand_value (scratchbuf, sizeof(scratchbuf), 1, off); oappend (scratchbuf); } @@ -3806,7 +3806,7 @@ OP_C (dummy, sizeflag) USED_REX (REX_EXTX); if (rex & REX_EXTX) add = 8; - sprintf (scratchbuf, "%%cr%d", reg + add); + snprintf (scratchbuf, sizeof(scratchbuf), "%%cr%d", reg + add); oappend (scratchbuf + intel_syntax); } @@ -3820,9 +3820,9 @@ OP_D (dummy, sizeflag) if (rex & REX_EXTX) add = 8; if (intel_syntax) - sprintf (scratchbuf, "db%d", reg + add); + snprintf (scratchbuf, sizeof(scratchbuf), "db%d", reg + add); else - sprintf (scratchbuf, "%%db%d", reg + add); + snprintf (scratchbuf, sizeof(scratchbuf), "%%db%d", reg + add); oappend (scratchbuf); } @@ -3831,7 +3831,7 @@ OP_T (dummy, sizeflag) int dummy; int sizeflag; { - sprintf (scratchbuf, "%%tr%d", reg); + snprintf (scratchbuf, sizeof(scratchbuf), "%%tr%d", reg); oappend (scratchbuf + intel_syntax); } @@ -3857,9 +3857,9 @@ OP_MMX (bytemode, sizeflag) add = 8; used_prefixes |= (prefixes & PREFIX_DATA); if (prefixes & PREFIX_DATA) - sprintf (scratchbuf, "%%xmm%d", reg + add); + snprintf (scratchbuf, sizeof(scratchbuf), "%%xmm%d", reg + add); else - sprintf (scratchbuf, "%%mm%d", reg + add); + snprintf (scratchbuf, sizeof(scratchbuf), "%%mm%d", reg + add); oappend (scratchbuf + intel_syntax); } @@ -3872,7 +3872,7 @@ OP_XMM (bytemode, sizeflag) USED_REX (REX_EXTX); if (rex & REX_EXTX) add = 8; - sprintf (scratchbuf, "%%xmm%d", reg + add); + snprintf (scratchbuf, sizeof(scratchbuf), "%%xmm%d", reg + add); oappend (scratchbuf + intel_syntax); } @@ -3896,9 +3896,9 @@ OP_EM (bytemode, sizeflag) codep++; used_prefixes |= (prefixes & PREFIX_DATA); if (prefixes & PREFIX_DATA) - sprintf (scratchbuf, "%%xmm%d", rm + add); + snprintf (scratchbuf, sizeof(scratchbuf), "%%xmm%d", rm + add); else - sprintf (scratchbuf, "%%mm%d", rm + add); + snprintf (scratchbuf, sizeof(scratchbuf), "%%mm%d", rm + add); oappend (scratchbuf + intel_syntax); } @@ -3920,7 +3920,7 @@ OP_EX (bytemode, sizeflag) /* Skip mod/rm byte. */ MODRM_CHECK; codep++; - sprintf (scratchbuf, "%%xmm%d", rm + add); + snprintf (scratchbuf, sizeof(scratchbuf), "%%xmm%d", rm + add); oappend (scratchbuf + intel_syntax); } @@ -4079,8 +4079,8 @@ OP_SIMD_Suffix (bytemode, sizeflag) suffix1 = 's', suffix2 = 'd'; } } - sprintf (scratchbuf, "cmp%s%c%c", - simd_cmp_op[cmp_type], suffix1, suffix2); + snprintf (scratchbuf, sizeof(scratchbuf), "cmp%s%c%c", + simd_cmp_op[cmp_type], suffix1, suffix2); used_prefixes |= (prefixes & PREFIX_REPZ); oappend (scratchbuf); } |