Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/fsck_msdos Avoid unportable shift construct



details:   https://anonhg.NetBSD.org/src/rev/325f485f736f
branches:  trunk
changeset: 969487:325f485f736f
user:      kamil <kamil%NetBSD.org@localhost>
date:      Sat Feb 22 09:59:22 2020 +0000

description:
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'

diffstat:

 sbin/fsck_msdos/boot.c |  14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diffs (54 lines):

diff -r 836ee256d711 -r 325f485f736f sbin/fsck_msdos/boot.c
--- a/sbin/fsck_msdos/boot.c    Sat Feb 22 09:54:27 2020 +0000
+++ b/sbin/fsck_msdos/boot.c    Sat Feb 22 09:59:22 2020 +0000
@@ -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 @@
        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 @@
                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 @@
                        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 @@
                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)



Home | Main Index | Thread Index | Old Index