-
-
Notifications
You must be signed in to change notification settings - Fork 39.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Short term fix for conflicting types for 'tfp_printf' #8157
Conversation
va_list va; | ||
va_start(va, fmt); | ||
tfp_format(&s, putcp, fmt, va); | ||
putcp(&s, 0); | ||
va_end(va); | ||
|
||
return 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was a void before, so no one can be checking the return code....
Question is, while not perfect, will this do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to this: http://www.cplusplus.com/reference/cstdio/printf/ the standard seems to be to return the number of characters written, or a negative number if unsuccessful. If tfp_format()
keeps track of that already, we could just change its return type too, and use that. Though I don't know how useful this information is, so returning 1
for now might be good enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be a more invasive change, things like uli2a
would need to be updated to return a count of written characters, then tfp_format
would need keep the tally. tfp_sprintf
could potentially return strlen
of the output buffer if it wants to be slightly more accurate. To be 100% compliant, we would need to do all the extra error handling.
At the moment, I kinda just want my board to compile... though I do see long term value in it being feature complete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we can use this fork of tinyprintf instead: https://github.com/cjlano/tinyprintf
It seems to have fixed a few bugs and added more functions, plus tfp_sprintf()
returns the number of characters already!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still has the tfp_printf void issue, and we would need to port the binary support into it. Worth considering, plus theres alternatives like https://github.com/mpaland/printf which tick both non void functions and binary support.
Edit: prepared a branch with the mpaland implementation https://github.com/qmk/qmk_firmware/compare/master...zvecr:feature/mpaland_printf?expand=1, seems to work fine with brief testing but it does increase chibios based firmware by 750 bytes.
5beea64
to
ae701e8
Compare
ae701e8
to
2948fdf
Compare
* 'master' of https://github.com/qmk/qmk_firmware: (37 commits) Update Hungarian keymap and add sendstring LUT (qmk#8220) Remove "ugly hack in usb_main.c" comments (qmk#8296) Update encoder functions for Iris VIA keymap (qmk#8295) Reduce PROGMEM usage for sendstring LUT (qmk#8109) [Docs] Update ISP Flashing guide (qmk#8149) Rewrite the Bathroom Epiphanies Frosty Flake matrix and LED handling (qmk#8243) Add onekey keymap for testing reset to bootloader. (qmk#8288) Get the direction right on the S75 encoder (qmk#8287) Prune out pure software pwm && custom driver && remove wrapping BACKLIGHT_PIN (qmk#8041) Make a fix to savage65 and tmov2 for via (qmk#8286) format code according to conventions [skip ci] Short term fix for conflicting types for 'tfp_printf' (qmk#8157) Fix recent clang-format breaking quantum.c (qmk#8282) format code according to conventions [skip ci] Remove duplicate BRTG case (qmk#8277) Clean up includes for glcdfont headers (qmk#7745) Fix the Breaking Changes doc again [Docs] translated 'feature_tap_dance.md' to japanese. (qmk#8137) PWM DMA based RGB Underglow for STM32 (qmk#7928) Add VIA support to Prime_M. Clean up all files (qmk#8247) ...
format code according to conventions [skip ci]
format code according to conventions [skip ci]
format code according to conventions [skip ci]
Description
When adding encoders to a board, while console is enabled, the following error is thrown
The route cause,
tfp_printf/tfp_sprintf
gets a macro alias to increase compatibility, however the signature of the tfp versions are not compliant.For reference, ive used http://www.cplusplus.com/reference/cstdio/printf/ and http://www.cplusplus.com/reference/cstdio/snprintf/, to update
tmk_core/common/chibios/printf.h
.Types of Changes
Checklist