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

Buffer comparison cast fix #89

Merged
merged 1 commit into from
Nov 5, 2024
Merged

Buffer comparison cast fix #89

merged 1 commit into from
Nov 5, 2024

Conversation

JensOgorek
Copy link
Contributor

@JensOgorek JensOgorek commented Nov 5, 2024

This is a fix for #86.
Size_t is unsigned and pos can be negative. After the change, I could not reproduce the problem.

Also, I increased the size of the patter queue to 100, like in the main queue with uart 0. I ran into a full queue multiple times.
W (3232) uart: Fail to enqueue pattern position, pattern queue is full.

@JensOgorek JensOgorek added the bug Something isn't working label Nov 5, 2024
@JensOgorek JensOgorek linked an issue Nov 5, 2024 that may be closed by this pull request
Copy link
Collaborator

@falkoschindler falkoschindler left a comment

Choose a reason for hiding this comment

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

Ok, but there's also

if (num_chars > buffer_len - 1)

in string_utils.cpp and multiple

buffer_len - pos

in expressions.cpp. I wonder if we need casting in these lines as well if mixing int and size_t is an issue. 🤔

@JensOgorek JensOgorek added this to the 0.6.0 milestone Nov 5, 2024
@JensOgorek
Copy link
Contributor Author

The main issue is the comparison of int with size_t, when the int is negative. But it would be good practice not to mix unsigned and signed without casting

Copy link
Collaborator

@falkoschindler falkoschindler left a comment

Choose a reason for hiding this comment

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

I see. Then the comparison addressed in this PR should be the only problematic case (as far as I can see). 👍

@JensOgorek
Copy link
Contributor Author

JensOgorek commented Nov 5, 2024

Right now, yes. But maybe we should have an eye open for this and change it sometime in the future.

@JensOgorek JensOgorek merged commit 88837e7 into main Nov 5, 2024
@JensOgorek JensOgorek deleted the fix_startup_buffer_error branch November 5, 2024 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error while loading startup script: buffer too small.
2 participants