On Tue, Aug 31, 2010 at 11:17:05PM +0200, Dimitry Andric wrote:
> Indeed, any subtraction is only in "u_char *p = (u_char *)PTOV(0);". If
> you prefer, I will revert to the old expression, or maybe we could use
> John's suggestion of:
>
> return (*(u_char *)PTOV(0x401) * 128 * 1024 +
>
On 2010-08-31 22:33, Kostik Belousov wrote:
> Going into this mode, can you cite the spell that makes the NULL to
> not point to anything ? There is 6.3.2.3,
>
> If a null pointer constant is converted to a pointer type, the resulting
> pointer,
On Tue, Aug 31, 2010 at 10:11:15PM +0200, Dimitry Andric wrote:
> On 2010-08-31 21:51, Kostik Belousov wrote:
> > What is the undefined behaviour you are claiming there ?
>
> Arithmetic on a NULL pointer, which is undefined. The C standard says
> in 6.5.6 (additive operators):
>
> 3. For subtrac
On Tuesday, August 31, 2010 3:53:54 pm Dimitry Andric wrote:
> On 2010-08-31 21:37, John Baldwin wrote:
> >> -return *(p + 0x401) * 128 * 1024 + *(u_int16_t *)(p + 0x594) * 1024
* 1024;
> >> +return *p * 128 * 1024 + *(u_int16_t *)(p + (0x594 - 0x401)) * 1024
* 1024;
> >> }
> >
> > Perh
On 2010-08-31 21:51, Kostik Belousov wrote:
> What is the undefined behaviour you are claiming there ?
Arithmetic on a NULL pointer, which is undefined. The C standard says
in 6.5.6 (additive operators):
3. For subtraction, one of the following shall hold:
— both operands have arithmetic type
On 2010-08-31 21:37, John Baldwin wrote:
>> -return *(p + 0x401) * 128 * 1024 + *(u_int16_t *)(p + 0x594) * 1024 *
>> 1024;
>> +return *p * 128 * 1024 + *(u_int16_t *)(p + (0x594 - 0x401)) * 1024 *
>> 1024;
>> }
>
> Perhaps replace '(p + 0x594 - 0x401)' with just 'PTOV(0x594)'?
>
> I w
On Tue, Aug 31, 2010 at 06:11:50PM +, Dimitry Andric wrote:
> Author: dim
> Date: Tue Aug 31 18:11:50 2010
> New Revision: 212064
> URL: http://svn.freebsd.org/changeset/base/212064
>
> Log:
> Avoid directly manipulating a NULL pointer (which could result in
> undefined behaviour) in sys/b
On Tuesday, August 31, 2010 2:11:50 pm Dimitry Andric wrote:
> Author: dim
> Date: Tue Aug 31 18:11:50 2010
> New Revision: 212064
> URL: http://svn.freebsd.org/changeset/base/212064
>
> Log:
> Avoid directly manipulating a NULL pointer (which could result in
> undefined behaviour) in sys/boot
Author: dim
Date: Tue Aug 31 18:11:50 2010
New Revision: 212064
URL: http://svn.freebsd.org/changeset/base/212064
Log:
Avoid directly manipulating a NULL pointer (which could result in
undefined behaviour) in sys/boot/pc98/boot2/boot2.c.
Reviewed by: nyan
Approved by: rpaulo (mentor)