-
Notifications
You must be signed in to change notification settings - Fork 119
[housekeeping] Integer-related compiler warnings #159
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 |
|---|---|---|
|
|
@@ -341,7 +341,7 @@ static int firehose_try_configure(struct qdl_device *qdl, bool skip_storage_init | |
| size_t size = 0; | ||
| void *buf; | ||
| int ret; | ||
| int i; | ||
| unsigned int i; | ||
|
|
||
| ret = firehose_send_configure(qdl, qdl->max_payload_size, skip_storage_init, | ||
| storage, &size); | ||
|
|
@@ -454,6 +454,7 @@ static int firehose_program(struct qdl_device *qdl, struct program *program, int | |
| int left; | ||
| int ret; | ||
| int n; | ||
| size_t i; | ||
| uint32_t fill_value; | ||
|
|
||
| /* | ||
|
|
@@ -526,8 +527,8 @@ static int firehose_program(struct qdl_device *qdl, struct program *program, int | |
| break; | ||
| case CHUNK_TYPE_FILL: | ||
| fill_value = program->sparse_fill_value; | ||
| for (n = 0; n < qdl->max_payload_size; n += sizeof(fill_value)) | ||
| memcpy(buf + n, &fill_value, sizeof(fill_value)); | ||
| for (i = 0; i < qdl->max_payload_size; i += sizeof(fill_value)) | ||
| memcpy(buf + i, &fill_value, sizeof(fill_value)); | ||
| break; | ||
| default: | ||
| ux_err("[SPARSE] invalid chunk type\n"); | ||
|
|
@@ -555,7 +556,7 @@ static int firehose_program(struct qdl_device *qdl, struct program *program, int | |
| goto out; | ||
| } | ||
|
|
||
| if (n < qdl->max_payload_size) | ||
| if ((size_t)n < qdl->max_payload_size) | ||
| memset(buf + n, 0, qdl->max_payload_size - n); | ||
| } | ||
|
|
||
|
|
@@ -587,7 +588,7 @@ static int firehose_program(struct qdl_device *qdl, struct program *program, int | |
| goto out; | ||
| } | ||
|
|
||
| if (n != chunk_size * sector_size) { | ||
| if ((size_t)n != chunk_size * sector_size) { | ||
| ux_err("USB write truncated\n"); | ||
| ret = -1; | ||
| goto out; | ||
|
|
@@ -686,20 +687,20 @@ static int firehose_issue_read(struct qdl_device *qdl, struct read_op *read_op, | |
| continue; | ||
| } else if (expect_empty) { | ||
| err(1, "expected empty transfer but received non-empty transfer during read"); | ||
| } else if (n != chunk_size * sector_size) { | ||
| } else if ((size_t)n != chunk_size * sector_size) { | ||
|
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. the check of |
||
| err(1, "failed to read full sector"); | ||
| } | ||
|
|
||
| if (out_buf) { | ||
| if (n > out_len - out_offset) | ||
| if ((size_t)n > out_len - out_offset) | ||
|
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. the check of |
||
| n = out_len - out_offset; | ||
|
|
||
| memcpy(out_buf + out_offset, buf, n); | ||
| out_offset += n; | ||
| } else { | ||
| n = write(fd, buf, n); | ||
|
|
||
| if (n != chunk_size * sector_size) { | ||
| if (n < 0 || (size_t)n != chunk_size * sector_size) { | ||
| err(1, "failed to write"); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -180,7 +180,7 @@ static void sahara_read(struct qdl_device *qdl, struct sahara_pkt *pkt, | |
| } | ||
|
|
||
| ret = qdl_write(qdl, image->ptr + offset, len, SAHARA_CMD_TIMEOUT_MS); | ||
| if (ret != len) | ||
| if (ret < 0 || ((size_t)ret != len)) | ||
| err(1, "failed to write %zu bytes to sahara", len); | ||
| } | ||
|
|
||
|
|
@@ -220,7 +220,7 @@ static void sahara_read64(struct qdl_device *qdl, struct sahara_pkt *pkt, | |
| } | ||
|
|
||
| ret = qdl_write(qdl, image->ptr + offset, len, SAHARA_CMD_TIMEOUT_MS); | ||
| if (ret != len) | ||
| if (ret < 0 || ((size_t)ret != len)) | ||
| err(1, "failed to write %zu bytes to sahara", len); | ||
| } | ||
|
|
||
|
|
@@ -302,7 +302,7 @@ static ssize_t sahara_debug64_one(struct qdl_device *qdl, | |
| goto out; | ||
| } | ||
|
|
||
| while (buf_offset < n) { | ||
| while (buf_offset < (size_t)n) { | ||
| written = write(fd, buf + buf_offset, n - buf_offset); | ||
| if (written <= 0) { | ||
| warn("failed to write ramdump chunk to \"%s\"", region.filename); | ||
|
|
@@ -373,7 +373,7 @@ static void sahara_debug64(struct qdl_device *qdl, struct sahara_pkt *pkt, | |
| struct sahara_debug_region64 *table; | ||
| struct sahara_pkt read_req; | ||
| ssize_t n; | ||
| int i; | ||
| size_t i; | ||
|
|
||
| assert(pkt->length == SAHARA_MEM_DEBUG64_LENGTH); | ||
|
|
||
|
|
@@ -455,7 +455,7 @@ int sahara_run(struct qdl_device *qdl, const struct sahara_image *images, | |
| } | ||
|
|
||
| pkt = (struct sahara_pkt *)buf; | ||
| if (n != pkt->length) { | ||
| if ((uint32_t)n != pkt->length) { | ||
|
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. the check of |
||
| ux_err("request length not matching received request\n"); | ||
| return -EINVAL; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
the check of
n < 0is above, so safe to cast here