Re: svn commit: r212064 - head/sys/boot/pc98/boot2

2010-08-31 Thread Kostik Belousov
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 + >

Re: svn commit: r212064 - head/sys/boot/pc98/boot2

2010-08-31 Thread Dimitry Andric
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,

Re: svn commit: r212064 - head/sys/boot/pc98/boot2

2010-08-31 Thread Kostik Belousov
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

Re: svn commit: r212064 - head/sys/boot/pc98/boot2

2010-08-31 Thread John Baldwin
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

Re: svn commit: r212064 - head/sys/boot/pc98/boot2

2010-08-31 Thread Dimitry Andric
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

Re: svn commit: r212064 - head/sys/boot/pc98/boot2

2010-08-31 Thread Dimitry Andric
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

Re: svn commit: r212064 - head/sys/boot/pc98/boot2

2010-08-31 Thread Kostik Belousov
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

Re: svn commit: r212064 - head/sys/boot/pc98/boot2

2010-08-31 Thread John Baldwin
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

svn commit: r212064 - head/sys/boot/pc98/boot2

2010-08-31 Thread Dimitry Andric
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)