Skip to content
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

Stop using PRI*8 printf formats. #15099

Merged
merged 1 commit into from
Feb 11, 2022

Conversation

bzbarsky-apple
Copy link
Contributor

These are not supported on some embedded/minimal libcs. Use %u/%d/%x
instead, since [u]int8_t will get promoted to int anyway when passed
via varargs.

This commit was generated by installing the git-extras package and running:

git sed -f g '" PRIu8 "' 'u'
git sed -f g '" PRIu8' 'u"'
git sed -f g '" PRIx8 "' 'x'
git sed -f g '" PRIx8' 'x"'
git sed -f g '" PRIX8 "' 'X'
git sed -f g '" PRIX8' 'X"'
git sed -f g '" PRId8 "' 'd'
git sed -f g '" PRId8' 'd"'

followed by the following manual fixups:

  1. Fixing a comment in src/app/MessageDef/StatusIB.cpp
  2. Deleting an unused macro in src/system/SystemStats.h
  3. Reverting the change the above git sed commands caused in
    third_party/lwip/repo/lwip/src/include/lwip/arch.h
  4. Adding a lint.
  5. Running restyle.

Problem

Log statements can print garbage or even crash, due to libcs ignoring these and ending up with format/args mismatches.

Change overview

See above.

Testing

Ideally no behavior changes in our CI, and fewer logging problems on devices.

These are not supported on some embedded/minimal libcs.  Use %u/%d/%x
instead, since [u]int8_t will get promoted to int anyway when passed
via varargs.

This commit was generated by installing the git-extras package and running:

    git sed -f g '" PRIu8 "' 'u'
    git sed -f g '" PRIu8' 'u"'
    git sed -f g '" PRIx8 "' 'x'
    git sed -f g '" PRIx8' 'x"'
    git sed -f g '" PRIX8 "' 'X'
    git sed -f g '" PRIX8' 'X"'
    git sed -f g '" PRId8 "' 'd'
    git sed -f g '" PRId8' 'd"'

followed by the following manual fixups:

1) Fixing a comment in src/app/MessageDef/StatusIB.cpp
2) Deleting an unused macro in src/system/SystemStats.h
3) Reverting the change the above git sed commands caused in
   third_party/lwip/repo/lwip/src/include/lwip/arch.h
4) Adding a lint.
5) Running restyle.
@github-actions
Copy link

github-actions bot commented Feb 11, 2022

PR #15099: Size comparison from 23d423f to f3c4fac

