src: replace deprecated sprintf calls

This commit is contained in:
selsta
2026-05-09 20:09:53 +02:00
parent cabeafa01a
commit 2e8a391d57
2 changed files with 2 additions and 2 deletions
@@ -272,7 +272,7 @@ plot 'stats.csv' index "DATA" using (timecolumn(1,"%Y-%m-%d")):4 with lines, ''
char buf[8];
unsigned int i;
for (i=0; i<24; i++) {
sprintf(buf, "\t%02u:00", i);
snprintf(buf, sizeof(buf), "\t%02u:00", i);
std::cout << buf;
}
}
+1 -1
View File
@@ -38,7 +38,7 @@ namespace hw {
void buffer_to_str(char *to_buff, size_t to_len, const char *buff, size_t len) {
CHECK_AND_ASSERT_THROW_MES(to_len > (len*2), "destination buffer too short. At least" << (len*2+1) << " bytes required");
for (size_t i=0; i<len; i++) {
sprintf(to_buff+2*i, "%.02x", (unsigned char)buff[i]);
snprintf(to_buff + 2 * i, to_len - 2 * i, "%.02x", (unsigned char)buff[i]);
}
}