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

Add support for signed/bool to BufferReader/Writer #27637

Merged
merged 2 commits into from
Jul 6, 2023

Conversation

tcarmelveilleux
Copy link
Contributor

Problem

Changes in this PR

  • Adds signed and bool support to BufferWriter and to Reader
  • Adds missing unit tests
  • Makes it clear that low-level reads are not to be used directly

Testing done

  • Integration tests pass
  • New unit tests added and pass
  • Existing unit tests all pass

Problem:

- Safe buffer reader/writer doesn't support signed values
- Safe buffer reader/writer doesn't support bools
- Fixes project-chip#27629

This PR:

- Adds signed and bool support to BufferWriter and to Reader
- Adds missing unit tests
- Makes it clear that low-level reads are not to be used directly

Testing done:
- Integration tests pass
- New unit tests added and pass
- Existing unit tests all pass
@github-actions
Copy link

github-actions bot commented Jul 5, 2023

PR #27637: Size comparison from 7e3aa84 to 4d1f6b0

Increases (58 builds for bl602, bl702, bl702l, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, telink)
platform target config section 7e3aa84 4d1f6b0 change % change
bl602 lighting-app bl602 (read/write) 1367598 1367614 16 0.0
.text 1051738 1051758 20 0.0
bl602+rpc (read/write) 1415034 1415058 24 0.0
.text 1083630 1083652 22 0.0
bl702 lighting-app bl702 (read/write) 1178715 1178739 24 0.0
.debug_aranges 150792 150888 96 0.1
.debug_frame 554536 554944 408 0.1
.debug_info 41862603 41872622 10019 0.0
.debug_line 5603042 5604554 1512 0.0
.debug_loc 3810100 3811526 1426 0.0
.debug_ranges 396376 396504 128 0.0
.debug_str 4369223 4372884 3661 0.1
.strtab 582174 582262 88 0.0
.text 945846 945870 24 0.0
bl702+rpc (read/write) 1277355 1277379 24 0.0
.debug_aranges 159280 159376 96 0.1
.debug_frame 583220 583628 408 0.1
.debug_info 47051213 47061232 10019 0.0
.debug_line 6029712 6031224 1512 0.0
.debug_loc 4015633 4016948 1315 0.0
.debug_ranges 422064 422192 128 0.0
.debug_str 4797999 4801242 3243 0.1
.strtab 645115 645203 88 0.0
.text 1020244 1020268 24 0.0
bl702l lighting-app bl702l (read/write) 1159096 1159120 24 0.0
.debug_aranges 144936 145032 96 0.1
.debug_frame 533168 533576 408 0.1
.debug_info 41855953 4186597 10019 0.0
.debug_line 5508938 5510450 1512 0.0
.debug_loc 3742797 3744153 1356 0.0
.debug_ranges 401272 401400 128 0.0
.debug_str 4379917 4383578 3661 0.1
.strtab 582081 582169 88 0.0
.text 934406 934430 24 0.0
cc32xx lock CC3235SF_LAUNCHXL (read only) 607978 608002 24 0.0
.debug_aranges 119328 119424 96 0.1
.debug_frame 407584 407872 288 0.1
.debug_info 19971040 19982323 11283 0.1
.debug_line 2878258 2879185 927 0.0
.debug_loclists 1732567 1733486 919 0.1
.debug_rnglists 107833 107905 72 0.1
.debug_str 3811978 3815696 3718 0.1
.strtab 485180 485268 88 0.0
.text 500992 501016 24 0.0
cyw30739 light cyw930739m2evb_01 (read/write) 545423 545439 16 0.0
.app_xip_area 437881 437897 16 0.0
lock cyw930739m2evb_01 (read/write) 530495 530511 16 0.0
.app_xip_area 417977 417993 16 0.0
ota-requestor cyw930739m2evb_01 (read/write) 568495 568519 24 0.0
.app_xip_area 462041 462065 24 0.0
switch cyw930739m2evb_01 (read/write) 541671 541687 16 0.0
.app_xip_area 432265 432281 16 0.0
efr32 lighting-app BRD4161A+rs9116 (read/write) 998168 998184 16 0.0
.text 813988 814004 16 0.0
BRD4187C (read/write) 1027276 1027292 16 0.0
.text 862732 862748 16 0.0
lock-app BRD4161A+wf200 (read/write) 1076160 1076176 16 0.0
.text 897868 897884 16 0.0
window-app BRD4187C (read/write) 1097868 1097892 24 0.0
.text 950420 950444 24 0.0
esp32 all-clusters-app c3devkit (read only) 1088788 1088802 14 0.0
.flash.text 1088788 1088802 14 0.0
m5stack (read only) 1135459 1135467 8 0.0
.flash.text 1130075 1130083 8 0.0
k32w contact k32w0+release (read only) 586476 586492 16 0.0
.text 585940 585956 16 0.0
light k32w0+release (read only) 585180 585196 16 0.0
.text 584644 584660 16 0.0
lock k32w0+release (read only) 557756 557772 16 0.0
.text 557220 557236 16 0.0
linux all-clusters-app debug (read only) 3343605 3344309 704 0.0
.rodata 233352 233384 32 0.0
.text 2917413 2918085 672 0.0
all-clusters-minimal-app debug (read only) 3056957 3057661 704 0.0
.rodata 224456 224488 32 0.0
.text 2645621 2646293 672 0.0
bridge-app debug (read only) 2525485 2526189 704 0.0
.rodata 172968 173000 32 0.0
.text 2179381 2180053 672 0.0
chip-tool debug (read only) 18163849 18164585 736 0.0
.rodata 765473 765505 32 0.0
.text 15593699 15594403 704 0.0
chip-tool-ipv6only arm64 (read only) 17479712 17480288 576 0.0
.text 14802228 14802804 576 0.0
lighting-app debug+rpc+ui (read only) 5209849 5210553 704 0.0
.rodata 329268 329300 32 0.0
.text 4640803 4641475 672 0.0
lock-app debug (read only) 2618181 2618885 704 0.0
.rodata 200456 200488 32 0.0
.text 2252757 2253429 672 0.0
ota-provider-app debug (read only) 2214685 2215389 704 0.0
.rodata 154088 154120 32 0.0
.text 1918261 1918933 672 0.0
ota-requestor-app debug (read only) 2383669 2384389 720 0.0
.rodata 158184 158216 32 0.0
.text 2074277 2074965 688 0.0
shell debug (read only) 2879745 2880465 720 0.0
.rodata 201522 201554 32 0.0
.text 2509410 2510098 688 0.0
thermostat-no-ble arm64 (read only) 2611468 2611996 528 0.0
.text 2215748 2216276 528 0.0
tv-app debug (read only) 3320481 3321201 720 0.0
.rodata 222776 222808 32 0.0
.text 2900706 2901394 688 0.0
tv-casting-app debug (read only) 9314481 9315201 720 0.0
.rodata 330932 330964 32 0.0
.text 8548546 8549234 688 0.0
mbed lock-app-release cy8cproto_062_4343w (read/write) 2515512 2515576 64 0.0
.text 1478196 1478260 64 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 (read/write) 1224744 1224776 32 0.0
text 850868 850888 20 0.0
nrf7002dk_nrf5340_cpuapp (read/write) 1325764 1325780 16 0.0
text 762300 762312 12 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 (read/write) 1151724 1151740 16 0.0
text 807416 807428 12 0.0
psoc6 all-clusters cy8ckit_062s2_43012 (read/write) 1746300 1746316 16 0.0
.debug_aranges 150832 150928 96 0.1
.debug_frame 505260 505548 288 0.1
.debug_info 29654330 29666097 11767 0.0
.debug_line 4085970 4086896 926 0.0
.debug_loclists 2338168 2339038 870 0.0
.debug_rnglists 146351 146423 72 0.0
.debug_str 4421901 4425609 3708 0.1
.strtab 775714 775802 88 0.0
.text 1545932 1545948 16 0.0
all-clusters-minimal cy8ckit_062s2_43012 (read/write) 1664668 1664684 16 0.0
.debug_aranges 148064 148160 96 0.1
.debug_frame 501056 501344 288 0.1
.debug_info 28374373 28386139 11766 0.0
.debug_line 4039122 4040048 926 0.0
.debug_loclists 2296408 2297278 870 0.0
.debug_rnglists 143101 143173 72 0.1
.debug_str 4364072 4367780 3708 0.1
.strtab 703355 703443 88 0.0
.text 1466148 1466164 16 0.0
light cy8ckit_062s2_43012 (read/write) 1597324 1597340 16 0.0
.debug_aranges 138424 138520 96 0.1
.debug_frame 465024 465312 288 0.1
.debug_info 23155733 23167263 11530 0.0
.debug_line 3611074 3612000 926 0.0
.debug_loclists 2137509 2138379 870 0.0
.debug_rnglists 133135 133207 72 0.1
.debug_str 4177823 4181531 3708 0.1
.strtab 626852 626940 88 0.0
.text 1405012 1405028 16 0.0
lock cy8ckit_062s2_43012 (read/write) 1628220 1628236 16 0.0
.debug_aranges 136520 136616 96 0.1
.debug_frame 458284 458572 288 0.1
.debug_info 22854244 22865773 11529 0.1
.debug_line 3546344 3547270 926 0.0
.debug_loclists 2106089 2106959 870 0.0
.debug_rnglists 130659 130731 72 0.1
.debug_str 4133007 4136715 3708 0.1
.strtab 597081 597169 88 0.0
.text 1408452 1408468 16 0.0
qpg lighting-app qpg6105+debug (read/write) 1172304 1172320 16 0.0
.text 619144 619160 16 0.0
lock-app qpg6105+debug (read/write) 1130424 1130440 16 0.0
.text 577268 577284 16 0.0
telink all-clusters-app tlsr9518adk80d (read/write) 1050600 1050616 16 0.0
text 721456 721470 14 0.0
all-clusters-minimal-app tlsr9518adk80d (read/write) 964972 964988 16 0.0
text 668002 668014 12 0.0
bridge-app tlsr9518adk80d (read/write) 930372 930388 16 0.0
text 643056 643068 12 0.0
contact-sensor-app tlsr9518adk80d (read/write) 862080 862096 16 0.0
text 586228 586242 14 0.0
light-switch-app tlsr9518adk80d (read/write) 890684 890700 16 0.0
text 611688 611704 16 0.0
lighting-app tlsr9518adk80d (read/write) 968928 968944 16 0.0
text 681968 681986 18 0.0
lighting-app-factory-data tlsr9518adk80d (read/write) 980300 980324 24 0.0
text 689488 689506 18 0.0
lighting-app-rpc tlsr9518adk80d (read/write) 1038412 1038428 16 0.0
text 726858 726876 18 0.0
lighting-app-shell tlsr9518adk80d (read/write) 1069776 1069792 16 0.0
text 747004 747024 20 0.0
lock-app tlsr9518adk80d (read/write) 917192 917200 8 0.0
text 614894 614908 14 0.0
ota-requestor-app tlsr9518adk80d (read/write) 884680 884696 16 0.0
text 608070 608086 16 0.0
pump-app tlsr9518adk80d (read/write) 867680 867696 16 0.0
text 591988 592002 14 0.0
pump-controller-app tlsr9518adk80d (read/write) 854700 854716 16 0.0
text 582332 582346 14 0.0
temperature-measurement-app tlsr9518adk80d (read/write) 850856 850864 8 0.0
text 577962 577974 12 0.0
thermostat tlsr9518adk80d (read/write) 896760 896784 24 0.0
text 617376 617394 18 0.0
window-covering tlsr9518adk80d (read/write) 892140 892156 16 0.0
text 612298 612314 16 0.0
Decreases (8 builds for bl702, bl702l, cc32xx, psoc6)
platform target config section 7e3aa84 4d1f6b0 change % change
bl702 lighting-app bl702 .debug_abbrev 1551791 1551788 -3 -0.0
bl702+rpc .debug_abbrev 1717074 1717071 -3 -0.0
bl702l lighting-app bl702l .debug_abbrev 1552694 1552691 -3 -0.0
cc32xx lock CC3235SF_LAUNCHXL .debug_abbrev 948237 948154 -83 -0.0
psoc6 all-clusters cy8ckit_062s2_43012 .debug_abbrev 1314218 1314082 -136 -0.0
all-clusters-minimal cy8ckit_062s2_43012 .debug_abbrev 1281948 1281812 -136 -0.0
light cy8ckit_062s2_43012 .debug_abbrev 1118805 1118669 -136 -0.0
lock cy8ckit_062s2_43012 .debug_abbrev 1101049 1100913 -136 -0.0
Full report (58 builds for bl602, bl702, bl702l, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, telink)
platform target config section 7e3aa84 4d1f6b0 change % change
bl602 lighting-app bl602 (read/write) 1367598 1367614 16 0.0
.bss 83942 83942 0 0.0
.data 9624 9624 0 0.0
.text 1051738 1051758 20 0.0
bl602+rpc (read/write) 1415034 1415058 24 0.0
.bss 91990 91990 0 0.0
.data 10024 10024 0 0.0
.text 1083630 1083652 22 0.0
bl702 lighting-app bl702 (read/write) 1178715 1178739 24 0.0
.bleromro 6342 6342 0 0.0
.bleromrw 124 124 0 0.0
.boot2 328 328 0 0.0
.bss 77773 77773 0 0.0
.bss_psram 24656 24656 0 0.0
.comment 48 48 0 0.0
.data 3592 3592 0 0.0
.debug_abbrev 1551791 1551788 -3 -0.0
.debug_aranges 150792 150888 96 0.1
.debug_frame 554536 554944 408 0.1
.debug_info 41862603 41872622 10019 0.0
.debug_line 5603042 5604554 1512 0.0
.debug_loc 3810100 3811526 1426 0.0
.debug_ranges 396376 396504 128 0.0
.debug_str 4369223 4372884 3661 0.1
.hbn 544 544 0 0.0
.hbn_noinit 260 260 0 0.0
.init 342 342 0 0.0
.init_array 140 140 0 0.0
.psram 0 0 0 0.0
.riscv.attributes 47 47 0 0.0
.rodata 105700 105700 0 0.0
.rsvd 4 4 0 0.0
.sha_ocram 72 72 0 0.0
.shstrtab 304 304 0 0.0
.stack 2048 2048 0 0.0
.strtab 582174 582262 88 0.0
.symtab 174176 174176 0 0.0
.tcm_data 28 28 0 0.0
.tcmcode 3394 3394 0 0.0
.text 0 0 0 0.0
945846 945870 24 0.0
bl702+rpc (read/write) 1277355 1277379 24 0.0
.bleromro 6342 6342 0 0.0
.bleromrw 124 124 0 0.0
.boot2 328 328 0 0.0
.bss 85821 85821 0 0.0
.bss_psram 25072 25072 0 0.0
.comment 48 48 0 0.0
.data 4144 4144 0 0.0
.debug_abbrev 1717074 1717071 -3 -0.0
.debug_aranges 159280 159376 96 0.1
.debug_frame 583220 583628 408 0.1
.debug_info 47051213 47061232 10019 0.0
.debug_line 6029712 6031224 1512 0.0
.debug_loc 4015633 4016948 1315 0.0
.debug_ranges 422064 422192 128 0.0
.debug_str 4797999 4801242 3243 0.1
.hbn 544 544 0 0.0
.hbn_noinit 260 260 0 0.0
.init 342 342 0 0.0
.init_array 156 156 0 0.0
.psram 0 0 0 0.0
.riscv.attributes 47 47 0 0.0
.rodata 120352 120352 0 0.0
.rsvd 4 4 0 0.0
.sha_ocram 72 72 0 0.0
.shstrtab 304 304 0 0.0
.stack 2048 2048 0 0.0
.strtab 645115 645203 88 0.0
.symtab 193088 193088 0 0.0
.tcm_data 28 28 0 0.0
.tcmcode 3394 3394 0 0.0
.text 0 0 0 0.0
1020244 1020268 24 0.0
bl702l lighting-app bl702l (read only) 278 278 0 0.0
(read/write) 1159096 1159120 24 0.0
.boot2 292 292 0 0.0
.bss 40776 40776 0 0.0
.bss_psram 69168 69168 0 0.0
.comment 48 48 0 0.0
.data 4560 4560 0 0.0
.debug_abbrev 1552694 1552691 -3 -0.0
.debug_aranges 144936 145032 96 0.1
.debug_frame 533168 533576 408 0.1
.debug_info 41855953 4186597 10019 0.0
.debug_line 5508938 5510450 1512 0.0
.debug_loc 3742797 3744153 1356 0.0
.debug_ranges 401272 401400 128 0.0
.debug_str 4379917 4383578 3661 0.1
.hbn 3244 3244 0 0.0
.hbn_noinit 308 308 0 0.0
.init 408 408 0 0.0
.init_array 140 140 0 0.0
.riscv.attributes 47 47 0 0.0
.rodata 99648 99648 0 0.0
.romdata 3224 3224 0 0.0
.rsvd 4 4 0 0.0
.sha_ocram 72 72 0 0.0
.shstrtab 286 286 0 0.0
.stack 2048 2048 0 0.0
.strtab 582081 582169 88 0.0
.symtab 173504 173504 0 0.0
.tcm_data 692 692 0 0.0
.tcmcode 278 278 0 0.0
.text 0 0 0 0.0
934406 934430 24 0.0
cc32xx lock CC3235SF_LAUNCHXL (blank) 0 0 0 0.0
(read only) 607978 608002 24 0.0
(read/write) 204172 204172 0 0.0
.ARM.attributes 44 44 0 0.0
.ARM.exidx 8 8 0 0.0
.bss 197584 197584 0 0.0
.comment 206 206 0 0.0
.data 1468 1468 0 0.0
.debug_abbrev 948237 948154 -83 -0.0
.debug_aranges 119328 119424 96 0.1
.debug_frame 407584 407872 288 0.1
.debug_info 19971040 19982323 11283 0.1
.debug_line 2878258 2879185 927 0.0
.debug_line_str 513 513 0 0.0
.debug_loc 33340 33340 0 0.0
.debug_loclists 1732567 1733486 919 0.1
.debug_ranges 4984 4984 0 0.0
.debug_rnglists 107833 107905 72 0.1
.debug_str 3811978 3815696 3718 0.1
.ramVecs 780 780 0 0.0
.resetVecs 64 64 0 0.0
.rodata 104866 104866 0 0.0
.shstrtab 265 265 0 0.0
.stack 2048 2048 0 0.0
.strtab 485180 485268 88 0.0
.symtab 288304 288304 0 0.0
.text 500992 501016 24 0.0
cyw30739 light cyw930739m2evb_01 (read/write) 545423 545439 16 0.0
.app_xip_area 437881 437897 16 0.0
.bss 62512 62512 0 0.0
.data 712 712 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
lock cyw930739m2evb_01 (read/write) 530495 530511 16 0.0
.app_xip_area 417977 417993 16 0.0
.bss 67480 67480 0 0.0
.data 720 720 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
ota-requestor cyw930739m2evb_01 (read/write) 568495 568519 24 0.0
.app_xip_area 462041 462065 24 0.0
.bss 61472 61472 0 0.0
.data 668 668 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
switch cyw930739m2evb_01 (read/write) 541671 541687 16 0.0
.app_xip_area 432265 432281 16 0.0
.bss 64344 64344 0 0.0
.data 744 744 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
efr32 lighting-app BRD4161A+rs9116 (read/write) 998168 998184 16 0.0
.bss 182008 182008 0 0.0
.data 2148 2148 0 0.0
.text 813988 814004 16 0.0
BRD4187C (read/write) 1027276 1027292 16 0.0
.bss 161732 161732 0 0.0
.data 2792 2792 0 0.0
.text 862732 862748 16 0.0
lock-app BRD4161A+wf200 (read/write) 1076160 1076176 16 0.0
.bss 176120 176120 0 0.0
.data 2152 2152 0 0.0
.text 897868 897884 16 0.0
window-app BRD4187C (read/write) 1097868 1097892 24 0.0
.bss 144740 144740 0 0.0
.data 2688 2688 0 0.0
.text 950420 950444 24 0.0
esp32 all-clusters-app c3devkit (read only) 1088788 1088802 14 0.0
(read/write) 1586728 1586728 0 0.0
.dram0.bss 75944 75944 0 0.0
.dram0.data 13940 13940 0 0.0
.flash.rodata 217696 217696 0 0.0
.flash.text 1088788 1088802 14 0.0
.iram0.text 76740 76740 0 0.0
m5stack (read only) 1135459 1135467 8 0.0
(read/write) 497126 497126 0 0.0
.dram0.bss 81424 81424 0 0.0
.dram0.data 34304 34304 0 0.0
.flash.rodata 246248 246248 0 0.0
.flash.text 1130075 1130083 8 0.0
.iram0.text 126055 126055 0 0.0
k32w contact k32w0+release (read only) 586476 586492 16 0.0
(read/write) 90112 90112 0 0.0
.bss 66108 66108 0 0.0
.data 2168 2168 0 0.0
.text 585940 585956 16 0.0
light k32w0+release (read only) 585180 585196 16 0.0
(read/write) 89760 89760 0 0.0
.bss 65772 65772 0 0.0
.data 2156 2156 0 0.0
.text 584644 584660 16 0.0
lock k32w0+release (read only) 557756 557772 16 0.0
(read/write) 87560 87560 0 0.0
.bss 63636 63636 0 0.0
.data 2100 2100 0 0.0
.text 557220 557236 16 0.0
linux all-clusters-app debug (read only) 3343605 3344309 704 0.0
(read/write) 160904 160904 0 0.0
.bss 60288 60288 0 0.0
.data 2160 2160 0 0.0
.data.rel.ro 91944 91944 0 0.0
.dynamic 608 608 0 0.0
.got 4728 4728 0 0.0
.init 27 27 0 0.0
.init_array 1152 1152 0 0.0
.rodata 233352 233384 32 0.0
.text 2917413 2918085 672 0.0
all-clusters-minimal-app debug (read only) 3056957 3057661 704 0.0
(read/write) 146664 146664 0 0.0
.bss 58176 58176 0 0.0
.data 2128 2128 0 0.0
.data.rel.ro 79960 79960 0 0.0
.dynamic 608 608 0 0.0
.got 4664 4664 0 0.0
.init 27 27 0 0.0
.init_array 1088 1088 0 0.0
.rodata 224456 224488 32 0.0
.text 2645621 2646293 672 0.0
bridge-app debug (read only) 2525485 2526189 704 0.0
(read/write) 129960 129960 0 0.0
.bss 50296 50296 0 0.0
.data 3824 3824 0 0.0
.data.rel.ro 69864 69864 0 0.0
.dynamic 608 608 0 0.0
.got 4568 4568 0 0.0
.init 27 27 0 0.0
.init_array 776 776 0 0.0
.rodata 172968 173000 32 0.0
.text 2179381 2180053 672 0.0
chip-tool debug (read only) 18163849 18164585 736 0.0
(read/write) 843088 843088 0 0.0
.bss 93528 93528 0 0.0
.data 5154 5154 0 0.0
.data.rel.ro 737072 737072 0 0.0
.dynamic 624 624 0 0.0
.got 5888 5888 0 0.0
.init 27 27 0 0.0
.init_array 784 784 0 0.0
.rodata 765473 765505 32 0.0
.text 15593699 15594403 704 0.0
chip-tool-ipv6only arm64 (read only) 17479712 17480288 576 0.0
(read/write) 910664 910664 0 0.0
.bss 102936 102936 0 0.0
.data 4448 4448 0 0.0
.data.rel.ro 774320 774320 0 0.0
.dynamic 560 560 0 0.0
.got 23472 23472 0 0.0
.init 24 24 0 0.0
.init_array 240 240 0 0.0
.rodata 688440 688440 0 0.0
.text 14802228 14802804 576 0.0
lighting-app debug+rpc+ui (read only) 5209849 5210553 704 0.0
(read/write) 220712 220712 0 0.0
.bss 117248 117248 0 0.0
.data 4880 4880 0 0.0
.data.rel.ro 91048 91048 0 0.0
.dynamic 672 672 0 0.0
.got 5912 5912 0 0.0
.init 27 27 0 0.0
.init_array 928 928 0 0.0
.rodata 329268 329300 32 0.0
.text 4640803 4641475 672 0.0
lock-app debug (read only) 2618181 2618885 704 0.0
(read/write) 117360 117360 0 0.0
.bss 45376 45376 0 0.0
.data 1904 1904 0 0.0
.data.rel.ro 64024 64024 0 0.0
.dynamic 608 608 0 0.0
.got 4592 4592 0 0.0
.init 27 27 0 0.0
.init_array 808 808 0 0.0
.rodata 200456 200488 32 0.0
.text 2252757 2253429 672 0.0
ota-provider-app debug (read only) 2214685 2215389 704 0.0
(read/write) 103952 103952 0 0.0
.bss 44560 44560 0 0.0
.data 2112 2112 0 0.0
.data.rel.ro 52184 52184 0 0.0
.dynamic 608 608 0 0.0
.got 3800 3800 0 0.0
.init 27 27 0 0.0
.init_array 664 664 0 0.0
.rodata 154088 154120 32 0.0
.text 1918261 1918933 672 0.0
ota-requestor-app debug (read only) 2383669 2384389 720 0.0
(read/write) 111744 111744 0 0.0
.bss 47024 47024 0 0.0
.data 2512 2512 0 0.0
.data.rel.ro 57040 57040 0 0.0
.dynamic 608 608 0 0.0
.got 3784 3784 0 0.0
.init 27 27 0 0.0
.init_array 744 744 0 0.0
.rodata 158184 158216 32 0.0
.text 2074277 2074965 688 0.0
shell debug (read only) 2879745 2880465 720 0.0
(read/write) 149320 149320 0 0.0
.bss 59240 59240 0 0.0
.data 1232 1232 0 0.0
.data.rel.ro 83000 83000 0 0.0
.dynamic 608 608 0 0.0
.got 4128 4128 0 0.0
.init 27 27 0 0.0
.init_array 1080 1080 0 0.0
.rodata 201522 201554 32 0.0
.text 2509410 2510098 688 0.0
thermostat-no-ble arm64 (read only) 2611468 2611996 528 0.0
(read/write) 143128 143128 0 0.0
.bss 52376 52376 0 0.0
.data 1736 1736 0 0.0
.data.rel.ro 79392 79392 0 0.0
.dynamic 560 560 0 0.0
.got 5512 5512 0 0.0
.init 24 24 0 0.0
.init_array 416 416 0 0.0
.rodata 129904 129904 0 0.0
.text 2215748 2216276 528 0.0
tv-app debug (read only) 3320481 3321201 720 0.0
(read/write) 261856 261856 0 0.0
.bss 171264 171264 0 0.0
.data 4080 4080 0 0.0
.data.rel.ro 79776 79776 0 0.0
.dynamic 608 608 0 0.0
.got 5000 5000 0 0.0
.init 27 27 0 0.0
.init_array 1080 1080 0 0.0
.rodata 222776 222808 32 0.0
.text 2900706 2901394 688 0.0
tv-casting-app debug (read only) 9314481 9315201 720 0.0
(read/write) 221744 221744 0 0.0
.bss 52096 52096 0 0.0
.data 1744 1744 0 0.0
.data.rel.ro 161296 161296 0 0.0
.dynamic 608 608 0 0.0
.got 4968 4968 0 0.0
.init 27 27 0 0.0
.init_array 1000 1000 0 0.0
.rodata 330932 330964 32 0.0
.text 8548546 8549234 688 0.0
mbed lock-app-release cy8cproto_062_4343w (read only) 6224 6224 0 0.0
(read/write) 2515512 2515576 64 0.0
.bss 216312 216312 0 0.0
.data 5152 5152 0 0.0
.text 1478196 1478260 64 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 (read only) 4 4 0 0.0
(read/write) 1224744 1224776 32 0.0
bss 155370 155370 0 0.0
rodata 139436 139436 0 0.0
text 850868 850888 20 0.0
nrf7002dk_nrf5340_cpuapp (read only) 4 4 0 0.0
(read/write) 1325764 1325780 16 0.0
bss 138696 138696 0 0.0
rodata 134056 134056 0 0.0
text 762300 762312 12 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 (read only) 4 4 0 0.0
(read/write) 1151724 1151740 16 0.0
bss 153489 153489 0 0.0
rodata 111728 111728 0 0.0
text 807416 807428 12 0.0
psoc6 all-clusters cy8ckit_062s2_43012 (read only) 841360 841360 0 0.0
(read/write) 1746300 1746316 16 0.0
.ARM.attributes 46 46 0 0.0
.ARM.exidx 8 8 0 0.0
.bss 189412 189412 0 0.0
.comment 212 212 0 0.0
.copy.table 24 24 0 0.0
.cy_m0p_image 6216 6216 0 0.0
.cy_sharedmem 8 8 0 0.0
.data 2568 2568 0 0.0
.debug_abbrev 1314218 1314082 -136 -0.0
.debug_aranges 150832 150928 96 0.1
.debug_frame 505260 505548 288 0.1
.debug_info 29654330 29666097 11767 0.0
.debug_line 4085970 4086896 926 0.0
.debug_line_str 957 957 0 0.0
.debug_loclists 2338168 2339038 870 0.0
.debug_rnglists 146351 146423 72 0.0
.debug_str 4421901 4425609 3708 0.1
.heap 841360 841360 0 0.0
.noinit 148 148 0 0.0
.ramVectors 736 736 0 0.0
.shstrtab 296 296 0 0.0
.stack_dummy 4096 4096 0 0.0
.strtab 775714 775802 88 0.0
.symtab 488144 488144 0 0.0
.text 1545932 1545948 16 0.0
.zero.table 8 8 0 0.0
text 0 0 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 (read only) 843208 843208 0 0.0
(read/write) 1664668 1664684 16 0.0
.ARM.attributes 46 46 0 0.0
.ARM.exidx 8 8 0 0.0
.bss 187572 187572 0 0.0
.comment 212 212 0 0.0
.copy.table 24 24 0 0.0
.cy_m0p_image 6216 6216 0 0.0
.cy_sharedmem 8 8 0 0.0
.data 2560 2560 0 0.0
.debug_abbrev 1281948 1281812 -136 -0.0
.debug_aranges 148064 148160 96 0.1
.debug_frame 501056 501344 288 0.1
.debug_info 28374373 28386139 11766 0.0
.debug_line 4039122 4040048 926 0.0
.debug_line_str 981 981 0 0.0
.debug_loclists 2296408 2297278 870 0.0
.debug_rnglists 143101 143173 72 0.1
.debug_str 4364072 4367780 3708 0.1
.heap 843208 843208 0 0.0
.noinit 148 148 0 0.0
.ramVectors 736 736 0 0.0
.shstrtab 296 296 0 0.0
.stack_dummy 4096 4096 0 0.0
.strtab 703355 703443 88 0.0
.symtab 461792 461792 0 0.0
.text 1466148 1466164 16 0.0
.zero.table 0 0 0 0.0
8 8 0 0.0
light cy8ckit_062s2_43012 (read only) 849416 849416 0 0.0
(read/write) 1597324 1597340 16 0.0
.ARM.attributes 46 46 0 0.0
.ARM.exidx 8 8 0 0.0
.bss 181532 181532 0 0.0
.comment 212 212 0 0.0
.copy.table 24 24 0 0.0
.cy_m0p_image 6216 6216 0 0.0
.cy_sharedmem 8 8 0 0.0
.data 2392 2392 0 0.0
.debug_abbrev 1118805 1118669 -136 -0.0
.debug_aranges 138424 138520 96 0.1
.debug_frame 465024 465312 288 0.1
.debug_info 23155733 23167263 11530 0.0
.debug_line 3611074 3612000 926 0.0
.debug_line_str 942 942 0 0.0
.debug_loclists 2137509 2138379 870 0.0
.debug_rnglists 133135 133207 72 0.1
.debug_str 4177823 4181531 3708 0.1
.heap 849416 849416 0 0.0
.noinit 148 148 0 0.0
.ramVectors 736 736 0 0.0
.shstrtab 296 296 0 0.0
.stack_dummy 4096 4096 0 0.0
.strtab 626852 626940 88 0.0
.symtab 427328 427328 0 0.0
.text 1405012 1405028 16 0.0
.zero.table 0 0 0 0.0
8 8 0 0.0
lock cy8ckit_062s2_43012 (read only) 821960 821960 0 0.0
(read/write) 1628220 1628236 16 0.0
.ARM.attributes 46 46 0 0.0
.ARM.exidx 8 8 0 0.0
.bss 208988 208988 0 0.0
.comment 212 212 0 0.0
.copy.table 24 24 0 0.0
.cy_m0p_image 6216 6216 0 0.0
.cy_sharedmem 8 8 0 0.0
.data 2392 2392 0 0.0
.debug_abbrev 1101049 1100913 -136 -0.0
.debug_aranges 136520 136616 96 0.1
.debug_frame 458284 458572 288 0.1
.debug_info 22854244 22865773 11529 0.1
.debug_line 3546344 3547270 926 0.0
.debug_line_str 933 933 0 0.0
.debug_loclists 2106089 2106959 870 0.0
.debug_rnglists 130659 130731 72 0.1
.debug_str 4133007 4136715 3708 0.1
.heap 821960 821960 0 0.0
.noinit 148 148 0 0.0
.ramVectors 736 736 0 0.0
.shstrtab 296 296 0 0.0
.stack_dummy 4096 4096 0 0.0
.strtab 597081 597169 88 0.0
.symtab 417616 417616 0 0.0
.text 1408452 1408468 16 0.0
.zero.table 0 0 0 0.0
8 8 0 0.0
qpg lighting-app qpg6105+debug (read/write) 1172304 1172320 16 0.0
.bss 99960 99960 0 0.0
.data 788 788 0 0.0
.text 619144 619160 16 0.0
lock-app qpg6105+debug (read/write) 1130424 1130440 16 0.0
.bss 94816 94816 0 0.0
.data 792 792 0 0.0
.text 577268 577284 16 0.0
telink all-clusters-app tlsr9518adk80d (read only) 4 4 0 0.0
(read/write) 1050600 1050616 16 0.0
bss 98292 98292 0 0.0
text 721456 721470 14 0.0
all-clusters-minimal-app tlsr9518adk80d (read only) 4 4 0 0.0
(read/write) 964972 964988 16 0.0
bss 96288 96288 0 0.0
text 668002 668014 12 0.0
bridge-app tlsr9518adk80d (read only) 4 4 0 0.0
(read/write) 930372 930388 16 0.0
bss 100312 100312 0 0.0
text 643056 643068 12 0.0
contact-sensor-app tlsr9518adk80d (read only) 4 4 0 0.0
(read/write) 862080 862096 16 0.0
bss 89972 89972 0 0.0
text 586228 586242 14 0.0
light-switch-app tlsr9518adk80d (read only) 4 4 0 0.0
(read/write) 890684 890700 16 0.0
bss 90516 90516 0 0.0
text 611688 611704 16 0.0
lighting-app tlsr9518adk80d (read only) 4 4 0 0.0
(read/write) 968928 968944 16 0.0
bss 98652 98652 0 0.0
text 681968 681986 18 0.0
lighting-app-factory-data tlsr9518adk80d (read only) 4 4 0 0.0
(read/write) 980300 980324 24 0.0
bss 102900 102900 0 0.0
text 689488 689506 18 0.0
lighting-app-rpc tlsr9518adk80d (read only) 4 4 0 0.0
(read/write) 1038412 1038428 16 0.0
bss 100208 100208 0 0.0
text 726858 726876 18 0.0
lighting-app-shell tlsr9518adk80d (read only) 4 4 0 0.0
(read/write) 1069776 1069792 16 0.0
bss 111292 111292 0 0.0
text 747004 747024 20 0.0
lock-app tlsr9518adk80d (read only) 4 4 0 0.0
(read/write) 917192 917200 8 0.0
bss 90636 90636 0 0.0
text 614894 614908 14 0.0
ota-requestor-app tlsr9518adk80d (read only) 4 4 0 0.0
(read/write) 884680 884696 16 0.0
bss 91248 91248 0 0.0
text 608070 608086 16 0.0
pump-app tlsr9518adk80d (read only) 4 4 0 0.0
(read/write) 867680 867696 16 0.0
bss 90104 90104 0 0.0
text 591988 592002 14 0.0
pump-controller-app tlsr9518adk80d (read only) 4 4 0 0.0
(read/write) 854700 854716 16 0.0
bss 89904 89904 0 0.0
text 582332 582346 14 0.0
temperature-measurement-app tlsr9518adk80d (read only) 4 4 0 0.0
(read/write) 850856 850864 8 0.0
bss 89812 89812 0 0.0
text 577962 577974 12 0.0
thermostat tlsr9518adk80d (read only) 4 4 0 0.0
(read/write) 896760 896784 24 0.0
bss 90348 90348 0 0.0
text 617376 617394 18 0.0
window-covering tlsr9518adk80d (read only) 4 4 0 0.0
(read/write) 892140 892156 16 0.0
bss 90640 90640 0 0.0
text 612298 612314 16 0.0

@mergify mergify bot merged commit 0d1f9c3 into project-chip:master Jul 6, 2023

namespace chip {
namespace Encoding {
namespace LittleEndian {

namespace {
// These helper methods return void and put the value being read into an

// This helper methods return void and put the value being read into an
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"method returns" and "puts"

memcpy(&result, p, sizeof(result));
result = chip::Encoding::LittleEndian::HostSwap(result);

*dest = static_cast<T>(result);
Copy link
Contributor

@bzbarsky-apple bzbarsky-apple Jul 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Casting to signed of things that are "negative" (i.e. out of range) has implementation-defined behavior until c++20...

This should probably use CastToSigned for the casting; that's what we have that utility for.

{
static_assert(CHAR_BIT == 8, "Our various sizeof checks rely on bytes and octets being the same thing");
static_assert((-1 & 3) == 3, "LittleEndian::BufferReader only works with 2's complement architectures.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the part that's meant to make the static_cast above safe? Or is this something we depend on for the HostSwap bits to work right for negative numbers? Would be good to make it clearer what the actual 2's complement dependency is here.

{
while (size > 0)
{
Put(static_cast<uint8_t>(x & 0xff));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it not be safer to just cast to uint64_t and then EndianPut that? That's obviously the reverse of what we do when reading in the BufferReader, whereas it's not entirely obvious without digging through C++ specs what the bitwise ops here will end up doing.

BufferWriter(uint8_t * buf, size_t len) : EndianBufferWriterBase<BufferWriter>(buf, len) {}
BufferWriter(uint8_t * buf, size_t len) : EndianBufferWriterBase<BufferWriter>(buf, len)
{
static_assert((-1 & 3) == 3, "LittleEndian::BufferWriter only works with 2's complement architectures.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, would be good to document exactly where this dependency comes in. I think if you do cast to unsigned as suggested above there is no such dependency here (because cast to unsigned is well-defined in the C++ standard).

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.

Extend the BufferReader and BufferWriter to handle signed integers
6 participants