-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Remove unnecessary casts in tokenizer.c #37792
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
Conversation
pandas/_libs/src/parser/tokenizer.c
Outdated
} | ||
} else { | ||
*error = -1; | ||
if (q != NULL) { | ||
// p and pc are different len due to tsep removal. Can't report | ||
// how much it has consumed of p. Just rewind to beginning. | ||
*q = (char *)p; | ||
*q = (char *)p; // TODO: this could be undefined behavior |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably just need better types here. I don't think q
is ever actually mutated, but if it is this would be undefined behavior as the contents of p
are qualified as const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems fine, do we have lesser warnings now?
@@ -600,7 +599,7 @@ static int parser_buffer_bytes(parser_t *self, size_t nbytes) { | |||
TRACE(("PUSH_CHAR: ERROR!!! slen(%d) >= stream_cap(%d)\n", slen, \ | |||
self->stream_cap)) \ | |||
int64_t bufsize = 100; \ | |||
self->error_msg = (char *)malloc(bufsize); \ | |||
self->error_msg = malloc(bufsize); \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra whitespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is by design to keep all of the slashes right aligned
There are no warnings now because the casts would suppress them, but this fixes a bug when the number of rows in a CSV file exceeds the size of a long long |
thanks |
Some of these are visual clutter, some are actual bugs though in unlikely cases (see the format specifiers)
https://stackoverflow.com/questions/605845/do-i-cast-the-result-of-malloc