Repository navigation
lib/dbmibase: Fix "Implicit conversion loses integer precision" warnings #8019
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
base: main
Are you sure you want to change the base?
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 | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -69,14 +69,14 @@ dbDirent *db_dirent(const char *dirname, int *n) | |||||||||||||||
| max = 0; | ||||||||||||||||
| while ((entry = readdir(dp))) { | ||||||||||||||||
| count++; | ||||||||||||||||
| len = strlen(entry->d_name); | ||||||||||||||||
| len = (int)strlen(entry->d_name); | ||||||||||||||||
| if (len > max) | ||||||||||||||||
| max = len; | ||||||||||||||||
| } | ||||||||||||||||
| rewinddir(dp); | ||||||||||||||||
|
|
||||||||||||||||
| size_t path_len = strlen(dirname) + max + 2; // extra 2 for / and NULL | ||||||||||||||||
| path = db_malloc(path_len); | ||||||||||||||||
| path = db_malloc((int)path_len); | ||||||||||||||||
|
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.
Suggested change
|
||||||||||||||||
| if (path == NULL) { | ||||||||||||||||
| closedir(dp); | ||||||||||||||||
| return (dbDirent *)NULL; | ||||||||||||||||
|
|
||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -90,7 +90,7 @@ static int set_string(dbString *x, char *s, int copy) | |||||||||||||
| copy = 1; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| len = strlen(s) + 1; | ||||||||||||||
| len = (int)strlen(s) + 1; | ||||||||||||||
|
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. With len = strlen(s) + 1;
if (copy) {
if (len > INT_MAX) {
db_memory_error();
return DB_MEMORY_ERR;
}
stat = db_enlarge_string(x, (int)len); |
||||||||||||||
|
|
||||||||||||||
| if (copy) { | ||||||||||||||
| stat = db_enlarge_string(x, len); | ||||||||||||||
|
|
@@ -202,14 +202,14 @@ dbString *db_alloc_string_array(int count) | |||||||||||||
| */ | ||||||||||||||
| int db_append_string(dbString *x, const char *s) | ||||||||||||||
| { | ||||||||||||||
| int len; | ||||||||||||||
| size_t len; | ||||||||||||||
| int stat; | ||||||||||||||
|
|
||||||||||||||
| if (!db_get_string(x)) | ||||||||||||||
| return db_set_string(x, s); | ||||||||||||||
|
|
||||||||||||||
| len = strlen(db_get_string(x)) + strlen(s) + 1; | ||||||||||||||
| stat = db_enlarge_string(x, len); | ||||||||||||||
| stat = db_enlarge_string(x, (int)len); | ||||||||||||||
|
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.
Suggested change
|
||||||||||||||
| if (stat != DB_OK) | ||||||||||||||
| return stat; | ||||||||||||||
| strcat(db_get_string(x), s); | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,7 +85,7 @@ int db__send_string(dbString *x) | |
| { | ||
| int stat = DB_OK; | ||
| const char *s = db_get_string(x); | ||
| int len = s ? strlen(s) + 1 : 1; | ||
| int len = s ? (int)strlen(s) + 1 : 1; | ||
|
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. The sent length stays size_t size = s ? strlen(s) + 1 : 1;
int len;
if (size > INT_MAX) {
db_protocol_error();
return DB_PROTOCOL_ERR;
}
len = (int)size; |
||
|
|
||
| if (!s) | ||
| s = ""; /* don't send a NULL string */ | ||
|
|
||
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.