ACK: [PATCH] lib: fwts_log: shift UL values rather than signed int values
ivanhu
ivan.hu at canonical.com
Wed Nov 14 02:25:23 UTC 2018
On 11/13/18 8:46 PM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Shifting signed int values can result in undefined behaviour if the shift
> is 31 places. Make all shifted values of 1 unsigned long to ensure there
> is no undefined behaviour. Cleans up clang error messages such as:
>
> (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
> src/lib/src/fwts_log.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/lib/src/fwts_log.c b/src/lib/src/fwts_log.c
> index 5a7151ec..9d3b3c65 100644
> --- a/src/lib/src/fwts_log.c
> +++ b/src/lib/src/fwts_log.c
> @@ -578,7 +578,7 @@ char *fwts_log_get_filenames(const char *filename, const fwts_log_type type)
> size_t len = 0;
>
> for (i = 0; i < 32; i++) {
> - fwts_log_type mask = 1 << i;
> + fwts_log_type mask = 1UL << i;
> if (type & mask) {
> if ((tmp = fwts_log_filename(filename, mask)) == NULL) {
> free(filenames);
> @@ -642,7 +642,7 @@ fwts_log *fwts_log_open(
> * the logging
> */
> for (i = 0; i < 32; i++) {
> - fwts_log_type mask = 1 << i; /* The log type for this iteration */
> + fwts_log_type mask = 1UL << i; /* The log type for this iteration */
>
> /* If set then go and open up a log for this log type */
> if (type & mask) {
Acked-by: Ivan Hu <ivan.hu at canonical.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ubuntu.com/archives/fwts-devel/attachments/20181114/b09bc90b/attachment.sig>
More information about the fwts-devel
mailing list