-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BLD: use unsigned instead of signed for lengths, avoid build warnings #26759
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
Changes from 3 commits
ac9536d
6f90c8e
d61082b
37b6002
f29bfdc
15c1c5d
fa66545
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -248,7 +248,8 @@ void parser_del(parser_t *self) { | |
} | ||
|
||
static int make_stream_space(parser_t *self, size_t nbytes) { | ||
int64_t i, cap, length; | ||
uint64_t i, cap; | ||
int64_t length; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is length signed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because there weren't any warnings telling us not to. Probably makes more sense unsigned liked the others. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you change this, otherwise lgtm. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing this requires changing a few other places to match. I think its benign, but not obvious. Go for it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep prob should |
||
int status; | ||
void *orig_ptr, *newptr; | ||
|
||
|
@@ -471,7 +472,7 @@ static int end_line(parser_t *self) { | |
return 0; | ||
} | ||
|
||
if (!(self->lines <= (int64_t) self->header_end + 1) && | ||
if (!(self->lines <= self->header_end + 1) && | ||
(self->expected_fields < 0 && fields > ex_fields) && !(self->usecols)) { | ||
// increment file line count | ||
self->file_lines++; | ||
|
@@ -507,7 +508,7 @@ static int end_line(parser_t *self) { | |
} | ||
} else { | ||
// missing trailing delimiters | ||
if ((self->lines >= (int64_t) self->header_end + 1) && | ||
if ((self->lines >= self->header_end + 1) && | ||
fields < ex_fields) { | ||
// might overrun the buffer when closing fields | ||
if (make_stream_space(self, ex_fields - fields) < 0) { | ||
|
@@ -651,7 +652,7 @@ static int parser_buffer_bytes(parser_t *self, size_t nbytes) { | |
stream = self->stream + self->stream_len; \ | ||
slen = self->stream_len; \ | ||
self->state = STATE; \ | ||
if (line_limit > 0 && self->lines == start_lines + (int64_t)line_limit) { \ | ||
if (line_limit > 0 && self->lines == start_lines + (uint64_t)line_limit) { \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason to even have these casts? Fraught with peril to begin with using macros I think this just adds nuances / developer burden There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated to remove these casts. Should we consider getting rid of the macros? That's outside my region of competence. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea might be worth doing so in a separate PR. Here's the cpp take on macros: https://isocpp.org/wiki/faq/inline-functions#inline-vs-macros I could see this one being particular troublesome with our codebase: https://isocpp.org/wiki/faq/misc-technical-issues#macros-with-if I think the main downside to using inline vs macros would be support for pre-C99 compilers, but I don't think that's a problem given age and the fact that we have inline functions elsewhere in the code base |
||
goto linelimit; \ | ||
} | ||
|
||
|
@@ -666,7 +667,7 @@ static int parser_buffer_bytes(parser_t *self, size_t nbytes) { | |
stream = self->stream + self->stream_len; \ | ||
slen = self->stream_len; \ | ||
self->state = STATE; \ | ||
if (line_limit > 0 && self->lines == start_lines + (int64_t)line_limit) { \ | ||
if (line_limit > 0 && self->lines == start_lines + (uint64_t)line_limit) { \ | ||
goto linelimit; \ | ||
} | ||
|
||
|
@@ -737,7 +738,8 @@ int skip_this_line(parser_t *self, int64_t rownum) { | |
|
||
int tokenize_bytes(parser_t *self, | ||
size_t line_limit, int64_t start_lines) { | ||
int64_t i, slen; | ||
int64_t i; | ||
uint64_t slen; | ||
int should_skip; | ||
char c; | ||
char *stream; | ||
|
@@ -1203,7 +1205,8 @@ static int parser_handle_eof(parser_t *self) { | |
} | ||
|
||
int parser_consume_rows(parser_t *self, size_t nrows) { | ||
int64_t i, offset, word_deletions, char_count; | ||
int64_t offset, word_deletions; | ||
uint64_t char_count, i; | ||
|
||
if (nrows > self->lines) { | ||
nrows = self->lines; | ||
|
@@ -1229,6 +1232,8 @@ int parser_consume_rows(parser_t *self, size_t nrows) { | |
self->stream_len -= char_count; | ||
|
||
/* move token metadata */ | ||
// Note: We should always have words_len < word_deletions, so this | ||
// subtraction will remain appropriately-typed. | ||
for (i = 0; i < self->words_len - word_deletions; ++i) { | ||
offset = i + word_deletions; | ||
|
||
|
@@ -1242,6 +1247,8 @@ int parser_consume_rows(parser_t *self, size_t nrows) { | |
self->word_start -= char_count; | ||
|
||
/* move line metadata */ | ||
// Note: We should always have self->lines - nrows + 1 >= 0, so this | ||
// subtraction will remain appropriately-typed. | ||
for (i = 0; i < self->lines - nrows + 1; ++i) { | ||
offset = i + nrows; | ||
self->line_start[i] = self->line_start[offset] - word_deletions; | ||
|
@@ -1265,7 +1272,7 @@ int parser_trim_buffers(parser_t *self) { | |
size_t new_cap; | ||
void *newptr; | ||
|
||
int64_t i; | ||
uint64_t i; | ||
|
||
/** | ||
* Before we free up space and trim, we should | ||
|
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.
Does leaving this as is not introduce any new build warnings? Looks like assignments and comparisons are done with unsigned types within this function