mgmt: mcumgr: fs_mgmt: hash/checksum: Fix size errors

There are warnings when building fs_mgmt with hash/checksum
functionality enabled due to array access and a wrong variable type
being used.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
This commit is contained in:
Jamie McCrae 2022-09-16 09:06:39 +01:00 committed by Fabio Baltieri
parent 05b17356e2
commit 52e2493842
2 changed files with 7 additions and 1 deletions

View file

@ -26,7 +26,7 @@ extern "C" {
* @return 0 on success, negative error code on failure.
*/
typedef int (*hash_checksum_mgmt_handler_fn)(struct fs_file_t *file,
uint8_t *output, uint32_t *out_len,
uint8_t *output, size_t *out_len,
size_t len);
/**

View file

@ -420,12 +420,18 @@ fs_mgmt_file_hash_checksum(struct mgmt_ctxt *ctxt)
if (group->output_size == sizeof(uint8_t)) {
tmp_val = (uint64_t)(*(uint8_t *)output);
#if FS_MGMT_CHECKSUM_HASH_LARGEST_OUTPUT_SIZE > 1
} else if (group->output_size == sizeof(uint16_t)) {
tmp_val = (uint64_t)(*(uint16_t *)output);
#if FS_MGMT_CHECKSUM_HASH_LARGEST_OUTPUT_SIZE > 2
} else if (group->output_size == sizeof(uint32_t)) {
tmp_val = (uint64_t)(*(uint32_t *)output);
#if FS_MGMT_CHECKSUM_HASH_LARGEST_OUTPUT_SIZE > 4
} else if (group->output_size == sizeof(uint64_t)) {
tmp_val = (*(uint64_t *)output);
#endif
#endif
#endif
} else {
LOG_ERR("Unable to handle numerical checksum size %u",
group->output_size);