mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-27 06:50:21 +00:00
replace sprintf as it not used anymore
This commit is contained in:
parent
81be4dfe13
commit
3cf13c71d9
8 changed files with 43 additions and 27 deletions
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -1,8 +1,10 @@
|
||||||
### New changes
|
### New changes
|
||||||
* Wifi scanner & Deauther plugins [(By SequoiaSan)](https://github.com/SequoiaSan)
|
* BadUSB keyboard layouts - now its possible to load keyboard layouts from microSD - [(by rien > dummy-decoy)](https://github.com/dummy-decoy/flipperzero-firmware/tree/dummy_decoy/bad_usb_keyboard_layout)
|
||||||
* UniRF app: display error if frequency is outside of range
|
* OFW: NFC: make dict attack more interactive
|
||||||
* Subghz frequency range fix
|
* OFW: NFC: Edit UID feature
|
||||||
* OFW: Merged latest commits
|
* OFW: MPU Hal
|
||||||
|
* OFW: Make printf great again
|
||||||
|
* OFW: other changes
|
||||||
|
|
||||||
**Note: Prefer installing using web updater or by self update package**
|
**Note: Prefer installing using web updater or by self update package**
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ void move_ball(Canvas* canvas) {
|
||||||
released = false;
|
released = false;
|
||||||
lives--;
|
lives--;
|
||||||
|
|
||||||
sprintf(text, "LIVES:%u", lives);
|
snprintf(text, sizeof(text), "LIVES:%u", lives);
|
||||||
canvas_draw_str(canvas, 0, 90, text);
|
canvas_draw_str(canvas, 0, 90, text);
|
||||||
|
|
||||||
// arduboy.tunes.tone(175, 250);
|
// arduboy.tunes.tone(175, 250);
|
||||||
|
@ -167,7 +167,7 @@ void move_ball(Canvas* canvas) {
|
||||||
leftBall <= rightBrick && rightBall >= leftBrick) {
|
leftBall <= rightBrick && rightBall >= leftBrick) {
|
||||||
// Draw score
|
// Draw score
|
||||||
score += (level * 10);
|
score += (level * 10);
|
||||||
sprintf(text, "SCORE:%u", score);
|
snprintf(text, sizeof(text), "SCORE:%u", score);
|
||||||
canvas_draw_str(canvas, 80, 90, text);
|
canvas_draw_str(canvas, 80, 90, text);
|
||||||
|
|
||||||
brickCount++;
|
brickCount++;
|
||||||
|
@ -209,7 +209,7 @@ void move_ball(Canvas* canvas) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_lives(Canvas* canvas) {
|
void draw_lives(Canvas* canvas) {
|
||||||
sprintf(text, "LIVES:%u", lives);
|
snprintf(text, sizeof(text), "LIVES:%u", lives);
|
||||||
canvas_draw_str(canvas, 0, 90, text);
|
canvas_draw_str(canvas, 0, 90, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,19 +39,21 @@ static void clock_render_callback(Canvas* const canvas, void* ctx) {
|
||||||
char strings[3][20];
|
char strings[3][20];
|
||||||
int curMin = (timerSecs / 60);
|
int curMin = (timerSecs / 60);
|
||||||
int curSec = timerSecs - (curMin * 60);
|
int curSec = timerSecs - (curMin * 60);
|
||||||
sprintf(
|
snprintf(
|
||||||
strings[0],
|
strings[0],
|
||||||
|
sizeof(strings[0]),
|
||||||
"%.4d-%.2d-%.2d",
|
"%.4d-%.2d-%.2d",
|
||||||
state->datetime.year,
|
state->datetime.year,
|
||||||
state->datetime.month,
|
state->datetime.month,
|
||||||
state->datetime.day);
|
state->datetime.day);
|
||||||
sprintf(
|
snprintf(
|
||||||
strings[1],
|
strings[1],
|
||||||
|
sizeof(strings[1]),
|
||||||
"%.2d:%.2d:%.2d",
|
"%.2d:%.2d:%.2d",
|
||||||
state->datetime.hour,
|
state->datetime.hour,
|
||||||
state->datetime.minute,
|
state->datetime.minute,
|
||||||
state->datetime.second);
|
state->datetime.second);
|
||||||
sprintf(strings[2], "%.2d:%.2d", curMin, curSec);
|
snprintf(strings[2], sizeof(strings[2]), "%.2d:%.2d", curMin, curSec);
|
||||||
release_mutex((ValueMutex*)ctx, state);
|
release_mutex((ValueMutex*)ctx, state);
|
||||||
canvas_set_font(canvas, FontBigNumbers);
|
canvas_set_font(canvas, FontBigNumbers);
|
||||||
canvas_draw_str_aligned(canvas, 64, 8, AlignCenter, AlignCenter, strings[1]);
|
canvas_draw_str_aligned(canvas, 64, 8, AlignCenter, AlignCenter, strings[1]);
|
||||||
|
|
|
@ -55,7 +55,7 @@ static void render_callback(Canvas* const canvas, void* ctx) {
|
||||||
|
|
||||||
canvas_set_font(canvas, FontSecondary);
|
canvas_set_font(canvas, FontSecondary);
|
||||||
if(!plugin_state->addr_err && !plugin_state->ducky_err) {
|
if(!plugin_state->addr_err && !plugin_state->ducky_err) {
|
||||||
sprintf(target_text, target_fmt_text, target_address_str);
|
snprintf(target_text, sizeof(target_text), target_fmt_text, target_address_str);
|
||||||
canvas_draw_str_aligned(canvas, 7, 10, AlignLeft, AlignBottom, target_text);
|
canvas_draw_str_aligned(canvas, 7, 10, AlignLeft, AlignBottom, target_text);
|
||||||
canvas_draw_str_aligned(canvas, 22, 20, AlignLeft, AlignBottom, "<- select address ->");
|
canvas_draw_str_aligned(canvas, 22, 20, AlignLeft, AlignBottom, "<- select address ->");
|
||||||
canvas_draw_str_aligned(canvas, 10, 30, AlignLeft, AlignBottom, "Press Ok button to ");
|
canvas_draw_str_aligned(canvas, 10, 30, AlignLeft, AlignBottom, "Press Ok button to ");
|
||||||
|
@ -92,7 +92,8 @@ static void mousejacker_state_init(PluginState* const plugin_state) {
|
||||||
|
|
||||||
static void hexlify(uint8_t* in, uint8_t size, char* out) {
|
static void hexlify(uint8_t* in, uint8_t size, char* out) {
|
||||||
memset(out, 0, size * 2);
|
memset(out, 0, size * 2);
|
||||||
for(int i = 0; i < size; i++) sprintf(out + strlen(out), "%02X", in[i]);
|
for(int i = 0; i < size; i++)
|
||||||
|
snprintf(out + strlen(out), sizeof(out + strlen(out)), "%02X", in[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool open_ducky_script(Stream* stream) {
|
static bool open_ducky_script(Stream* stream) {
|
||||||
|
|
|
@ -127,11 +127,12 @@ static void render_callback(Canvas* const canvas, void* ctx) {
|
||||||
|
|
||||||
if(!sniffing_state) strcpy(sniffing, "No");
|
if(!sniffing_state) strcpy(sniffing, "No");
|
||||||
|
|
||||||
sprintf(rate_text, rate_text_fmt, (int)rate);
|
snprintf(rate_text, sizeof(rate_text), rate_text_fmt, (int)rate);
|
||||||
sprintf(channel_text, channel_text_fmt, (int)target_channel);
|
snprintf(channel_text, sizeof(channel_text), channel_text_fmt, (int)target_channel);
|
||||||
sprintf(preamble_text, preamble_text_fmt, target_preamble[0]);
|
snprintf(preamble_text, sizeof(preamble_text), preamble_text_fmt, target_preamble[0]);
|
||||||
sprintf(sniff_text, sniff_text_fmt, sniffing);
|
snprintf(sniff_text, sizeof(sniff_text), sniff_text_fmt, sniffing);
|
||||||
sprintf(sniffed_address, sniffed_address_fmt, top_address, (int)rate);
|
snprintf(
|
||||||
|
sniffed_address, sizeof(sniffed_address), sniffed_address_fmt, top_address, (int)rate);
|
||||||
canvas_draw_str_aligned(canvas, 10, 10, AlignLeft, AlignBottom, rate_text);
|
canvas_draw_str_aligned(canvas, 10, 10, AlignLeft, AlignBottom, rate_text);
|
||||||
canvas_draw_str_aligned(canvas, 10, 20, AlignLeft, AlignBottom, channel_text);
|
canvas_draw_str_aligned(canvas, 10, 20, AlignLeft, AlignBottom, channel_text);
|
||||||
canvas_draw_str_aligned(canvas, 10, 30, AlignLeft, AlignBottom, preamble_text);
|
canvas_draw_str_aligned(canvas, 10, 30, AlignLeft, AlignBottom, preamble_text);
|
||||||
|
@ -151,7 +152,8 @@ static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queu
|
||||||
|
|
||||||
static void hexlify(uint8_t* in, uint8_t size, char* out) {
|
static void hexlify(uint8_t* in, uint8_t size, char* out) {
|
||||||
memset(out, 0, size * 2);
|
memset(out, 0, size * 2);
|
||||||
for(int i = 0; i < size; i++) sprintf(out + strlen(out), "%02X", in[i]);
|
for(int i = 0; i < size; i++)
|
||||||
|
snprintf(out + strlen(out), sizeof(out + strlen(out)), "%02X", in[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool save_addr_to_file(Storage* storage, uint8_t* data, uint8_t size) {
|
static bool save_addr_to_file(Storage* storage, uint8_t* data, uint8_t size) {
|
||||||
|
@ -165,7 +167,7 @@ static bool save_addr_to_file(Storage* storage, uint8_t* data, uint8_t size) {
|
||||||
Stream* stream = file_stream_alloc(storage);
|
Stream* stream = file_stream_alloc(storage);
|
||||||
|
|
||||||
if(target_rate == 8) rate = 2;
|
if(target_rate == 8) rate = 2;
|
||||||
sprintf(ending, ",%d\n", rate);
|
snprintf(ending, sizeof(ending), ",%d\n", rate);
|
||||||
hexlify(data, size, addrline);
|
hexlify(data, size, addrline);
|
||||||
strcat(addrline, ending);
|
strcat(addrline, ending);
|
||||||
linesize = strlen(addrline);
|
linesize = strlen(addrline);
|
||||||
|
|
|
@ -103,12 +103,12 @@ void tictactoe_draw(Canvas* canvas) {
|
||||||
canvas_draw_str(canvas, 75, 24, "X:");
|
canvas_draw_str(canvas, 75, 24, "X:");
|
||||||
|
|
||||||
char scoreXBuffer[10];
|
char scoreXBuffer[10];
|
||||||
sprintf(scoreXBuffer, "%d", scoreX);
|
snprintf(scoreXBuffer, sizeof(scoreXBuffer), "%d", scoreX);
|
||||||
canvas_draw_str(canvas, 88, 24, scoreXBuffer);
|
canvas_draw_str(canvas, 88, 24, scoreXBuffer);
|
||||||
canvas_draw_str(canvas, 75, 35, "O:");
|
canvas_draw_str(canvas, 75, 35, "O:");
|
||||||
|
|
||||||
char scoreOBuffer[10];
|
char scoreOBuffer[10];
|
||||||
sprintf(scoreOBuffer, "%d", scoreO);
|
snprintf(scoreOBuffer, sizeof(scoreOBuffer), "%d", scoreO);
|
||||||
canvas_draw_str(canvas, 88, 35, scoreOBuffer);
|
canvas_draw_str(canvas, 88, 35, scoreOBuffer);
|
||||||
|
|
||||||
canvas_set_font(canvas, FontSecondary);
|
canvas_set_font(canvas, FontSecondary);
|
||||||
|
|
|
@ -255,18 +255,21 @@ static void wifi_module_render_callback(Canvas* const canvas, void* ctx) {
|
||||||
offsetY += fontHeight + 1;
|
offsetY += fontHeight + 1;
|
||||||
|
|
||||||
char string[15];
|
char string[15];
|
||||||
sprintf(string, "RSSI: %d", app->m_currentAccesspointDescription.m_rssi);
|
snprintf(
|
||||||
|
string, sizeof(string), "RSSI: %d", app->m_currentAccesspointDescription.m_rssi);
|
||||||
canvas_draw_str(canvas, offsetX, offsetY, string);
|
canvas_draw_str(canvas, offsetX, offsetY, string);
|
||||||
|
|
||||||
offsetY += fontHeight + 1;
|
offsetY += fontHeight + 1;
|
||||||
|
|
||||||
sprintf(string, "CHNL: %d", app->m_currentAccesspointDescription.m_channel);
|
snprintf(
|
||||||
|
string, sizeof(string), "CHNL: %d", app->m_currentAccesspointDescription.m_channel);
|
||||||
canvas_draw_str(canvas, offsetX, offsetY, string);
|
canvas_draw_str(canvas, offsetX, offsetY, string);
|
||||||
|
|
||||||
offsetY += fontHeight + 1;
|
offsetY += fontHeight + 1;
|
||||||
|
|
||||||
sprintf(
|
snprintf(
|
||||||
string,
|
string,
|
||||||
|
sizeof(string),
|
||||||
"ENCR: %s",
|
"ENCR: %s",
|
||||||
string_get_cstr(app->m_currentAccesspointDescription.m_secType));
|
string_get_cstr(app->m_currentAccesspointDescription.m_secType));
|
||||||
canvas_draw_str(canvas, offsetX, offsetY, string);
|
canvas_draw_str(canvas, offsetX, offsetY, string);
|
||||||
|
@ -275,7 +278,12 @@ static void wifi_module_render_callback(Canvas* const canvas, void* ctx) {
|
||||||
offsetY -= fontHeight;
|
offsetY -= fontHeight;
|
||||||
|
|
||||||
u8g2_SetFont(&canvas->fb, u8g2_font_courB08_tn);
|
u8g2_SetFont(&canvas->fb, u8g2_font_courB08_tn);
|
||||||
sprintf(string, "%d/%d", app->m_currentIndexAccessPoint, app->m_totalAccessPoints);
|
snprintf(
|
||||||
|
string,
|
||||||
|
sizeof(string),
|
||||||
|
"%d/%d",
|
||||||
|
app->m_currentIndexAccessPoint,
|
||||||
|
app->m_totalAccessPoints);
|
||||||
offsetX = u8g2_GetDisplayWidth(&canvas->fb) - canvas_string_width(canvas, string) - 5;
|
offsetX = u8g2_GetDisplayWidth(&canvas->fb) - canvas_string_width(canvas, string) - 5;
|
||||||
canvas_draw_str(canvas, offsetX, offsetY, string);
|
canvas_draw_str(canvas, offsetX, offsetY, string);
|
||||||
|
|
||||||
|
@ -323,7 +331,7 @@ static void wifi_module_render_callback(Canvas* const canvas, void* ctx) {
|
||||||
offsetY += fontHeight - 5;
|
offsetY += fontHeight - 5;
|
||||||
|
|
||||||
char rssi[8];
|
char rssi[8];
|
||||||
sprintf(rssi, "%d", app->m_currentAccesspointDescription.m_rssi);
|
snprintf(rssi, sizeof(rssi), "%d", app->m_currentAccesspointDescription.m_rssi);
|
||||||
canvas_draw_str(canvas, offsetX, offsetY, rssi);
|
canvas_draw_str(canvas, offsetX, offsetY, rssi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -360,7 +360,8 @@ void nrf24_init_promisc_mode(FuriHalSpiBusHandle* handle, uint8_t channel, uint8
|
||||||
|
|
||||||
void hexlify(uint8_t* in, uint8_t size, char* out) {
|
void hexlify(uint8_t* in, uint8_t size, char* out) {
|
||||||
memset(out, 0, size * 2);
|
memset(out, 0, size * 2);
|
||||||
for(int i = 0; i < size; i++) sprintf(out + strlen(out), "%02X", in[i]);
|
for(int i = 0; i < size; i++)
|
||||||
|
snprintf(out + strlen(out), sizeof(out + strlen(out)), "%02X", in[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t bytes_to_int64(uint8_t* bytes, uint8_t size, bool bigendian) {
|
uint64_t bytes_to_int64(uint8_t* bytes, uint8_t size, bool bigendian) {
|
||||||
|
|
Loading…
Reference in a new issue