[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 02/40] elf: Add notes implementation
From: |
Michael Matz |
Subject: |
Re: [Qemu-devel] [PATCH 02/40] elf: Add notes implementation |
Date: |
Tue, 2 Nov 2010 11:17:55 +0100 (CET) |
Hi,
On Mon, 1 Nov 2010, Alexander Graf wrote:
> > No. Pointers of same type which are not void pointers can be compared.
> >
> > There is even a data type ptrdiff_t, so you can also compare their
> > difference with zero.
>
> Let's ask someone who definitely knows :).
>
> Michael, is code like
>
> char *x = a, *y = b;
> if (x < y) {
> ...
> }
Pointers can be compared iff they point into the same object
(including right after the object), so it depends on what a and b were
above. This would be invalid for instance:
int o1, o2;
int *p1 = &o1, *p2 = &o2;
if (p1 < p2) ...
> valid? Or do I first have to cast x and y to unsigned longs or
> uintptr_t?
For doing a valid pointer comparison you don't have to cast anything.
Casting doesn't make an invalid comparison valid.
Ciao,
Michael.
- [Qemu-devel] [PATCH 24/40] xenner: kernel: printk, (continued)
- [Qemu-devel] [PATCH 24/40] xenner: kernel: printk, Alexander Graf, 2010/11/01
- [Qemu-devel] [PATCH 25/40] xenner: kernel: KVM PV code, Alexander Graf, 2010/11/01
- [Qemu-devel] [PATCH 02/40] elf: Add notes implementation, Alexander Graf, 2010/11/01
- Re: [Qemu-devel] [PATCH 02/40] elf: Add notes implementation, Blue Swirl, 2010/11/01
- Re: [Qemu-devel] [PATCH 02/40] elf: Add notes implementation, Stefan Weil, 2010/11/01
- Re: [Qemu-devel] [PATCH 02/40] elf: Add notes implementation, Alexander Graf, 2010/11/01
- Re: [Qemu-devel] [PATCH 02/40] elf: Add notes implementation, Stefan Weil, 2010/11/01
- Re: [Qemu-devel] [PATCH 02/40] elf: Add notes implementation, Alexander Graf, 2010/11/01
- [Qemu-devel] Re: [PATCH 02/40] elf: Add notes implementation, Paolo Bonzini, 2010/11/01
- Re: [Qemu-devel] [PATCH 02/40] elf: Add notes implementation, Stefan Weil, 2010/11/01
- Re: [Qemu-devel] [PATCH 02/40] elf: Add notes implementation,
Michael Matz <=
[Qemu-devel] Re: [PATCH 02/40] elf: Add notes implementation, Paolo Bonzini, 2010/11/01
[Qemu-devel] [PATCH 05/40] xen-disk: disable aio, Alexander Graf, 2010/11/01
[Qemu-devel] [PATCH 31/40] xenner: libxc emu: xenstore, Alexander Graf, 2010/11/01
[Qemu-devel] [PATCH 04/40] elf: add section analyzer, Alexander Graf, 2010/11/01
[Qemu-devel] [PATCH 10/40] xenner: kernel: Hypercall handler (i386), Alexander Graf, 2010/11/01