Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/ufs/lfs Avoid undefined behavior in *_BITMAP_FREE() macros
details: https://anonhg.NetBSD.org/src/rev/7bb3149312b8
branches: trunk
changeset: 745038:7bb3149312b8
user: kamil <kamil%NetBSD.org@localhost>
date: Sat Feb 22 00:32:08 2020 +0000
description:
Avoid undefined behavior in *_BITMAP_FREE() macros
left shift of 1 by 31 places cannot be represented in type 'int'
diffstat:
sys/ufs/lfs/lfs_alloc.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diffs (38 lines):
diff -r 93b0f26284ea -r 7bb3149312b8 sys/ufs/lfs/lfs_alloc.c
--- a/sys/ufs/lfs/lfs_alloc.c Sat Feb 22 00:28:35 2020 +0000
+++ b/sys/ufs/lfs/lfs_alloc.c Sat Feb 22 00:32:08 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_alloc.c,v 1.138 2020/01/17 20:08:10 ad Exp $ */
+/* $NetBSD: lfs_alloc.c,v 1.139 2020/02/22 00:32:08 kamil Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.138 2020/01/17 20:08:10 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.139 2020/02/22 00:32:08 kamil Exp $");
#if defined(_KERNEL_OPT)
#include "opt_quota.h"
@@ -95,16 +95,16 @@
#define SET_BITMAP_FREE(F, I) do { \
DLOG((DLOG_ALLOC, "lfs: ino %d wrd %d bit %d set\n", (int)(I), \
(int)((I) >> BMSHIFT), (int)((I) & BMMASK))); \
- (F)->lfs_ino_bitmap[(I) >> BMSHIFT] |= (1 << ((I) & BMMASK)); \
+ (F)->lfs_ino_bitmap[(I) >> BMSHIFT] |= (1U << ((I) & BMMASK)); \
} while (0)
#define CLR_BITMAP_FREE(F, I) do { \
DLOG((DLOG_ALLOC, "lfs: ino %d wrd %d bit %d clr\n", (int)(I), \
(int)((I) >> BMSHIFT), (int)((I) & BMMASK))); \
- (F)->lfs_ino_bitmap[(I) >> BMSHIFT] &= ~(1 << ((I) & BMMASK)); \
+ (F)->lfs_ino_bitmap[(I) >> BMSHIFT] &= ~(1U << ((I) & BMMASK)); \
} while(0)
#define ISSET_BITMAP_FREE(F, I) \
- ((F)->lfs_ino_bitmap[(I) >> BMSHIFT] & (1 << ((I) & BMMASK)))
+ ((F)->lfs_ino_bitmap[(I) >> BMSHIFT] & (1U << ((I) & BMMASK)))
/*
* Add a new block to the Ifile, to accommodate future file creations.
Home |
Main Index |
Thread Index |
Old Index