Skip to contentSkip to conversation

2.6.30-rc8 build

Compile Warning Michael S. Zick 2 participants 3 messages Jun 5, 2009

lore
Share & tools
lore
#0 lore raw

Group;

I can't argue with gcc on this one either:

drivers/scsi/sd.c: In function 'sd_read_capacity':
drivers/scsi/sd.c:1451: warning: comparison is always false due to limited range of data type

It reads to my eyes as if the function can never
select read_capacity_16 for very large devices.

Suggestions?

Mike

#1 lore raw
Quoted 8 lines

I can't argue with gcc on this one either:

drivers/scsi/sd.c: In function 'sd_read_capacity':
drivers/scsi/sd.c:1451: warning: comparison is always false due to limited range of data type

It reads to my eyes as if the function can never
select read_capacity_16 for very large devices.

The code is:

		if ((sizeof(sdkp->capacity) > 4) &&
		    (sdkp->capacity > 0xffffffffULL)) {

sdkp->capacity is a sector_t, and <linux/types.h> has:

	#ifdef CONFIG_LBD
	typedef u64 sector_t;
	typedef u64 blkcnt_t;
	#else
	typedef unsigned long sector_t;
	typedef unsigned long blkcnt_t;
	#endif

so if you don't set CONFIG_LBD on a 32-bit architecture, then you are correct that sd.c won't ever hit the READ_CAPACITY(16) case, and the kernel won't be able to handle large SCSI disks.

#2 lore raw
Quoted 24 lines · Roland Dreier
Quoted 8 lines

I can't argue with gcc on this one either:

drivers/scsi/sd.c: In function 'sd_read_capacity':
drivers/scsi/sd.c:1451: warning: comparison is always false due to limited range of data type

It reads to my eyes as if the function can never
select read_capacity_16 for very large devices.

The code is:

		if ((sizeof(sdkp->capacity) > 4) &&
		    (sdkp->capacity > 0xffffffffULL)) {

sdkp->capacity is a sector_t, and <linux/types.h> has:

	#ifdef CONFIG_LBD
	typedef u64 sector_t;
	typedef u64 blkcnt_t;
	#else
	typedef unsigned long sector_t;
	typedef unsigned long blkcnt_t;
	#endif
Quoted 5 lines

so if you don't set CONFIG_LBD on a 32-bit architecture, then you are correct that sd.c won't ever hit the READ_CAPACITY(16) case, and the kernel won't be able to handle large SCSI disks.

Perhaps then let gcc coherce the test value into a local sector_t holder to make the warning go away (it would still be protected by the >4 thing).

Not a problem here - NetBooks don't (yet) come with that big a disk. ;)

Thanks
Mike