mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Jan Engelhardt <jengelh@computergmbh.de>
Cc: Pavel Machek <pavel@ucw.cz>, Julia Lawall <julia@diku.dk>,
	tglx@linutronix.de, viro@ftp.linux.org.uk,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 1/3] arch/x86: Use offsetof
Date: Wed, 26 Dec 2007 17:49:55 -0800	[thread overview]
Message-ID: <477304C3.9060409@zytor.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0712270243370.32714@fbirervta.pbzchgretzou.qr>

Jan Engelhardt wrote:
> On Dec 26 2007 17:01, H. Peter Anvin wrote:
>>>> @@ -215,7 +215,9 @@ asmlinkage int sys_vm86old(struct pt_reg
>>>>   ret = -EFAULT;
>>>>   if (tmp)
>>>> 		goto out;
>>>> -	memset(&info.vm86plus, 0, (int)&info.regs32 - (int)&info.vm86plus);
>>>> +	memset(&info.vm86plus, 0,
>>>> +	       offsetof(struct kernel_vm86_struct, regs32) -
>>>> +	       offsetof(struct kernel_vm86_struct, vm86plus));
>>> I do not think this makes it more readable... (int) -> (char *) would
>>> make it portable and readable, AFAICT.
>>>         Pavel
>> The right way to do it is:
>>
>> 	memset(&info.vm86plus, 0, sizeof info.vm86plus);
> 
> Either way, downcasting a pointer to (int) is dangerous,
> even if this one occurrence happens to be in 32-bit-only code.

Actually, it would be safe (although stupid) in this case since the 
difference would still be 32 bits or less.

Doesn't make it any less wrong.

	-hpa

      reply	other threads:[~2007-12-27  1:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-26 16:13 Julia Lawall
2007-12-26 19:47 ` Pavel Machek
2007-12-27  1:01   ` H. Peter Anvin
2007-12-27  1:17     ` Al Viro
2007-12-27  1:21       ` H. Peter Anvin
2007-12-30 13:54         ` Ingo Molnar
2007-12-27  1:44     ` Jan Engelhardt
2007-12-27  1:49       ` H. Peter Anvin [this message]

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=477304C3.9060409@zytor.com \
    --to=hpa@zytor.com \
    --cc=jengelh@computergmbh.de \
    --cc=julia@diku.dk \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=tglx@linutronix.de \
    --cc=viro@ftp.linux.org.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®