On Thu, Jun 15, 2023 at 11:36:21AM +0200, Stefan Fritsch wrote:
> >From FreeBSD commits
>     
>       commit c0db7289c3de290d821311942d5533f2284af77f
>       Author: pfg <p...@freebsd.org>
>       Date:   Wed Aug 8 15:08:22 2018 +0000
>     
>       msdosfs: fixes for Undefined Behavior.
>     
> and
>     
>       commit 852150953b828e4e8c32789637061001158a8cf4
>       Author: kib <k...@freebsd.org>
>       Date:   Fri Oct 11 18:37:02 2019 +0000
>     
>       Plug the rest of undef behavior places that were missed in r337456.
> 
> 
> ok ?

OK bluhm@

> diff --git a/sys/msdosfs/msdosfs_fat.c b/sys/msdosfs/msdosfs_fat.c
> index d31abf7d11d..be23e161e29 100644
> --- a/sys/msdosfs/msdosfs_fat.c
> +++ b/sys/msdosfs/msdosfs_fat.c
> @@ -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)

Reply via email to