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

[logging] Use CHIP_ERROR_FORMAT in more places #19983

Merged
merged 1 commit into from
Jun 27, 2022

Conversation

Damian-Nordic
Copy link
Contributor

Problem

We have two alternative ways of logging an error code:

  • using CHIP_ERROR_FORMAT which resolves either to %s or %u
  • using %s + ErrorStr()

Both methods are supposed to have the same effect, but the former generates slightly smaller code, so it's worth using it everywhere.

Change overview

Replace: "%s", ErrorStr(err) with "%" CHIP_ERROR_FORMAT, err.Format() in most places.
Do minor cleanup of logs. For example, remove unnecessary new line characters.

Testing

Did smoke tests on nRF52840

We have two alternative ways of logging an error code:
- using CHIP_ERROR_FORMAT which resolves either to %s or %u
- using %s + ErrorStr()

Both methods are supposed to have the same effect, but the
former generates slightly smaller code.

Signed-off-by: Damian Krolik <[email protected]>
@github-actions
Copy link

github-actions bot commented Jun 25, 2022

PR #19983: Size comparison from 84a165d to d35a9cb

Increases (8 builds for cc13x2_26x2, esp32)
platform target config section 84a165d d35a9cb change % change
cc13x2_26x2 all-clusters-app LP_CC2652R7 (read/write) 187084 187324 240 0.1
.rodata 88059 88091 32 0.0
all-clusters-minimal-app LP_CC2652R7 (read/write) 197612 197832 220 0.1
.rodata 91563 91607 44 0.0
lock-ftd LP_CC2652R7 (read/write) 174692 174920 228 0.1
.rodata 76147 76183 36 0.0
lock-mtd LP_CC2652R7 .rodata 76027 76063 36 0.0
pump-app LP_CC2652R7 (read/write) 165720 165960 240 0.1
.rodata 88711 88751 40 0.0
pump-controller-app LP_CC2652R7 (read/write) 179960 180200 240 0.1
.rodata 84551 84591 40 0.0
shell LP_CC2652R7 (read/write) 190136 190372 236 0.1
.rodata 84814 84850 36 0.0
esp32 all-clusters-app c3devkit (read/write) 1487018 1487058 40 0.0
.flash.rodata 215128 215168 40 0.0
Decreases (36 builds for cc13x2_26x2, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, p6, telink)
platform target config section 84a165d d35a9cb change % change
cc13x2_26x2 all-clusters-app LP_CC2652R7 (read only) 665915 665675 -240 -0.0
.text 577540 577268 -272 -0.0
all-clusters-minimal-app LP_CC2652R7 (read only) 654683 654463 -220 -0.0
.text 562804 562540 -264 -0.0
lock-ftd LP_CC2652R7 (read only) 668451 668223 -228 -0.0
.text 591824 591560 -264 -0.0
lock-mtd LP_CC2652R7 (read only) 617867 617639 -228 -0.0
.text 541352 541088 -264 -0.0
pump-app LP_CC2652R7 (read only) 678279 678039 -240 -0.0
.text 589084 588804 -280 -0.0
pump-controller-app LP_CC2652R7 (read only) 664159 663919 -240 -0.0
.text 579128 578848 -280 -0.0
shell LP_CC2652R7 (read only) 658366 658130 -236 -0.0
.text 573236 572964 -272 -0.0
cyw30739 ota-requestor-no-progress-logging cyw930739m2evb_01 (read/write) 584726 584486 -240 -0.0
.app_xip_area 462568 462328 -240 -0.1
efr32 lighting-app BRD4161A (read/write) 1082848 1082620 -228 -0.0
.text 946008 945780 -228 -0.0
BRD4161A+rpc (read/write) 1137164 1136924 -240 -0.0
.text 983420 983184 -236 -0.0
BRD4161A+rs911x (read/write) 945656 945440 -216 -0.0
.text 803100 802884 -216 -0.0
lock-app BRD4161A+wf200 (read/write) 1122544 1122320 -224 -0.0
.text 979528 979304 -224 -0.0
window-app BRD4161A (read/write) 1068124 1067892 -232 -0.0
.text 931176 930940 -236 -0.0
esp32 all-clusters-app c3devkit (read only) 1019320 1019058 -262 -0.0
.flash.text 1019320 1019058 -262 -0.0
m5stack (read only) 1073427 1073187 -240 -0.0
(read/write) 489152 489144 -8 -0.0
.flash.rodata 245652 245644 -8 -0.0
.flash.text 1068043 1067803 -240 -0.0
k32w light k32w061+release (read/write) 660600 660344 -256 -0.0
.text 581516 581260 -256 -0.0
lock k32w061+release (read/write) 687008 686768 -240 -0.0
.text 607440 607200 -240 -0.0
linux chip-tool-no-interactive-ipv6only arm64 (read only) 9928900 9928148 -752 -0.0
.text 7915844 7915092 -752 -0.0
thermostat-no-ble arm64 (read only) 2597460 2596692 -768 -0.0
.text 2191536 2190768 -768 -0.0
mbed lock-app CY8CPROTO_062_4343W+release (read/write) 2448040 2447832 -208 -0.0
.text 1410684 1410476 -208 -0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 (read/write) 1175867 1175563 -304 -0.0
text 810556 810248 -308 -0.0
all-clusters-minimal-app nrf52840dk_nrf52840 (read/write) 1156735 1156431 -304 -0.0
text 800260 799956 -304 -0.0
lighting-app nrf52840dk_nrf52840 (read/write) 1168159 1167839 -320 -0.0
text 818956 818640 -316 -0.0
nrf52840dk_nrf52840+rpc (read/write) 1138327 1138007 -320 -0.0
text 796764 796448 -316 -0.0
nrf52840dongle_nrf52840 (read/write) 1074979 1074659 -320 -0.0
text 747352 747040 -312 -0.0
nrf5340dk_nrf5340_cpuapp (read/write) 1071834 1071530 -304 -0.0
text 731668 731352 -316 -0.0
lock-app nrf52840dk_nrf52840 (read/write) 1125815 1125511 -304 -0.0
text 769456 769144 -312 -0.0
nrf5340dk_nrf5340_cpuapp (read/write) 1029678 1029358 -320 -0.0
text 682236 681920 -316 -0.0
pump-app nrf52840dk_nrf52840 (read/write) 1081107 1080803 -304 -0.0
text 748652 748336 -316 -0.0
pump-controller-app nrf52840dk_nrf52840 (read/write) 1069011 1068703 -308 -0.0
rodata 114268 114264 -4 -0.0
text 740032 739716 -316 -0.0
p6 all-clusters-app default (read/write) 2564496 2564296 -200 -0.0
.text 1522760 1522560 -200 -0.0
all-clusters-minimal-app default (read/write) 2510360 2510144 -216 -0.0
.text 1468624 1468408 -216 -0.0
light-app default (read/write) 2440504 2440280 -224 -0.0
.text 1398768 1398544 -224 -0.0
lock-app default (read/write) 2466776 2466552 -224 -0.0
.text 1425040 1424816 -224 -0.0
telink light-switch-app tlsr9518adk80d (read/write) 799080 798776 -304 -0.0
text 565512 565208 -304 -0.1
lighting-app tlsr9518adk80d (read/write) 819044 818732 -312 -0.0
text 581952 581640 -312 -0.1
Full report (38 builds for cc13x2_26x2, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, p6, telink)
platform target config section 84a165d d35a9cb change % change
cc13x2_26x2 all-clusters-app LP_CC2652R7 (read only) 665915 665675 -240 -0.0
(read/write) 187084 187324 240 0.1
.bss 75892 75892 0 0.0
.data 3356 3356 0 0.0
.rodata 88059 88091 32 0.0
.text 577540 577268 -272 -0.0
all-clusters-minimal-app LP_CC2652R7 (read only) 654683 654463 -220 -0.0
(read/write) 197612 197832 220 0.1
.bss 75188 75188 0 0.0
.data 3356 3356 0 0.0
.rodata 91563 91607 44 0.0
.text 562804 562540 -264 -0.0
lock-ftd LP_CC2652R7 (read only) 668451 668223 -228 -0.0
(read/write) 174692 174920 228 0.1
.bss 72924 72924 0 0.0
.data 3280 3280 0 0.0
.rodata 76147 76183 36 0.0
.text 591824 591560 -264 -0.0
lock-mtd LP_CC2652R7 (read only) 617867 617639 -228 -0.0
(read/write) 146040 146040 0 0.0
.bss 68644 68644 0 0.0
.data 3280 3280 0 0.0
.rodata 76027 76063 36 0.0
.text 541352 541088 -264 -0.0
pump-app LP_CC2652R7 (read only) 678279 678039 -240 -0.0
(read/write) 165720 165960 240 0.1
.bss 73012 73012 0 0.0
.data 3280 3280 0 0.0
.rodata 88711 88751 40 0.0
.text 589084 588804 -280 -0.0
pump-controller-app LP_CC2652R7 (read only) 664159 663919 -240 -0.0
(read/write) 179960 180200 240 0.1
.bss 73132 73132 0 0.0
.data 3276 3276 0 0.0
.rodata 84551 84591 40 0.0
.text 579128 578848 -280 -0.0
shell LP_CC2652R7 (read only) 658366 658130 -236 -0.0
(read/write) 190136 190372 236 0.1
.bss 78196 78196 0 0.0
.data 3360 3360 0 0.0
.rodata 84814 84850 36 0.0
.text 573236 572964 -272 -0.0
cyw30739 light cyw930739m2evb_01 (read/write) 580974 580974 0 0.0
.app_xip_area 457968 457968 0 0.0
.bss 65968 65968 0 0.0
.data 716 716 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
lock cyw930739m2evb_01 (read/write) 582534 582534 0 0.0
.app_xip_area 459336 459336 0 0.0
.bss 66160 66160 0 0.0
.data 720 720 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
ota-requestor-no-progress-logging cyw930739m2evb_01 (read/write) 584726 584486 -240 -0.0
.app_xip_area 462568 462328 -240 -0.1
.bss 65176 65176 0 0.0
.data 660 660 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
efr32 lighting-app BRD4161A (read/write) 1082848 1082620 -228 -0.0
.bss 134772 134772 0 0.0
.data 2048 2048 0 0.0
.text 946008 945780 -228 -0.0
BRD4161A+rpc (read/write) 1137164 1136924 -240 -0.0
.bss 151460 151460 0 0.0
.data 2260 2260 0 0.0
.text 983420 983184 -236 -0.0
BRD4161A+rs911x (read/write) 945656 945440 -216 -0.0
.bss 140488 140488 0 0.0
.data 2048 2048 0 0.0
.text 803100 802884 -216 -0.0
lock-app BRD4161A+wf200 (read/write) 1122544 1122320 -224 -0.0
.bss 140936 140936 0 0.0
.data 2060 2060 0 0.0
.text 979528 979304 -224 -0.0
window-app BRD4161A (read/write) 1068124 1067892 -232 -0.0
.bss 134852 134852 0 0.0
.data 2076 2076 0 0.0
.text 931176 930940 -236 -0.0
esp32 all-clusters-app c3devkit (read only) 1019320 1019058 -262 -0.0
(read/write) 1487018 1487058 40 0.0
.dram0.bss 71840 71840 0 0.0
.dram0.data 14624 14624 0 0.0
.flash.rodata 215128 215168 40 0.0
.flash.text 1019320 1019058 -262 -0.0
.iram0.text 62902 62902 0 0.0
m5stack (read only) 1073427 1073187 -240 -0.0
(read/write) 489152 489144 -8 -0.0
.dram0.bss 77360 77360 0 0.0
.dram0.data 34144 34144 0 0.0
.flash.rodata 245652 245644 -8 -0.0
.flash.text 1068043 1067803 -240 -0.0
.iram0.text 123267 123267 0 0.0
k32w light k32w061+release (read/write) 660600 660344 -256 -0.0
.bss 71292 71292 0 0.0
.data 1992 1992 0 0.0
.text 581516 581260 -256 -0.0
lock k32w061+release (read/write) 687008 686768 -240 -0.0
.bss 71764 71764 0 0.0
.data 2004 2004 0 0.0
.text 607440 607200 -240 -0.0
linux chip-tool-no-interactive-ipv6only arm64 (read only) 9928900 9928148 -752 -0.0
(read/write) 675697 675697 0 0.0
.bss 42641 42641 0 0.0
.data 1152 1152 0 0.0
.data.rel.ro 614632 614632 0 0.0
.dynamic 528 528 0 0.0
.got 13456 13456 0 0.0
.init 24 24 0 0.0
.init_array 192 192 0 0.0
.rodata 473380 473380 0 0.0
.text 7915844 7915092 -752 -0.0
thermostat-no-ble arm64 (read only) 2597460 2596692 -768 -0.0
(read/write) 181793 181793 0 0.0
.bss 88721 88721 0 0.0
.data 1704 1704 0 0.0
.data.rel.ro 83256 83256 0 0.0
.dynamic 528 528 0 0.0
.got 5088 5088 0 0.0
.init 24 24 0 0.0
.init_array 400 400 0 0.0
.rodata 166148 166148 0 0.0
.text 2191536 2190768 -768 -0.0
mbed lock-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2448040 2447832 -208 -0.0
.bss 215732 215732 0 0.0
.data 5872 5872 0 0.0
.text 1410684 1410476 -208 -0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 (read/write) 1175867 1175563 -304 -0.0
bss 144666 144666 0 0.0
rodata 141724 141724 0 0.0
text 810556 810248 -308 -0.0
all-clusters-minimal-app nrf52840dk_nrf52840 (read/write) 1156735 1156431 -304 -0.0
bss 143902 143902 0 0.0
rodata 133656 133656 0 0.0
text 800260 799956 -304 -0.0
lighting-app nrf52840dk_nrf52840 (read/write) 1168159 1167839 -320 -0.0
bss 146229 146229 0 0.0
rodata 124104 124104 0 0.0
text 818956 818640 -316 -0.0
nrf52840dk_nrf52840+rpc (read/write) 1138327 1138007 -320 -0.0
bss 146674 146674 0 0.0
rodata 115648 115648 0 0.0
text 796764 796448 -316 -0.0
nrf52840dongle_nrf52840 (read/write) 1074979 1074659 -320 -0.0
bss 153460 153460 0 0.0
rodata 93148 93148 0 0.0
text 747352 747040 -312 -0.0
nrf5340dk_nrf5340_cpuapp (read/write) 1071834 1071530 -304 -0.0
bss 142600 142600 0 0.0
rodata 116512 116512 0 0.0
text 731668 731352 -316 -0.0
lock-app nrf52840dk_nrf52840 (read/write) 1125815 1125511 -304 -0.0
bss 136205 136205 0 0.0
rodata 141288 141288 0 0.0
text 769456 769144 -312 -0.0
nrf5340dk_nrf5340_cpuapp (read/write) 1029678 1029358 -320 -0.0
bss 132608 132608 0 0.0
rodata 133756 133756 0 0.0
text 682236 681920 -316 -0.0
pump-app nrf52840dk_nrf52840 (read/write) 1081107 1080803 -304 -0.0
bss 136124 136124 0 0.0
rodata 117484 117484 0 0.0
text 748652 748336 -316 -0.0
pump-controller-app nrf52840dk_nrf52840 (read/write) 1069011 1068703 -308 -0.0
bss 135919 135919 0 0.0
rodata 114268 114264 -4 -0.0
text 740032 739716 -316 -0.0
p6 all-clusters-app default (read/write) 2564496 2564296 -200 -0.0
.bss 150912 150912 0 0.0
.data 2776 2776 0 0.0
.text 1522760 1522560 -200 -0.0
all-clusters-minimal-app default (read/write) 2510360 2510144 -216 -0.0
.bss 150192 150192 0 0.0
.data 2776 2776 0 0.0
.text 1468624 1468408 -216 -0.0
light-app default (read/write) 2440504 2440280 -224 -0.0
.bss 142248 142248 0 0.0
.data 2592 2592 0 0.0
.text 1398768 1398544 -224 -0.0
lock-app default (read/write) 2466776 2466552 -224 -0.0
.bss 142096 142096 0 0.0
.data 2600 2600 0 0.0
.text 1425040 1424816 -224 -0.0
telink light-switch-app tlsr9518adk80d (read/write) 799080 798776 -304 -0.0
bss 72360 72360 0 0.0
noinit 40416 40416 0 0.0
text 565512 565208 -304 -0.1
lighting-app tlsr9518adk80d (read/write) 819044 818732 -312 -0.0
bss 73180 73180 0 0.0
noinit 40416 40416 0 0.0
text 581952 581640 -312 -0.1

@Damian-Nordic Damian-Nordic merged commit 5e9d413 into project-chip:master Jun 27, 2022
@Damian-Nordic Damian-Nordic deleted the log-format branch June 27, 2022 07:02
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.

3 participants