diff options
author | Stefan Fritsch <sf@cvs.openbsd.org> | 2023-06-16 08:42:09 +0000 |
---|---|---|
committer | Stefan Fritsch <sf@cvs.openbsd.org> | 2023-06-16 08:42:09 +0000 |
commit | dd3b5975d70811319c574ca6c046eaaee5296b22 (patch) | |
tree | 391bf3d4a5e03143cc0ba790b370c91fc0faaf75 | |
parent | 1053994a2ebbf6e930061f310afbb9f929f2f79f (diff) |
msdosfs: fixes for Undefined Behavior
From FreeBSD commits
commit c0db7289c3de290d821311942d5533f2284af77f
Author: pfg <pfg@FreeBSD.org>
Date: Wed Aug 8 15:08:22 2018 +0000
commit 852150953b828e4e8c32789637061001158a8cf4
Author: kib <kib@FreeBSD.org>
Date: Fri Oct 11 18:37:02 2019 +0000
ok bluhm@
-rw-r--r-- | sys/msdosfs/msdosfs_fat.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/sys/msdosfs/msdosfs_fat.c b/sys/msdosfs/msdosfs_fat.c index d31abf7d11d..0b28222da0a 100644 --- a/sys/msdosfs/msdosfs_fat.c +++ b/sys/msdosfs/msdosfs_fat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msdosfs_fat.c,v 1.35 2023/04/30 17:16:36 sf Exp $ */ +/* $OpenBSD: msdosfs_fat.c,v 1.36 2023/06/16 08:42:08 sf Exp $ */ /* $NetBSD: msdosfs_fat.c,v 1.26 1997/10/17 11:24:02 ws Exp $ */ /*- @@ -411,7 +411,7 @@ usemap_alloc(struct msdosfsmount *pmp, uint32_t cn) { KASSERT(cn <= pmp->pm_maxcluster); - pmp->pm_inusemap[cn / N_INUSEBITS] |= 1 << (cn % N_INUSEBITS); + pmp->pm_inusemap[cn / N_INUSEBITS] |= 1U << (cn % N_INUSEBITS); pmp->pm_freeclustercount--; } @@ -421,7 +421,7 @@ usemap_free(struct msdosfsmount *pmp, uint32_t cn) KASSERT(cn <= pmp->pm_maxcluster); pmp->pm_freeclustercount++; - pmp->pm_inusemap[cn / N_INUSEBITS] &= ~(1 << (cn % N_INUSEBITS)); + pmp->pm_inusemap[cn / N_INUSEBITS] &= ~(1U << (cn % N_INUSEBITS)); } int @@ -652,7 +652,7 @@ chainlength(struct msdosfsmount *pmp, uint32_t start, uint32_t count) idx = start / N_INUSEBITS; start %= N_INUSEBITS; map = pmp->pm_inusemap[idx]; - map &= ~((1 << start) - 1); + map &= ~((1U << start) - 1); if (map) { len = ffs(map) - 1 - start; len = MIN(len, count); @@ -759,7 +759,7 @@ clusteralloc(struct msdosfsmount *pmp, uint32_t start, uint32_t count, for (cn = newst; cn <= pmp->pm_maxcluster;) { idx = cn / N_INUSEBITS; map = pmp->pm_inusemap[idx]; - map |= (1 << (cn % N_INUSEBITS)) - 1; + map |= (1U << (cn % N_INUSEBITS)) - 1; if (map != (u_int)-1) { cn = idx * N_INUSEBITS + ffs(map^(u_int)-1) - 1; if ((l = chainlength(pmp, cn, count)) >= count) @@ -776,7 +776,7 @@ clusteralloc(struct msdosfsmount *pmp, uint32_t start, uint32_t count, for (cn = 0; cn < newst;) { idx = cn / N_INUSEBITS; map = pmp->pm_inusemap[idx]; - map |= (1 << (cn % N_INUSEBITS)) - 1; + map |= (1U << (cn % N_INUSEBITS)) - 1; if (map != (u_int)-1) { cn = idx * N_INUSEBITS + ffs(map^(u_int)-1) - 1; if ((l = chainlength(pmp, cn, count)) >= count) |