@@ -126,13 +126,14 @@ int scsi_partsize(unsigned char *buf, unsigned long capacity,
unsigned int *cyls, unsigned int *hds, unsigned int *secs)
{
struct partition *p = (struct partition *)buf, *largest = NULL;
- int i, largest_cyl;
- int cyl, ext_cyl, end_head, end_cyl, end_sector;
+ int i;
+ unsigned int largest_cyl = UINT_MAX;
+ unsigned int cyl, ext_cyl, end_head, end_cyl, end_sector;
unsigned int logical_end, physical_end, ext_physical_end;
if (*(unsigned short *) (buf + 64) == 0xAA55) {
- for (largest_cyl = -1, i = 0; i < 4; ++i, ++p) {
+ for (i = 0; i < 4; ++i, ++p) {
if (!p->sys_ind)
continue;
#ifdef DEBUG
@@ -140,7 +141,7 @@ int scsi_partsize(unsigned char *buf, unsigned long capacity,
i);
#endif
cyl = p->cyl + ((p->sector & 0xc0) << 2);
- if (cyl > largest_cyl) {
+ if ((largest == NULL) || (cyl > largest_cyl)) {
largest_cyl = cyl;
largest = p;
}