From e711951979fb9e105de8ef2ed8eb1987aac702f8 Mon Sep 17 00:00:00 2001 From: arbee Date: Sat, 3 Jun 2023 20:27:30 -0400 Subject: Some more sprintf() deprecation warning fixes. [R. Belmont] --- src/devices/cpu/apexc/apexcdsm.cpp | 2 +- src/devices/cpu/dsp56156/tables.cpp | 24 ++++++++++++------------ src/lib/util/jedparse.cpp | 14 +++++++------- src/tools/jedutil.cpp | 36 ++++++++++++++++++------------------ 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/devices/cpu/apexc/apexcdsm.cpp b/src/devices/cpu/apexc/apexcdsm.cpp index bb581dd2850..c0b07e894cf 100644 --- a/src/devices/cpu/apexc/apexcdsm.cpp +++ b/src/devices/cpu/apexc/apexcdsm.cpp @@ -101,7 +101,7 @@ offs_t apexc_disassembler::disassemble(std::ostream &stream, offs_t pc, const da the_desc = & instructions[function >> 1]; /* generate mnemonic : append a 'v' to the basic mnemonic if it is a vector instruction */ - sprintf(mnemonic, "%.*s%c", (int)sizeof(mnemonic)-2, the_desc->mnemonic, vector ? 'v' : ' '); + snprintf(mnemonic, 9, "%.*s%c", (int)sizeof(mnemonic)-2, the_desc->mnemonic, vector ? 'v' : ' '); /* print mnemonic and n immediate */ switch (the_desc->format) diff --git a/src/devices/cpu/dsp56156/tables.cpp b/src/devices/cpu/dsp56156/tables.cpp index e4341511aa3..63910a123b0 100644 --- a/src/devices/cpu/dsp56156/tables.cpp +++ b/src/devices/cpu/dsp56156/tables.cpp @@ -502,14 +502,14 @@ void assemble_eas_from_mm_table(uint16_t mm, int n1, int n2, std::string& ea1, s char temp2[32]; switch(mm) { - case 0x0: sprintf(temp1, "(R%d)+", n1) ; - sprintf(temp2, "(R%d)+", n2) ; break; - case 0x1: sprintf(temp1, "(R%d)+", n1) ; - sprintf(temp2, "(R%d)+N%d", n2, n2); break; - case 0x2: sprintf(temp1, "(R%d)+N%d", n1, n1); - sprintf(temp2, "(R%d)+", n2) ; break; - case 0x3: sprintf(temp1, "(R%d)+N%d", n1, n1); - sprintf(temp2, "(R%d)+N%d", n2, n2); break; + case 0x0: snprintf(temp1, 32, "(R%d)+", n1) ; + snprintf(temp2, 32, "(R%d)+", n2) ; break; + case 0x1: snprintf(temp1, 32, "(R%d)+", n1) ; + snprintf(temp2, 32, "(R%d)+N%d", n2, n2); break; + case 0x2: snprintf(temp1, 32, "(R%d)+N%d", n1, n1); + snprintf(temp2, 32, "(R%d)+", n2) ; break; + case 0x3: snprintf(temp1, 32, "(R%d)+N%d", n1, n1); + snprintf(temp2, 32, "(R%d)+N%d", n2, n2); break; } ea1 = temp1; ea2 = temp2; @@ -540,8 +540,8 @@ void assemble_ea_from_t_table(uint16_t t, uint16_t val, std::string& ea) char temp[32]; switch(t) { - case 0x0: sprintf(temp, "X:>$%x", val); break; - case 0x1: sprintf(temp, "#>$%x", val); break; + case 0x0: snprintf(temp, 32, "X:>$%x", val); break; + case 0x1: snprintf(temp, 32, "#>$%x", val); break; // NEW // case 0x0: sprintf(ea, "X:$%04x", val); break; // NEW // case 0x1: sprintf(ea, "#$%04x", val); break; } @@ -565,12 +565,12 @@ void assemble_D_from_P_table(uint16_t P, uint16_t ppppp, std::string& D) switch(P) { case 0x0: - sprintf(temp, "X:<$%x", ppppp); + snprintf(temp, 32, "X:<$%x", ppppp); // NEW // sprintf(temp, "X:$%02x", ppppp); break; case 0x1: assemble_address_from_IO_short_address(ppppp, fullAddy); - sprintf(temp, "X:<<$%s", fullAddy.c_str()); + snprintf(temp, 32, "X:<<$%s", fullAddy.c_str()); // NEW // sprintf(temp, "X:$%s", fullAddy.c_str()); break; } diff --git a/src/lib/util/jedparse.cpp b/src/lib/util/jedparse.cpp index 3b77c4abe35..5915886b1a6 100644 --- a/src/lib/util/jedparse.cpp +++ b/src/lib/util/jedparse.cpp @@ -355,13 +355,13 @@ size_t jed_output(const jed_data *data, void *result, size_t length) /* always start the DST with a standard header and an STX */ tempbuf[0] = 0x02; - sprintf(&tempbuf[1], "JEDEC file generated by jedutil*\n"); + snprintf(&tempbuf[1], 255, "JEDEC file generated by jedutil*\n"); if (curdst + strlen(tempbuf) <= dstend) memcpy(curdst, tempbuf, strlen(tempbuf)); curdst += strlen(tempbuf); /* append the package information */ - sprintf(tempbuf, "QF%d*\n", data->numfuses); + snprintf(tempbuf, 256, "QF%d*\n", data->numfuses); if (curdst + strlen(tempbuf) <= dstend) memcpy(curdst, tempbuf, strlen(tempbuf)); curdst += strlen(tempbuf); @@ -382,7 +382,7 @@ size_t jed_output(const jed_data *data, void *result, size_t length) defbyte = (ones > zeros) ? 0xff : 0x00; /* output the default fuse state */ - sprintf(tempbuf, "F%d*\n", defbyte & 1); + snprintf(tempbuf, 256, "F%d*\n", defbyte & 1); if (curdst + strlen(tempbuf) <= dstend) memcpy(curdst, tempbuf, strlen(tempbuf)); curdst += strlen(tempbuf); @@ -398,10 +398,10 @@ size_t jed_output(const jed_data *data, void *result, size_t length) int j; /* build up a string of 32 fuses */ - stroffs = sprintf(tempbuf, "L%05d ", i); + stroffs = snprintf(tempbuf, 256, "L%05d ", i); for (j = 0; j < 32 && i+j < data->numfuses; j++) tempbuf[stroffs++] = '0' + jed_get_fuse(data, i + j); - stroffs += sprintf(&tempbuf[stroffs], "*\n"); + stroffs += snprintf(&tempbuf[stroffs], 256-stroffs, "*\n"); /* append to the buffer */ if (curdst + strlen(tempbuf) <= dstend) @@ -410,7 +410,7 @@ size_t jed_output(const jed_data *data, void *result, size_t length) } /* write the checksum */ - sprintf(tempbuf, "C%04X*\n", checksum); + snprintf(tempbuf, 256, "C%04X*\n", checksum); if (curdst + strlen(tempbuf) <= dstend) memcpy(curdst, tempbuf, strlen(tempbuf)); curdst += strlen(tempbuf); @@ -423,7 +423,7 @@ size_t jed_output(const jed_data *data, void *result, size_t length) /* append the ETX and the transmission checksum */ tempbuf[0] = 0x03; - sprintf(&tempbuf[1], "%04X", checksum); + snprintf(&tempbuf[1], 255, "%04X", checksum); if (curdst + strlen(tempbuf) <= dstend) memcpy(curdst, tempbuf, strlen(tempbuf)); curdst += strlen(tempbuf); diff --git a/src/tools/jedutil.cpp b/src/tools/jedutil.cpp index 73e190e3f0e..f9f57ff8fed 100644 --- a/src/tools/jedutil.cpp +++ b/src/tools/jedutil.cpp @@ -2999,7 +2999,7 @@ static void generate_product_terms(const pal_data* pal, const jed_data* jed, uin if (!is_output_pin(pin)) { - sprintf(tmpbuffer, LOW_SYMBOL INPUT_SYMBOL "%d", pin); + snprintf(tmpbuffer, 20, LOW_SYMBOL INPUT_SYMBOL "%d", pin); strcat(buffer, tmpbuffer); } else @@ -3010,11 +3010,11 @@ static void generate_product_terms(const pal_data* pal, const jed_data* jed, uin { if (flags & OUTPUT_COMBINATORIAL) { - sprintf(tmpbuffer, LOW_SYMBOL OUTPUT_SYMBOL "%d", pin); + snprintf(tmpbuffer, 20, LOW_SYMBOL OUTPUT_SYMBOL "%d", pin); } else if (flags & OUTPUT_REGISTERED) { - sprintf(tmpbuffer, LOW_SYMBOL REGISTERED_FEEDBACK_OUTPUT_SYMBOL "%d", pin); + snprintf(tmpbuffer, 20, LOW_SYMBOL REGISTERED_FEEDBACK_OUTPUT_SYMBOL "%d", pin); } else { @@ -3025,11 +3025,11 @@ static void generate_product_terms(const pal_data* pal, const jed_data* jed, uin } else if (flags & OUTPUT_FEEDBACK_COMBINATORIAL) { - sprintf(tmpbuffer, LOW_SYMBOL OUTPUT_FEEDBACK_SYMBOL "%d", pin); + snprintf(tmpbuffer, 20, LOW_SYMBOL OUTPUT_FEEDBACK_SYMBOL "%d", pin); } else if (flags & OUTPUT_FEEDBACK_REGISTERED) { - sprintf(tmpbuffer, LOW_SYMBOL REGISTERED_FEEDBACK_SYMBOL "%d", pin); + snprintf(tmpbuffer, 20, LOW_SYMBOL REGISTERED_FEEDBACK_SYMBOL "%d", pin); } else { @@ -3053,7 +3053,7 @@ static void generate_product_terms(const pal_data* pal, const jed_data* jed, uin if (!is_output_pin(pin)) { - sprintf(tmpbuffer, INPUT_SYMBOL "%d", pin); + snprintf(tmpbuffer, 20, INPUT_SYMBOL "%d", pin); strcat(buffer, tmpbuffer); } else @@ -3064,11 +3064,11 @@ static void generate_product_terms(const pal_data* pal, const jed_data* jed, uin { if (flags & OUTPUT_COMBINATORIAL) { - sprintf(tmpbuffer, OUTPUT_SYMBOL "%d", pin); + snprintf(tmpbuffer, 20, OUTPUT_SYMBOL "%d", pin); } else if (flags & OUTPUT_REGISTERED) { - sprintf(tmpbuffer, REGISTERED_FEEDBACK_OUTPUT_SYMBOL "%d", pin); + snprintf(tmpbuffer, 20, REGISTERED_FEEDBACK_OUTPUT_SYMBOL "%d", pin); } else { @@ -3079,11 +3079,11 @@ static void generate_product_terms(const pal_data* pal, const jed_data* jed, uin } else if (flags & OUTPUT_FEEDBACK_COMBINATORIAL) { - sprintf(tmpbuffer, OUTPUT_FEEDBACK_SYMBOL "%d", pin); + snprintf(tmpbuffer, 20, OUTPUT_FEEDBACK_SYMBOL "%d", pin); } else if (flags & OUTPUT_FEEDBACK_REGISTERED) { - sprintf(tmpbuffer, REGISTERED_FEEDBACK_SYMBOL "%d", pin); + snprintf(tmpbuffer, 20, REGISTERED_FEEDBACK_SYMBOL "%d", pin); } else { @@ -3232,11 +3232,11 @@ static void print_product_terms(const pal_data* pal, const jed_data* jed) if (flags & OUTPUT_COMBINATORIAL) { - sprintf(buffer, OUTPUT_SYMBOL "%d " COMBINATORIAL_ASSIGNMENT " ", outputpins[index].pin); + snprintf(buffer, 200, OUTPUT_SYMBOL "%d " COMBINATORIAL_ASSIGNMENT " ", outputpins[index].pin); } else if (flags & OUTPUT_REGISTERED) { - sprintf(buffer, REGISTERED_FEEDBACK_SYMBOL "%d " REGISTERED_ASSIGNMENT " ", outputpins[index].pin); + snprintf(buffer, 200, REGISTERED_FEEDBACK_SYMBOL "%d " REGISTERED_ASSIGNMENT " ", outputpins[index].pin); } else { @@ -3357,7 +3357,7 @@ static void print_pal20xxx_product_terms(const pal_data* pal, const jed_data* je if (flags & OUTPUT_COMBINATORIAL) { - sprintf(buffer, LOW_SYMBOL OUTPUT_SYMBOL "%d " COMBINATORIAL_ASSIGNMENT " ", outputpins[index].pin); + snprintf(buffer, 200, LOW_SYMBOL OUTPUT_SYMBOL "%d " COMBINATORIAL_ASSIGNMENT " ", outputpins[index].pin); printf("%s", buffer); @@ -3412,7 +3412,7 @@ static void print_pal20xxx_product_terms(const pal_data* pal, const jed_data* je } else if (flags & OUTPUT_REGISTERED) { - sprintf(buffer, LOW_SYMBOL REGISTERED_FEEDBACK_SYMBOL "%d " REGISTERED_ASSIGNMENT " ", outputpins[index].pin); + snprintf(buffer, 200, LOW_SYMBOL REGISTERED_FEEDBACK_SYMBOL "%d " REGISTERED_ASSIGNMENT " ", outputpins[index].pin); printf("%s", buffer); @@ -4002,7 +4002,7 @@ static void print_82s153_pls153_product_terms(const pal_data* pal, const jed_dat indent += strlen(LOW_SYMBOL); } - sprintf(buffer, OUTPUT_SYMBOL "%d " COMBINATORIAL_ASSIGNMENT " ", outputpins[index].pin); + snprintf(buffer, 200, OUTPUT_SYMBOL "%d " COMBINATORIAL_ASSIGNMENT " ", outputpins[index].pin); printf("%s", buffer); @@ -4105,7 +4105,7 @@ static void print_ck2605_product_terms(const pal_data* pal, const jed_data* jed) indent += strlen(LOW_SYMBOL); } - sprintf(buffer, OUTPUT_SYMBOL "%d " COMBINATORIAL_ASSIGNMENT " ", outputpins[index].pin); + snprintf(buffer, 200, OUTPUT_SYMBOL "%d " COMBINATORIAL_ASSIGNMENT " ", outputpins[index].pin); printf("%s", buffer); @@ -4228,7 +4228,7 @@ static void print_epl10p8_product_terms(const pal_data* pal, const jed_data* jed indent += strlen(LOW_SYMBOL); } - sprintf(buffer, OUTPUT_SYMBOL "%d " COMBINATORIAL_ASSIGNMENT " ", outputpins[index].pin); + snprintf(buffer, 200, OUTPUT_SYMBOL "%d " COMBINATORIAL_ASSIGNMENT " ", outputpins[index].pin); printf("%s", buffer); @@ -4687,7 +4687,7 @@ static void print_82s100_pls100_product_terms(const pal_data* pal, const jed_dat indent += strlen(LOW_SYMBOL); } - sprintf(buffer, OUTPUT_SYMBOL "%d " COMBINATORIAL_ASSIGNMENT " ", outputpins[index].pin); + snprintf(buffer, 200, OUTPUT_SYMBOL "%d " COMBINATORIAL_ASSIGNMENT " ", outputpins[index].pin); printf("%s", buffer); -- cgit v1.2.3