block.h: Make BDRV_SECTOR_SIZE 64 bit safe
PATCH 1/1 block.h: Make BDRV_SECTOR_SIZE 64 bit safe
From: Jes Sorensen <[email protected]>
C defaults to int, so make definition of BDRV_SECTOR_SIZE 64 bit safe as it and BDRV_SECTOR_MASK may be used against 64 bit addresses.
--- block.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
block.h +1 -1
@@ -38,7 +38,7 @@ typedef struct QEMUSnapshotInfo {#define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_CACHE_WB)#define BDRV_SECTOR_BITS 9 -#define BDRV_SECTOR_SIZE (1 << BDRV_SECTOR_BITS) +#define BDRV_SECTOR_SIZE (1ULL << BDRV_SECTOR_BITS)#define BDRV_SECTOR_MASK ~(BDRV_SECTOR_SIZE - 1) typedef enum {
Signature · 1 line
1.6.5.2
Kevin Wolf
AppliedAm 27.05.2010 15:46, schrieb [email protected]:
Quoted 6 lines
From: Jes Sorensen <[email protected]>
C defaults to int, so make definition of
BDRV_SECTOR_SIZE64 bit safe as it andBDRV_SECTOR_MASKmay be used against 64 bit addresses.Signed-off-by Jes Sorensen <[email protected]>
Thanks, applied to the block branch.
Kevin
Quoted 9 lines · Kevin Wolf
Am 27.05.2010 15:46, schrieb [email protected]:
Quoted 6 lines
From: Jes Sorensen<[email protected]>
C defaults to int, so make definition of
BDRV_SECTOR_SIZE64 bit safe as it andBDRV_SECTOR_MASKmay be used against 64 bit addresses.Signed-off-by Jes Sorensen<[email protected]>Thanks, applied to the block branch.
Candidate for stable too?
Paolo
Quoted 4 lines · Paolo Bonzini
Quoted 3 lines · Kevin Wolf
Am 27.05.2010 15:46, schrieb [email protected]:
Quoted 2 lines
From: Jes Sorensen<[email protected]>
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
C defaults to int, so make definition of
BDRV_SECTOR_SIZE64 bit safe as it andBDRV_SECTOR_MASKmay be used against 64 bit addresses.Signed-off-by Jes Sorensen<[email protected]>Thanks, applied to the block branch.
Candidate for stable too?
It should be safe to apply, but I didn't find any current users where the mask was applied in a way where it was causing problems. Not sure if you want the noise, or apply it as better safe than sorry?
Cheers,
Jes
Quoted 4 lines · Jes Sorensen
Quoted 1 line
Candidate for stable too?
It should be safe to apply, but I didn't find any current users where the mask was applied in a way where it was causing problems. Not sure if you want the noise, or apply it as better safe than sorry?
The only use in fact is this:
addr = qemu_get_be64(f);
flags = addr & ~BDRV_SECTOR_MASK;which is safe since the ~~ cancels to give back 511 again. So nevermind, just asking. If there are no bugs related to it it seems just as safe not to apply it.
Paolo
Quoted 6 lines · Paolo Bonzini
Quoted 4 lines · Jes Sorensen
Quoted 1 line
Candidate for stable too?
It should be safe to apply, but I didn't find any current users where the mask was applied in a way where it was causing problems. Not sure if you want the noise, or apply it as better safe than sorry?
Quoted 8 lines
The only use in fact is this:
addr = qemu_get_be64(f); flags = addr & ~BDRV_SECTOR_MASK;which is safe since the ~~ cancels to give back 511 again. So nevermind, just asking. If there are no bugs related to it it seems just as safe not to apply it.
That is correct, which is why I don't think it is necessary for the stable release. However I want to see the fix in upstream as the macro is likely to get used for other things in the future and it's a hidden bug waiting to happen.
Cheers,
Jes