All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Tokarev <mjt@tls.msk.ru>
To: "Neil Brown (neilb@suse.de)" <neilb@suse.de>,
	"linux-raid@vger.kernel.org" <linux-raid@vger.kernel.org>,
	Luca Berra <bluca@comedia.it>
Subject: Re: [mdadm PATCH 1/3] fix gcc warnings about strict-aliasing rules
Date: Tue, 02 Mar 2010 10:40:21 +0300	[thread overview]
Message-ID: <4B8CC0E5.4040004@msgid.tls.msk.ru> (raw)
In-Reply-To: <20100227135338.GB24207@maude.comedia.it>

Luca Berra wrong:
> Signed-off-by: Luca Berra <bluca@comedia.it>
> ---
>   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;
>           }


  reply	other threads:[~2010-03-02  7:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-27 10:14 [mdadm PATCH 0/3] *** fix gcc warnings *** Luca Berra
2010-02-27 13:53 ` [mdadm PATCH 2/3] fix compiler warnings Luca Berra
2010-02-27 13:53 ` [mdadm PATCH 1/3] fix gcc warnings about strict-aliasing rules Luca Berra
2010-03-02  7:40   ` Michael Tokarev [this message]
2010-03-02  7:48     ` Luca Berra
2010-03-03  4:19       ` Neil Brown
2010-02-27 13:53 ` [mdadm PATCH 3/3] workaround unused results Luca Berra
2010-03-02 23:59 ` [mdadm PATCH 0/3] *** fix gcc warnings *** Neil Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B8CC0E5.4040004@msgid.tls.msk.ru \
    --to=mjt@tls.msk.ru \
    --cc=bluca@comedia.it \
    --cc=linux-raid@vger.kernel.org \
    --cc=neilb@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.