src: Replace sprintf with snprintf

snprintf is needed anyway, that's one less function to have :p
And it's bad practice anyway.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
This commit is contained in:
Sylvain Munaut 2019-08-05 15:43:33 +02:00
parent 1d4152a36f
commit 4289788e0b
3 changed files with 10 additions and 10 deletions

View File

@ -120,7 +120,7 @@ void gdb_putpacket(const char *packet, int size)
} }
} }
gdb_if_putchar('#', 0); gdb_if_putchar('#', 0);
sprintf(xmit_csum, "%02X", csum); snprintf(xmit_csum, sizeof(xmit_csum), "%02X", csum);
gdb_if_putchar(xmit_csum[0], 0); gdb_if_putchar(xmit_csum[0], 0);
gdb_if_putchar(xmit_csum[1], 1); gdb_if_putchar(xmit_csum[1], 1);
#ifdef DEBUG_GDBPACKET #ifdef DEBUG_GDBPACKET

View File

@ -611,7 +611,7 @@ bool efm32_probe(target *t)
uint32_t ram_size = ram_kib * 0x400; uint32_t ram_size = ram_kib * 0x400;
uint32_t flash_page_size = device->flash_page_size; uint32_t flash_page_size = device->flash_page_size;
sprintf(variant_string, "%c\b%c\b%s %d F%d %s", snprintf(variant_string, sizeof(variant_string), "%c\b%c\b%s %d F%d %s",
di_version + 48, (uint8_t)device_index + 32, di_version + 48, (uint8_t)device_index + 32,
device->name, part_number, flash_kib, device->description); device->name, part_number, flash_kib, device->description);

View File

@ -390,15 +390,15 @@ bool samd_probe(target *t)
/* Part String */ /* Part String */
if (protected) { if (protected) {
sprintf(variant_string, snprintf(variant_string, sizeof(variant_string),
"Atmel SAMD%d%c%dA%s (rev %c) (PROT=1)", "Atmel SAMD%d%c%dA%s (rev %c) (PROT=1)",
samd.series, samd.pin, samd.mem, samd.series, samd.pin, samd.mem,
samd.package, samd.revision); samd.package, samd.revision);
} else { } else {
sprintf(variant_string, snprintf(variant_string, sizeof(variant_string),
"Atmel SAMD%d%c%dA%s (rev %c)", "Atmel SAMD%d%c%dA%s (rev %c)",
samd.series, samd.pin, samd.mem, samd.series, samd.pin, samd.mem,
samd.package, samd.revision); samd.package, samd.revision);
} }
/* Setup Target */ /* Setup Target */