1
0
Fork 0
forked from forks/qmk_firmware

[Fix] Patches after printf library update (#17584)

* Add missing '(' to print_bin_reverse32 declaration
* Fix insufficient character buffers on satisfaction75
* Remove \0 character in format string and use corrected offset math
  instead on rocketboard 16
* Replace snprintf_ with snprintf for djinn
* Explicitly ignore format checks for tracktyl manuform that uses %b
  specifier
* Print properly escaped version string in command.c, as PRODUCT or
  other defines can contain constructs like 'Vendor keyboard 66%' which
  will be interpreted as a format specifier
This commit is contained in:
Stefan Kerkmann 2022-07-07 14:14:09 +02:00 committed by GitHub
parent 8224f62806
commit 643f6367a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 24 additions and 24 deletions

View file

@ -145,7 +145,7 @@ static char* get_time(void) {
hour = 12;
}
static char time_str[8] = "";
static char time_str[11] = "";
sprintf(time_str, "%02d:%02d%s", hour, minute, is_pm ? "pm" : "am");
return time_str;
@ -162,7 +162,7 @@ static char* get_date(void) {
day = day_config;
}
static char date_str[11] = "";
static char date_str[15] = "";
sprintf(date_str, "%04d-%02d-%02d", year, month, day);
return date_str;

View file

@ -247,7 +247,7 @@ static bool has_shift_mod(void) {
*/
__attribute__((unused)) static void debug_charybdis_config_to_console(charybdis_config_t* config) {
# ifdef CONSOLE_ENABLE
dprintf("(charybdis) process_record_kb: config = {\n"
IGNORE_FORMAT_WARNING(dprintf("(charybdis) process_record_kb: config = {\n"
"\traw = 0x%04X,\n"
"\t{\n"
"\t\tis_dragscroll_enabled=%b\n"
@ -256,7 +256,7 @@ __attribute__((unused)) static void debug_charybdis_config_to_console(charybdis_
"\t\tsniping_dpi=0x%01X (%ld)\n"
"\t}\n"
"}\n",
config->raw, config->is_dragscroll_enabled, config->is_sniping_enabled, config->pointer_default_dpi, get_pointer_default_dpi(config), config->pointer_sniping_dpi, get_pointer_sniping_dpi(config));
config->raw, config->is_dragscroll_enabled, config->is_sniping_enabled, config->pointer_default_dpi, get_pointer_default_dpi(config), config->pointer_sniping_dpi, get_pointer_sniping_dpi(config)));
# endif // CONSOLE_ENABLE
}

View file

@ -107,10 +107,10 @@ static void oled_write_ln_centered(const char * data, bool inverted)
char line_buf[21];
// Amount to offset string from left side
uint8_t offset = (21 - strlen(data))/2;
uint8_t offset = (22 - strlen(data)) / 2;
// Formatted string centering... look, it works, don't ask how...
snprintf(line_buf, 21, "%*s%s%*s\0", offset, "", data, offset, ""); // Centers data within 21 character buffer with null termination
snprintf(line_buf, 21, "%*s%s%*s", offset, "", data, offset, ""); // Centers data within 21 character buffer
oled_write_ln(line_buf, inverted);
}

View file

@ -107,10 +107,10 @@ static void oled_write_ln_centered(const char * data, bool inverted)
char line_buf[21];
// Amount to offset string from left side
uint8_t offset = (21 - strlen(data))/2;
uint8_t offset = (22 - strlen(data))/2;
// Formatted string centering... look, it works, don't ask how...
snprintf(line_buf, 21, "%*s%s%*s\0", offset, "", data, offset, ""); // Centers data within 21 character buffer with null termination
snprintf(line_buf, 21, "%*s%s%*s", offset, "", data, offset, ""); // Centers data within 21 character buffer
oled_write_ln(line_buf, inverted);
}

View file

@ -158,7 +158,7 @@ void draw_ui_user(void) {
if (hue_redraw || rgb_effect_redraw) {
static int max_rgb_xpos = 0;
xpos = 16;
snprintf_(buf, sizeof(buf), "rgb: %s", rgb_matrix_name(curr_effect));
snprintf(buf, sizeof(buf), "rgb: %s", rgb_matrix_name(curr_effect));
for (int i = 5; i < sizeof(buf); ++i) {
if (buf[i] == 0)
@ -187,7 +187,7 @@ void draw_ui_user(void) {
static int max_layer_xpos = 0;
xpos = 16;
snprintf_(buf, sizeof(buf), "layer: %s", layer_name);
snprintf(buf, sizeof(buf), "layer: %s", layer_name);
xpos += qp_drawtext_recolor(lcd, xpos, ypos, thintel, buf, curr_hue, 255, 255, curr_hue, 255, 0);
if (max_layer_xpos < xpos) {
max_layer_xpos = xpos;
@ -200,7 +200,7 @@ void draw_ui_user(void) {
if (hue_redraw || power_state_redraw) {
static int max_power_xpos = 0;
xpos = 16;
snprintf_(buf, sizeof(buf), "power: %s", usbpd_str(kb_state.current_setting));
snprintf(buf, sizeof(buf), "power: %s", usbpd_str(kb_state.current_setting));
xpos += qp_drawtext_recolor(lcd, xpos, ypos, thintel, buf, curr_hue, 255, 255, curr_hue, 255, 0);
if (max_power_xpos < xpos) {
max_power_xpos = xpos;
@ -213,7 +213,7 @@ void draw_ui_user(void) {
if (hue_redraw || scan_redraw) {
static int max_scans_xpos = 0;
xpos = 16;
snprintf_(buf, sizeof(buf), "scans: %d", (int)theme_state.scan_rate);
snprintf(buf, sizeof(buf), "scans: %d", (int)theme_state.scan_rate);
xpos += qp_drawtext_recolor(lcd, xpos, ypos, thintel, buf, curr_hue, 255, 255, curr_hue, 255, 0);
if (max_scans_xpos < xpos) {
max_scans_xpos = xpos;
@ -226,7 +226,7 @@ void draw_ui_user(void) {
if (hue_redraw || wpm_redraw) {
static int max_wpm_xpos = 0;
xpos = 16;
snprintf_(buf, sizeof(buf), "wpm: %d", (int)get_current_wpm());
snprintf(buf, sizeof(buf), "wpm: %d", (int)get_current_wpm());
xpos += qp_drawtext_recolor(lcd, xpos, ypos, thintel, buf, curr_hue, 255, 255, curr_hue, 255, 0);
if (max_wpm_xpos < xpos) {
max_wpm_xpos = xpos;

View file

@ -161,7 +161,7 @@ static void command_common_help(void) {
}
static void print_version(void) {
print(/* clang-format off */
xprintf("%s", /* clang-format off */
"\n\t- Version -\n"
"VID: " STR(VENDOR_ID) "(" STR(MANUFACTURER) ") "
"PID: " STR(PRODUCT_ID) "(" STR(PRODUCT) ") "

View file

@ -100,7 +100,7 @@ void print_set_sendchar(sendchar_func_t func);
#define print_bin32(i) IGNORE_FORMAT_WARNING(xprintf("%032lb", i))
#define print_bin_reverse8(i) IGNORE_FORMAT_WARNING(xprintf("%08b", bitrev(i)))
#define print_bin_reverse16(i) IGNORE_FORMAT_WARNING(xprintf("%016b", bitrev16(i)))
#define print_bin_reverse32(i) IGNORE_FORMAT_WARNINGxprintf("%032lb", bitrev32(i)))
#define print_bin_reverse32(i) IGNORE_FORMAT_WARNING(xprintf("%032lb", bitrev32(i)))
/* print value utility */
#define print_val_dec(v) xprintf(#v ": %u\n", v)
#define print_val_decs(v) xprintf(#v ": %d\n", v)