diff options
Diffstat (limited to 'lib/avb')
-rw-r--r-- | lib/avb/fsl/utils.c | 23 | ||||
-rw-r--r-- | lib/avb/fsl/utils.h | 6 |
2 files changed, 20 insertions, 9 deletions
diff --git a/lib/avb/fsl/utils.c b/lib/avb/fsl/utils.c index ec50c70..458ccea 100644 --- a/lib/avb/fsl/utils.c +++ b/lib/avb/fsl/utils.c @@ -1,4 +1,9 @@ - +/* ++ * Copyright (C) 2016 Freescale Semiconductor, Inc. ++ * Copyright 2017 NXP ++ * ++ * SPDX-License-Identifier: GPL-2.0+ ++ */ #include <common.h> #include <stdlib.h> @@ -14,23 +19,23 @@ int get_margin_pos(uint64_t part_start, uint64_t part_end, unsigned long blksz, return -1; if (offset < 0) { - margin->blk_start = (offset + 1) / blksz + part_end; - margin->start = (off = offset % blksz) == 0 ? 0 : blksz + off; // offset == -1 means the last byte?, or start need -1 + margin->blk_start = (offset + 1) / (uint64_t)blksz + part_end; + margin->start = (off = offset % (uint64_t)blksz) == 0 ? 0 : blksz + off; // offset == -1 means the last byte?, or start need -1 if (offset + num_bytes - 1 >= 0) { if (!allow_partial) return -1; margin->blk_end = part_end; margin->end = blksz - 1; } else { - margin->blk_end = (num_bytes + offset) / blksz + part_end; // which blk the last byte is in - margin->end = (off = (num_bytes + offset - 1) % blksz) == 0 ? + margin->blk_end = (num_bytes + offset) / (uint64_t)blksz + part_end; // which blk the last byte is in + margin->end = (off = (num_bytes + offset - 1) % (uint64_t)blksz) == 0 ? 0 : blksz + off; // last byte } } else { - margin->blk_start = offset / blksz + part_start; - margin->start = offset % blksz; - margin->blk_end = (offset + num_bytes - 1) / blksz + part_start ; - margin->end = (offset + num_bytes - 1) % blksz; + margin->blk_start = offset / (uint64_t)blksz + part_start; + margin->start = offset % (uint64_t)blksz; + margin->blk_end = (offset + num_bytes - 1) / (uint64_t)blksz + part_start ; + margin->end = (offset + num_bytes - 1) % (uint64_t)blksz; if (margin->blk_end > part_end) { if (!allow_partial) return -1; diff --git a/lib/avb/fsl/utils.h b/lib/avb/fsl/utils.h index 6fe72f5..8100e77 100644 --- a/lib/avb/fsl/utils.h +++ b/lib/avb/fsl/utils.h @@ -1,3 +1,9 @@ +/* + * Copyright (C) 2016 Freescale Semiconductor, Inc. + * Copyright 2017 NXP + * + * SPDX-License-Identifier: GPL-2.0+ + */ #ifndef __UTILS_H__ #define __UTILS_H__ |