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

Don't accept strings with '\0' for C operations. #2601

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

floitsch
Copy link
Member

No description provided.

@floitsch floitsch requested a review from kasperl October 24, 2024 12:58
@cla-bot cla-bot bot added the cla-signed The contributors have signed the CLA label Oct 24, 2024
ARGS(Blob, message, bool, add_newline);
auto bytes = message.address();
for (int i = 0; i < message.length(); i++) {
putchar(bytes[i]);
Copy link
Member

Choose a reason for hiding this comment

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

How is this stderr? This looks like a pretty significant regression.

I'd take something like my suggestion above and maybe put it in a static helper function parameterized with the stream.

Also, consider making both member variables of Blob const like:

 private:
  const uint8* const address_;
  const word length_;

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch...
I will update the blob fields in a separate PR.

src/primitive_core.cc Outdated Show resolved Hide resolved
floitsch and others added 2 commits October 25, 2024 09:35
Co-authored-by: Kasper Lund <kasper@toit.io>
@floitsch
Copy link
Member Author

Good feedback.

fprintf(stderr, "%s%s", message, add_newline ? "\n" : "");
fflush(stderr);
ARGS(Blob, message, bool, add_newline);
write_to(stderr, message.address(), message.length());
Copy link
Member

Choose a reason for hiding this comment

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

What happened to the newline?

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The contributors have signed the CLA
Development

Successfully merging this pull request may close these issues.

2 participants