Re: [PATCH 1/3] arch/x86: Use offsetof

From: Jan Engelhardt
Date: Wed Dec 26 2007 - 20:44:51 EST



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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/