Skip to content

Conversation

@promag
Copy link
Contributor

@promag promag commented May 10, 2021

It was casting from const unsigned char* to char*.

Copy link
Contributor

@vasild vasild left a comment

Choose a reason for hiding this comment

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

ACK c4928aa

Copy link
Contributor

@theStack theStack left a comment

Choose a reason for hiding this comment

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

ACK c4928aa

while (scriptCode.GetOp(it, opcode)) {
if (opcode == OP_CODESEPARATOR) {
s.write((char*)&itBegin[0], it-itBegin-1);
s.write(reinterpret_cast<const char*>(&itBegin[0]), it-itBegin-1);
Copy link
Member

Choose a reason for hiding this comment

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

There is a safe helper CharCast and UCharCast, that can be used.

Though, I have a patch (Bundle 2/2 of #21969) to remove char completely.

Copy link
Member

Choose a reason for hiding this comment

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

See #22167

Copy link
Member

Choose a reason for hiding this comment

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

See #22167

See #23438 😅

@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 6, 2021

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #22167 (refactor: Remove char serialize by MarcoFalke)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@promag
Copy link
Contributor Author

promag commented Aug 29, 2021

Closing in favour of #22167.

@promag promag closed this Aug 29, 2021
@promag promag deleted the 2021-05-fix-cast branch August 29, 2021 18:14
laanwj added a commit to bitcoin-core/gui that referenced this pull request Jan 27, 2022
…alize

fa5d2e6 Remove unused char serialize (MarcoFalke)
fa24493 Use spans of std::byte in serialize (MarcoFalke)
fa65bbf span: Add BytePtr helper (MarcoFalke)

Pull request description:

  This changes the serialize code (`.read()` and `.write()` functions) to take a `Span` instead of a pointer and size. This is a breaking change for the serialize interface, so at no additional cost we can also switch to `std::byte` (instead of using `char`).

  The benefits of using `Span`:
  * Less verbose and less fragile code when passing an already existing `Span`(-like) object to or from serialization

  The benefits of using `std::byte`:
  * `std::byte` can't accidentally be mistaken for an integer

  The goal here is to only change serialize to use spans of `std::byte`. If needed, `AsBytes`,  `MakeUCharSpan`, ... can be used (temporarily) to pass spans of the right type.

  Other changes that are included here:

  * [#22167](bitcoin/bitcoin#22167) (refactor: Remove char serialize by MarcoFalke)
  * [#21906](bitcoin/bitcoin#21906) (Preserve const in cast on CTransactionSignatureSerializer by promag)

ACKs for top commit:
  laanwj:
    Concept and code review ACK fa5d2e6
  sipa:
    re-utACK fa5d2e6

Tree-SHA512: 08ee9eced5fb777cedae593b11e33660bed9a3e1711a7451a87b835089a96c99ce0632918bb4666a4e859c4d020f88fb50f2dd734216b0c3d1a9a704967ece6f
@bitcoin bitcoin locked and limited conversation to collaborators Nov 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants