On Wed, 16 Aug 2023 13:01:53 GMT, Christian Hagedorn <chaged...@openjdk.org> wrote:
>> This code: >> >> uint64_t isa; >> if (!_reader.read_uleb128(&isa, 4)) { >> // isa register is 4 bytes wide. >> return false; >> } >> _state->_isa = isa; // only save 4 bytes >> >> returns 64 bit of information into isa from this read_uleb128 call, even >> though it passes 4. > > I've quickly skimmed through the usages of `read_uleb128`. We only seem to be > reading either directly into a proper `uint64_t` or we are reading 4 bytes > (i.e. `check_size = 4`). In the latter case, we could either: > - add a `static_cast` for the read value when storing it into a 32 bit field, > as for example for `isa` above (i.e. `_state->_isa = > static_cast<uint32_t>(isa)`). > - provide a 32 bit `read_uleb128()` version that hides the casting. > > I guess it's fine to just go with a `static_cast` when storing to a field for > the few cases we have. Thanks Christian. I'll revert to use the static cast. One of the cases has a comment why. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15233#discussion_r1295937366