-
Notifications
You must be signed in to change notification settings - Fork 1.7k
util: fix -Wshorten-64-to-32 warnings #12481
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 all commits
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 |
|---|---|---|
|
|
@@ -117,20 +117,20 @@ static fpos_t SeekFn(void *handler, fpos_t offset, int whence) | |
| */ | ||
| static int ReadFn(void *handler, char *buf, int size) | ||
| { | ||
| size_t count = 0; | ||
| int count = 0; | ||
| SCFmem *mem = handler; | ||
| size_t available = mem->size - mem->pos; | ||
| int is_eof = 0; | ||
|
|
||
| if (size < 0) return - 1; | ||
|
|
||
| if ((size_t)size > available) { | ||
| size = available; | ||
| if (size > (int)available) { | ||
catenacyber marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| size = (int)available; | ||
| } else { | ||
| is_eof = 1; | ||
| } | ||
|
|
||
| while (count < (size_t)size) | ||
| while (count < size) | ||
| buf[count++] = mem->buffer[mem->pos++]; | ||
|
|
||
| if (is_eof == 1) | ||
|
|
@@ -148,16 +148,16 @@ static int ReadFn(void *handler, char *buf, int size) | |
| */ | ||
| static int WriteFn(void *handler, const char *buf, int size) | ||
| { | ||
| size_t count = 0; | ||
| int count = 0; | ||
| SCFmem *mem = handler; | ||
| size_t available = mem->size - mem->pos; | ||
|
Member
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. where is checked that his result fits an
Contributor
Author
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.
Member
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. it looks very hacky. size_t actually does look like the correct type here, and the change should probably that the function arg |
||
|
|
||
| if (size < 0) return - 1; | ||
|
|
||
| if ((size_t)size > available) | ||
| size = available; | ||
| if (size > (int)available) | ||
| size = (int)available; | ||
|
|
||
| while (count < (size_t)size) | ||
| while (count < size) | ||
| mem->buffer[mem->pos++] = buf[count++]; | ||
|
|
||
| return count; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.