Decreases (29 builds for cyw30739, efr32, esp32, k32w, mbed, nrfconnect, p6, qpg, telink)
platform target config section 23d423f f3c4fac change % change
cyw30739 light cyw930739m2evb_01 (read/write) 592258 592230 -28 -0.0
.app_xip_area 497712 497684 -28 -0.0
lock cyw930739m2evb_01 (read/write) 550322 550294 -28 -0.0
.app_xip_area 457344 457316 -28 -0.0
ota-requestor cyw930739m2evb_01 (read/write) 568962 568930 -32 -0.0
.app_xip_area 466728 466696 -32 -0.0
efr32 lighting-app BRD4161A (read only) 908296 908240 -56 -0.0
.text 908288 908232 -56 -0.0
BRD4161A+rpc (read only) 895772 895716 -56 -0.0
.text 895764 895708 -56 -0.0
window-app BRD4161A (read only) 843520 843468 -52 -0.0
(read/write) 125472 125468 -4 -0.0
.text 843512 843460 -52 -0.0
esp32 all-clusters-app c3devkit (read/write) 1398706 1398498 -208 -0.0
.flash.rodata 199112 198904 -208 -0.1
m5stack (read/write) 463984 463792 -192 -0.0
.flash.rodata 226216 226024 -192 -0.1
k32w light k32w061+release (read/write) 682904 682836 -68 -0.0
.text 598520 598452 -68 -0.0
lock k32w061+release (read/write) 688316 688260 -56 -0.0
.text 603496 603440 -56 -0.0
mbed all-clusters-app CY8CPROTO_062_4343W+release (read/write) 2397384 2397216 -168 -0.0
.text 1359984 1359816 -168 -0.0
lighting-app CY8CPROTO_062_4343W+release (read/write) 2359280 2359240 -40 -0.0
.text 1321880 1321840 -40 -0.0
lock-app CY8CPROTO_062_4343W+release (read/write) 2322808 2322776 -32 -0.0
.text 1285408 1285376 -32 -0.0
shell CY8CPROTO_062_4343W+release (read/write) 2308172 2308124 -48 -0.0
.text 1270744 1270696 -48 -0.0
nrfconnect lighting-app nrf52840dk_nrf52840 (read/write) 1015203 1015147 -56 -0.0
rodata 120016 119960 -56 -0.0
nrf52840dk_nrf52840+rpc (read/write) 984035 983983 -52 -0.0
rodata 111384 111332 -52 -0.0
nrf52840dongle_nrf52840 (read/write) 1031083 1031039 -44 -0.0
rodata 118884 118840 -44 -0.0
nrf5340dk_nrf5340_cpuapp (read/write) 921894 921838 -56 -0.0
rodata 113256 113200 -56 -0.0
lock-app nrf52840dk_nrf52840 (read/write) 944947 944911 -36 -0.0
rodata 108760 108724 -36 -0.0
nrf5340dk_nrf5340_cpuapp (read/write) 852506 852466 -40 -0.0
rodata 101932 101892 -40 -0.0
pump-app nrf52840dk_nrf52840 (read/write) 943791 943727 -64 -0.0
rodata 107740 107676 -64 -0.1
pump-controller-app nrf52840dk_nrf52840 (read/write) 939711 939671 -40 -0.0
rodata 107412 107372 -40 -0.0
shell nrf52840dk_nrf52840 (read/write) 806755 806743 -12 -0.0
rodata 79080 79068 -12 -0.0
p6 all-clusters-app default (read/write) 2482400 2482208 -192 -0.0
.text 1440664 1440472 -192 -0.0
light-app default (read/write) 2389080 2389040 -40 -0.0
.text 1347344 1347304 -40 -0.0
lock-app default (read/write) 2352552 2352504 -48 -0.0
.text 1310816 1310768 -48 -0.0
qpg lighting-app qpg6105+debug (read only) 594484 594444 -40 -0.0
.text 589164 589124 -40 -0.0
lock-app qpg6105+debug (read only) 560232 560188 -44 -0.0
.text 554912 554868 -44 -0.0
telink lighting-app tlsr9518adk80d (read/write) 874214 874178 -36 -0.0
Full report (43 builds for cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
platform target config section 23d423f f3c4fac change % change
cyw30739 light cyw930739m2evb_01 (read/write) 592258 592230 -28 -0.0
.app_xip_area 497712 497684 -28 -0.0
.bss 77244 77244 0 0.0
.data 644 644 0 0.0
.rodata 0 0 0 0.0
.text 0 0 0 0.0
lock cyw930739m2evb_01 (read/write) 550322 550294 -28 -0.0
.app_xip_area 457344 457316 -28 -0.0
.bss 75716 75716 0 0.0
.data 608 608 0 0.0
.rodata 0 0 0 0.0
.text 0 0 0 0.0
ota-requestor cyw930739m2evb_01 (read/write) 568962 568930 -32 -0.0
.app_xip_area 466728 466696 -32 -0.0
.bss 84644 84644 0 0.0
.data 552 552 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
efr32 lighting-app BRD4161A (read only) 908296 908240 -56 -0.0
(read/write) 127408 127408 0 0.0
.bss 125376 125376 0 0.0
.data 2032 2032 0 0.0
.text 908288 908232 -56 -0.0
BRD4161A+rpc (read only) 895772 895716 -56 -0.0
(read/write) 144068 144068 0 0.0
.bss 141936 141936 0 0.0
.data 2132 2132 0 0.0
.text 895764 895708 -56 -0.0
window-app BRD4161A (read only) 843520 843468 -52 -0.0
(read/write) 125472 125468 -4 -0.0
.bss 123568 123568 0 0.0
.data 1900 1900 0 0.0
.text 843512 843460 -52 -0.0
esp32 all-clusters-app c3devkit (read only) 944494 944494 0 0.0
(read/write) 1398706 1398498 -208 -0.0
.dram0.bss 66432 66432 0 0.0
.dram0.data 14268 14268 0 0.0
.flash.rodata 199112 198904 -208 -0.1
.flash.text 944494 944494 0 0.0
.iram0.text 62056 62056 0 0.0
m5stack (read only) 994471 994471 0 0.0
(read/write) 463984 463792 -192 -0.0
.dram0.bss 71576 71576 0 0.0
.dram0.data 34064 34064 0 0.0
.flash.rodata 226216 226024 -192 -0.1
.flash.text 989087 989087 0 0.0
.iram0.text 123399 123399 0 0.0
k32w light k32w061+release (read/write) 682904 682836 -68 -0.0
.bss 76680 76680 0 0.0
.data 1904 1904 0 0.0
.text 598520 598452 -68 -0.0
lock k32w061+release (read/write) 688316 688260 -56 -0.0
.bss 77072 77072 0 0.0
.data 1948 1948 0 0.0
.text 603496 603440 -56 -0.0
linux all-clusters-app debug (read only) 2354633 2354633 0 0.0
(read/write) 140032 140032 0 0.0
.bss 54560 54560 0 0.0
.data 1296 1296 0 0.0
.data.rel.ro 78488 78488 0 0.0
.dynamic 592 592 0 0.0
.got 4136 4136 0 0.0
.init 27 27 0 0.0
.init_array 920 920 0 0.0
.rodata 205669 205669 0 0.0
.text 1986738 1986738 0 0.0
bridge-app debug+rpc (read only) 1723717 1723717 0 0.0
(read/write) 84200 84200 0 0.0
.bss 38960 38960 0 0.0
.data 2034 2034 0 0.0
.data.rel.ro 38056 38056 0 0.0
.dynamic 592 592 0 0.0
.got 3976 3976 0 0.0
.init 27 27 0 0.0
.init_array 560 560 0 0.0
.rodata 141548 141548 0 0.0
.text 1465669 1465669 0 0.0
chip-tool debug (read only) 8381709 8381709 0 0.0
(read/write) 245728 245728 0 0.0
.bss 32232 32232 0 0.0
.data 1184 1184 0 0.0
.data.rel.ro 206264 206264 0 0.0
.dynamic 608 608 0 0.0
.got 4784 4784 0 0.0
.init 27 27 0 0.0
.init_array 624 624 0 0.0
.rodata 459797 459797 0 0.0
.text 7406565 7406565 0 0.0
chip-tool-ipv6only arm64 (read only) 8193188 8193188 0 0.0
(read/write) 353233 353233 0 0.0
.bss 50529 50529 0 0.0
.data 1216 1216 0 0.0
.data.rel.ro 248680 248680 0 0.0
.dynamic 560 560 0 0.0
.got 49008 49008 0 0.0
.init 24 24 0 0.0
.init_array 192 192 0 0.0
.rodata 436012 436012 0 0.0
.text 6996340 6996340 0 0.0
door-lock-app debug (read only) 1928873 1928873 0 0.0
(read/write) 110520 110520 0 0.0
.bss 42032 42032 0 0.0
.data 1010 1010 0 0.0
.data.rel.ro 62064 62064 0 0.0
.dynamic 592 592 0 0.0
.got 4112 4112 0 0.0
.init 27 27 0 0.0
.init_array 672 672 0 0.0
.rodata 172946 172946 0 0.0
.text 1607458 1607458 0 0.0
lighting-app debug+rpc (read only) 2051993 2051993 0 0.0
(read/write) 115800 115800 0 0.0
.bss 43008 43008 0 0.0
.data 1464 1464 0 0.0
.data.rel.ro 65832 65832 0 0.0
.dynamic 608 608 0 0.0
.got 4144 4144 0 0.0
.init 27 27 0 0.0
.init_array 720 720 0 0.0
.rodata 165265 165265 0 0.0
.text 1731938 1731938 0 0.0
ota-provider-app debug (read only) 1862369 1862369 0 0.0
(read/write) 106200 106200 0 0.0
.bss 41888 41888 0 0.0
.data 1224 1224 0 0.0
.data.rel.ro 57432 57432 0 0.0
.dynamic 608 608 0 0.0
.got 4368 4368 0 0.0
.init 27 27 0 0.0
.init_array 624 624 0 0.0
.rodata 157363 157363 0 0.0
.text 1554466 1554466 0 0.0
ota-requestor-app debug (read only) 1857857 1857857 0 0.0
(read/write) 107288 107288 0 0.0
.bss 42176 42176 0 0.0
.data 1160 1160 0 0.0
.data.rel.ro 58504 58504 0 0.0
.dynamic 592 592 0 0.0
.got 4176 4176 0 0.0
.init 27 27 0 0.0
.init_array 624 624 0 0.0
.rodata 151076 151076 0 0.0
.text 1557986 1557986 0 0.0
shell debug (read only) 2338993 2338993 0 0.0
(read/write) 141520 141520 0 0.0
.bss 61824 61824 0 0.0
.data 832 832 0 0.0
.data.rel.ro 73168 73168 0 0.0
.dynamic 592 592 0 0.0
.got 4168 4168 0 0.0
.init 27 27 0 0.0
.init_array 904 904 0 0.0
.rodata 206546 206546 0 0.0
.text 1975714 1975714 0 0.0
thermostat-no-ble arm64 (read only) 2148172 2148172 0 0.0
(read/write) 140673 140673 0 0.0
.bss 57553 57553 0 0.0
.data 1032 1032 0 0.0
.data.rel.ro 74984 74984 0 0.0
.dynamic 560 560 0 0.0
.got 4144 4144 0 0.0
.init 24 24 0 0.0
.init_array 328 328 0 0.0
.rodata 132796 132796 0 0.0
.text 1797232 1797232 0 0.0
tv-app debug (read only) 2526233 2526233 0 0.0
(read/write) 139424 139424 0 0.0
.bss 57216 57216 0 0.0
.data 3200 3200 0 0.0
.data.rel.ro 72984 72984 0 0.0
.dynamic 592 592 0 0.0
.got 4528 4528 0 0.0
.init 27 27 0 0.0
.init_array 888 888 0 0.0
.rodata 197581 197581 0 0.0
.text 2155730 2155730 0 0.0
mbed all-clusters-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2397384 2397216 -168 -0.0
.bss 188500 188500 0 0.0
.data 5320 5320 0 0.0
.text 1359984 1359816 -168 -0.0
lighting-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2359280 2359240 -40 -0.0
.bss 181112 181112 0 0.0
.data 5624 5624 0 0.0
.text 1321880 1321840 -40 -0.0
lock-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2322808 2322776 -32 -0.0
.bss 181000 181000 0 0.0
.data 5600 5600 0 0.0
.text 1285408 1285376 -32 -0.0
pigweed-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 1139648 1139648 0 0.0
.bss 11756 11756 0 0.0
.data 4368 4368 0 0.0
.text 103032 103032 0 0.0
shell CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2308172 2308124 -48 -0.0
.bss 178252 178252 0 0.0
.data 5424 5424 0 0.0
.text 1270744 1270696 -48 -0.0
nrfconnect lighting-app nrf52840dk_nrf52840 (read/write) 1015203 1015147 -56 -0.0
bss 121436 121436 0 0.0
rodata 120016 119960 -56 -0.0
text 694824 694824 0 0.0
nrf52840dk_nrf52840+rpc (read/write) 984035 983983 -52 -0.0
bss 118624 118624 0 0.0
rodata 111384 111332 -52 -0.0
text 674440 674440 0 0.0
nrf52840dongle_nrf52840 (read/write) 1031083 1031039 -44 -0.0
bss 122824 122824 0 0.0
rodata 118884 118840 -44 -0.0
text 699460 699460 0 0.0
nrf5340dk_nrf5340_cpuapp (read/write) 921894 921838 -56 -0.0
bss 118000 118000 0 0.0
rodata 113256 113200 -56 -0.0
text 609848 609848 0 0.0
lock-app nrf52840dk_nrf52840 (read/write) 944947 944911 -36 -0.0
bss 119808 119808 0 0.0
rodata 108760 108724 -36 -0.0
text 637876 637876 0 0.0
nrf5340dk_nrf5340_cpuapp (read/write) 852506 852466 -40 -0.0
bss 116400 116400 0 0.0
rodata 101932 101892 -40 -0.0
text 553672 553672 0 0.0
pigweed-app nrf52840dk_nrf52840 (read/write) 527595 527595 0 0.0
bss 53632 53632 0 0.0
rodata 49976 49976 0 0.0
text 361016 361016 0 0.0
pump-app nrf52840dk_nrf52840 (read/write) 943791 943727 -64 -0.0
bss 119528 119528 0 0.0
rodata 107740 107676 -64 -0.1
text 637932 637932 0 0.0
pump-controller-app nrf52840dk_nrf52840 (read/write) 939711 939671 -40 -0.0
bss 119532 119532 0 0.0
rodata 107412 107372 -40 -0.0
text 634172 634172 0 0.0
shell nrf52840dk_nrf52840 (read/write) 806755 806743 -12 -0.0
bss 111216 111216 0 0.0
rodata 79080 79068 -12 -0.0
text 538872 538872 0 0.0
p6 all-clusters-app default (read/write) 2482400 2482208 -192 -0.0
.bss 117768 117768 0 0.0
.data 2672 2672 0 0.0
.text 1440664 1440472 -192 -0.0
light-app default (read/write) 2389080 2389040 -40 -0.0
.bss 107416 107416 0 0.0
.data 2520 2520 0 0.0
.text 1347344 1347304 -40 -0.0
lock-app default (read/write) 2352552 2352504 -48 -0.0
.bss 107136 107136 0 0.0
.data 2480 2480 0 0.0
.text 1310816 1310768 -48 -0.0
qpg lighting-app qpg6105+debug (read only) 594484 594444 -40 -0.0
(read/write) 146936 146936 0 0.0
.bss 88960 88960 0 0.0
.data 1108 1108 0 0.0
.text 589164 589124 -40 -0.0
lock-app qpg6105+debug (read only) 560232 560188 -44 -0.0
(read/write) 146936 146936 0 0.0
.bss 88944 88944 0 0.0
.data 1060 1060 0 0.0
.text 554912 554868 -44 -0.0
persistent-storage-app qpg6105+debug (read only) 99520 99520 0 0.0
(read/write) 146940 146940 0 0.0
.bss 24004 24004 0 0.0
.data 176 176 0 0.0
.text 94200 94200 0 0.0
telink lighting-app tlsr9518adk80d (read/write) 874214 874178 -36 -0.0
bss 88760 88760 0 0.0
noinit 37160 37160 0 0.0
text 614002 614002 0 0.0

@andy31415 andy31415 merged commit 2155328 into project-chip:master Feb 11, 2022
@bzbarsky-apple bzbarsky-apple deleted the nix-PRI-star-8 branch February 12, 2022 00:53
mspang added a commit to mspang/connectedhomeip that referenced this pull request Feb 12, 2022
jamesluo11 pushed a commit to jamesluo11/connectedhomeip that referenced this pull request Apr 26, 2022
These are not supported on some embedded/minimal libcs.  Use %u/%d/%x
instead, since [u]int8_t will get promoted to int anyway when passed
via varargs.

This commit was generated by installing the git-extras package and running:

    git sed -f g '" PRIu8 "' 'u'
    git sed -f g '" PRIu8' 'u"'
    git sed -f g '" PRIx8 "' 'x'
    git sed -f g '" PRIx8' 'x"'
    git sed -f g '" PRIX8 "' 'X'
    git sed -f g '" PRIX8' 'X"'
    git sed -f g '" PRId8 "' 'd'
    git sed -f g '" PRId8' 'd"'

followed by the following manual fixups:

1) Fixing a comment in src/app/MessageDef/StatusIB.cpp
2) Deleting an unused macro in src/system/SystemStats.h
3) Reverting the change the above git sed commands caused in
   third_party/lwip/repo/lwip/src/include/lwip/arch.h
4) Adding a lint.
5) Running restyle.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants