Thus the read(...) and write(...) methods of all stream classes now have identical parameter lists. This will bring these classes one step closer to a common interface.
replace int with size_t in stream methods #4706
pull kdomanski wants to merge 1 commits into bitcoin:master from kdomanski:2014_08_stream_size_t changing 1 files +4 −6-
kdomanski commented at 9:31 PM on August 15, 2014: contributor
-
laanwj commented at 7:42 AM on August 18, 2014: member
Looks good to me, although before merging it must be verified that we're not passing in numbers that are potentially negative anywhere. After this change that would result in an integer overflow or undefined behavior.
-
kdomanski commented at 6:19 PM on August 18, 2014: contributor
@laanwj I took a look and it seems that these methods are only ever used by various Serialize/Unserialize functions and methods. In some of them, the size parameter is acquired through sizeof operator. In other, the size is calculated in a trivial manner, or at least trivial anough to warrant usage of size_t in every other streamlike object's T.write(..) or T.read(..) method.
-
8695a39350
replace int with size_t in stream methods
Thus the read(...) and write(...) methods of all stream classes now have identical parameter lists. This will bring these classes one step closer to a common interface.
-
laanwj commented at 6:42 PM on August 18, 2014: member
Ok thanks for checking.
I'd prefer not use anything with virtual methods, though. Serialization is performance-critical, and having vtables (which are essentially function pointers) are known to make it easier to write exploits so may be worse from a security viewpoint.
-
sipa commented at 6:46 PM on August 18, 2014: member
Yes, I really want to avoid introducing runtime lookups for serialization. The effective amount of code is huge, and it only really works so well because the compiler can optimize pretty much everything away.
Of course, I haven't benchmarked, and numbers may convince me otherwise.
- kdomanski closed this on Aug 18, 2014
- kdomanski reopened this on Aug 18, 2014
-
sipa commented at 9:49 PM on August 18, 2014: member
Untested ACK
-
BitcoinPullTester commented at 10:31 PM on August 18, 2014: none
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p4706_8695a39350cd9fd403c1bb1ca725535b591f82f9/ for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.
-
jgarzik commented at 2:00 AM on August 19, 2014: contributor
ut ACK
- laanwj added the label Improvement on Aug 19, 2014
-
laanwj commented at 6:50 AM on August 21, 2014: member
tested ACK
- laanwj merged this on Aug 21, 2014
- laanwj closed this on Aug 21, 2014
- laanwj referenced this in commit 56953925db on Aug 21, 2014
- kdomanski deleted the branch on Aug 21, 2014
- MarcoFalke locked this on Sep 8, 2021