Avoid unportable shift construct

boot.c:150:29, left shift of 255 by 24 places cannot be represented in type 'int'
boot.c:153:29, left shift of 255 by 24 places cannot be represented in type 'int'
This commit is contained in:
kamil 2020-02-22 09:59:22 +00:00
parent f7f69ae002
commit b110dc906e

View File

@ -27,7 +27,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: boot.c,v 1.22 2020/01/11 16:29:07 christos Exp $");
__RCSID("$NetBSD: boot.c,v 1.23 2020/02/22 09:59:22 kamil Exp $");
#endif /* not lint */
#include <stdlib.h>
@ -81,8 +81,8 @@ readboot(int dosfs, struct bootblock *boot)
boot->FATsmall = block[22] + (block[23] << 8);
boot->SecPerTrack = block[24] + (block[25] << 8);
boot->Heads = block[26] + (block[27] << 8);
boot->HiddenSecs = block[28] + (block[29] << 8) + (block[30] << 16) + (block[31] << 24);
boot->HugeSectors = block[32] + (block[33] << 8) + (block[34] << 16) + (block[35] << 24);
boot->HiddenSecs = block[28] + (block[29] << 8) + (block[30] << 16) + ((uint32_t)block[31] << 24);
boot->HugeSectors = block[32] + (block[33] << 8) + (block[34] << 16) + ((uint32_t)block[35] << 24);
boot->FATsecs = boot->FATsmall;
@ -90,7 +90,7 @@ readboot(int dosfs, struct bootblock *boot)
boot->flags |= FAT32;
if (boot->flags & FAT32) {
boot->FATsecs = block[36] + (block[37] << 8)
+ (block[38] << 16) + (block[39] << 24);
+ (block[38] << 16) + ((uint32_t)block[39] << 24);
if (block[40] & 0x80)
boot->ValidFat = block[40] & 0x0f;
@ -102,7 +102,7 @@ readboot(int dosfs, struct bootblock *boot)
return FSFATAL;
}
boot->RootCl = block[44] + (block[45] << 8)
+ (block[46] << 16) + (block[47] << 24);
+ (block[46] << 16) + ((uint32_t)block[47] << 24);
boot->FSInfo = block[48] + (block[49] << 8);
boot->Backup = block[50] + (block[51] << 8);
@ -147,10 +147,10 @@ readboot(int dosfs, struct bootblock *boot)
if (boot->FSInfo) {
boot->FSFree = fsinfo[0x1e8] + (fsinfo[0x1e9] << 8)
+ (fsinfo[0x1ea] << 16)
+ (fsinfo[0x1eb] << 24);
+ ((uint32_t)fsinfo[0x1eb] << 24);
boot->FSNext = fsinfo[0x1ec] + (fsinfo[0x1ed] << 8)
+ (fsinfo[0x1ee] << 16)
+ (fsinfo[0x1ef] << 24);
+ ((uint32_t)fsinfo[0x1ef] << 24);
}
if (lseek(dosfs, boot->Backup * boot->BytesPerSec, SEEK_SET)