Re: [mdadm PATCH 1/3] fix gcc warnings about strict-aliasing rules

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Luca Berra wrong:
> Signed-off-by: Luca Berra <bluca@xxxxxxxxxx>
> ---
>   util.c |    4 ++--
>   1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/util.c b/util.c
> index 68f048d..1def2a0 100644
> --- a/util.c
> +++ b/util.c
> @@ -1160,7 +1160,7 @@ static int get_gpt_last_partition_end(int fd,
> unsigned long long *endofpart)
>       entry_size = __le32_to_cpu(buf[GPT_ENTRY_SIZE_OFFSET]);
>         /* Check GPT signature*/
> -    if (*((__u64*)buf) != GPT_SIGNATURE_MAGIC)
> +    if ((__u64)buf[0] != GPT_SIGNATURE_MAGIC)

This looks wrong.

buf is an array of unsigned char.  Before, we converted the
whole thing to a pointer to u64 and took the first element
at that address, u64 size.  Now after the change, we take
first _byte_ of the array, convert it to u64 (adding leading
zeros) and compare with a large number.

Does it actually work?

>           return -1;
>         /* sanity checks */
> @@ -1178,7 +1178,7 @@ static int get_gpt_last_partition_end(int fd,
> unsigned long long *endofpart)
>           /* is this valid partition? */
>           if (memcmp(part->type_guid, empty_gpt_entry, 16) != 0) {
>               /* check the last lba for the current partition */
> -            curr_part_end = __le64_to_cpu(*(__u64*)part->ending_lba);
> +            curr_part_end = __le64_to_cpu((__u64)part->ending_lba[0]);

And the same thing here as well.

Thanks!

/mjt

>               if (curr_part_end > *endofpart)
>                   *endofpart = curr_part_end;
>           }

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux