Commit 2dc766dafc7f5416bfdf184b42f0c5c22567bb60
1 parent
bb0574fe
Fix ppc-softmmu warnings on OpenBSD host
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7099 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
19 additions
and
11 deletions
gdbstub.c
| @@ -1333,11 +1333,11 @@ static const char *get_feature_xml(const char *p, const char **newp) | @@ -1333,11 +1333,11 @@ static const char *get_feature_xml(const char *p, const char **newp) | ||
| 1333 | GDB_CORE_XML); | 1333 | GDB_CORE_XML); |
| 1334 | 1334 | ||
| 1335 | for (r = first_cpu->gdb_regs; r; r = r->next) { | 1335 | for (r = first_cpu->gdb_regs; r; r = r->next) { |
| 1336 | - strcat(target_xml, "<xi:include href=\""); | ||
| 1337 | - strcat(target_xml, r->xml); | ||
| 1338 | - strcat(target_xml, "\"/>"); | 1336 | + pstrcat(target_xml, sizeof(target_xml), "<xi:include href=\""); |
| 1337 | + pstrcat(target_xml, sizeof(target_xml), r->xml); | ||
| 1338 | + pstrcat(target_xml, sizeof(target_xml), "\"/>"); | ||
| 1339 | } | 1339 | } |
| 1340 | - strcat(target_xml, "</target>"); | 1340 | + pstrcat(target_xml, sizeof(target_xml), "</target>"); |
| 1341 | } | 1341 | } |
| 1342 | return target_xml; | 1342 | return target_xml; |
| 1343 | } | 1343 | } |
| @@ -1838,7 +1838,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) | @@ -1838,7 +1838,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) | ||
| 1838 | if (strncmp(p, "Supported", 9) == 0) { | 1838 | if (strncmp(p, "Supported", 9) == 0) { |
| 1839 | snprintf(buf, sizeof(buf), "PacketSize=%x", MAX_PACKET_LENGTH); | 1839 | snprintf(buf, sizeof(buf), "PacketSize=%x", MAX_PACKET_LENGTH); |
| 1840 | #ifdef GDB_CORE_XML | 1840 | #ifdef GDB_CORE_XML |
| 1841 | - strcat(buf, ";qXfer:features:read+"); | 1841 | + pstrcat(buf, sizeof(buf), ";qXfer:features:read+"); |
| 1842 | #endif | 1842 | #endif |
| 1843 | put_packet(s, buf); | 1843 | put_packet(s, buf); |
| 1844 | break; | 1844 | break; |
target-ppc/translate.c
| @@ -81,6 +81,7 @@ void ppc_translate_init(void) | @@ -81,6 +81,7 @@ void ppc_translate_init(void) | ||
| 81 | { | 81 | { |
| 82 | int i; | 82 | int i; |
| 83 | char* p; | 83 | char* p; |
| 84 | + size_t cpu_reg_names_size; | ||
| 84 | static int done_init = 0; | 85 | static int done_init = 0; |
| 85 | 86 | ||
| 86 | if (done_init) | 87 | if (done_init) |
| @@ -89,32 +90,37 @@ void ppc_translate_init(void) | @@ -89,32 +90,37 @@ void ppc_translate_init(void) | ||
| 89 | cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); | 90 | cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); |
| 90 | 91 | ||
| 91 | p = cpu_reg_names; | 92 | p = cpu_reg_names; |
| 93 | + cpu_reg_names_size = sizeof(cpu_reg_names); | ||
| 92 | 94 | ||
| 93 | for (i = 0; i < 8; i++) { | 95 | for (i = 0; i < 8; i++) { |
| 94 | - sprintf(p, "crf%d", i); | 96 | + snprintf(p, cpu_reg_names_size, "crf%d", i); |
| 95 | cpu_crf[i] = tcg_global_mem_new_i32(TCG_AREG0, | 97 | cpu_crf[i] = tcg_global_mem_new_i32(TCG_AREG0, |
| 96 | offsetof(CPUState, crf[i]), p); | 98 | offsetof(CPUState, crf[i]), p); |
| 97 | p += 5; | 99 | p += 5; |
| 100 | + cpu_reg_names_size -= 5; | ||
| 98 | } | 101 | } |
| 99 | 102 | ||
| 100 | for (i = 0; i < 32; i++) { | 103 | for (i = 0; i < 32; i++) { |
| 101 | - sprintf(p, "r%d", i); | 104 | + snprintf(p, cpu_reg_names_size, "r%d", i); |
| 102 | cpu_gpr[i] = tcg_global_mem_new(TCG_AREG0, | 105 | cpu_gpr[i] = tcg_global_mem_new(TCG_AREG0, |
| 103 | offsetof(CPUState, gpr[i]), p); | 106 | offsetof(CPUState, gpr[i]), p); |
| 104 | p += (i < 10) ? 3 : 4; | 107 | p += (i < 10) ? 3 : 4; |
| 108 | + cpu_reg_names_size -= (i < 10) ? 3 : 4; | ||
| 105 | #if !defined(TARGET_PPC64) | 109 | #if !defined(TARGET_PPC64) |
| 106 | - sprintf(p, "r%dH", i); | 110 | + snprintf(p, cpu_reg_names_size, "r%dH", i); |
| 107 | cpu_gprh[i] = tcg_global_mem_new_i32(TCG_AREG0, | 111 | cpu_gprh[i] = tcg_global_mem_new_i32(TCG_AREG0, |
| 108 | offsetof(CPUState, gprh[i]), p); | 112 | offsetof(CPUState, gprh[i]), p); |
| 109 | p += (i < 10) ? 4 : 5; | 113 | p += (i < 10) ? 4 : 5; |
| 114 | + cpu_reg_names_size -= (i < 10) ? 4 : 5; | ||
| 110 | #endif | 115 | #endif |
| 111 | 116 | ||
| 112 | - sprintf(p, "fp%d", i); | 117 | + snprintf(p, cpu_reg_names_size, "fp%d", i); |
| 113 | cpu_fpr[i] = tcg_global_mem_new_i64(TCG_AREG0, | 118 | cpu_fpr[i] = tcg_global_mem_new_i64(TCG_AREG0, |
| 114 | offsetof(CPUState, fpr[i]), p); | 119 | offsetof(CPUState, fpr[i]), p); |
| 115 | p += (i < 10) ? 4 : 5; | 120 | p += (i < 10) ? 4 : 5; |
| 121 | + cpu_reg_names_size -= (i < 10) ? 4 : 5; | ||
| 116 | 122 | ||
| 117 | - sprintf(p, "avr%dH", i); | 123 | + snprintf(p, cpu_reg_names_size, "avr%dH", i); |
| 118 | #ifdef WORDS_BIGENDIAN | 124 | #ifdef WORDS_BIGENDIAN |
| 119 | cpu_avrh[i] = tcg_global_mem_new_i64(TCG_AREG0, | 125 | cpu_avrh[i] = tcg_global_mem_new_i64(TCG_AREG0, |
| 120 | offsetof(CPUState, avr[i].u64[0]), p); | 126 | offsetof(CPUState, avr[i].u64[0]), p); |
| @@ -123,8 +129,9 @@ void ppc_translate_init(void) | @@ -123,8 +129,9 @@ void ppc_translate_init(void) | ||
| 123 | offsetof(CPUState, avr[i].u64[1]), p); | 129 | offsetof(CPUState, avr[i].u64[1]), p); |
| 124 | #endif | 130 | #endif |
| 125 | p += (i < 10) ? 6 : 7; | 131 | p += (i < 10) ? 6 : 7; |
| 132 | + cpu_reg_names_size -= (i < 10) ? 6 : 7; | ||
| 126 | 133 | ||
| 127 | - sprintf(p, "avr%dL", i); | 134 | + snprintf(p, cpu_reg_names_size, "avr%dL", i); |
| 128 | #ifdef WORDS_BIGENDIAN | 135 | #ifdef WORDS_BIGENDIAN |
| 129 | cpu_avrl[i] = tcg_global_mem_new_i64(TCG_AREG0, | 136 | cpu_avrl[i] = tcg_global_mem_new_i64(TCG_AREG0, |
| 130 | offsetof(CPUState, avr[i].u64[1]), p); | 137 | offsetof(CPUState, avr[i].u64[1]), p); |
| @@ -133,6 +140,7 @@ void ppc_translate_init(void) | @@ -133,6 +140,7 @@ void ppc_translate_init(void) | ||
| 133 | offsetof(CPUState, avr[i].u64[0]), p); | 140 | offsetof(CPUState, avr[i].u64[0]), p); |
| 134 | #endif | 141 | #endif |
| 135 | p += (i < 10) ? 6 : 7; | 142 | p += (i < 10) ? 6 : 7; |
| 143 | + cpu_reg_names_size -= (i < 10) ? 6 : 7; | ||
| 136 | } | 144 | } |
| 137 | 145 | ||
| 138 | cpu_nip = tcg_global_mem_new(TCG_AREG0, | 146 | cpu_nip = tcg_global_mem_new(TCG_AREG0, |