De-lint: assign MALLOC's argument, size, to a temporary unsigned
long, __size, before using it. This quiets complaints when the caller passes a 16-bit or 8-bit size---for example, in ieee80211_node_attach, where it calls MALLOC(..., ic->ic_tim_len, ...). I could not get any number of casts to quiet the complaint.
This commit is contained in:
parent
300c8b0563
commit
2e6630457d
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: malloc.h,v 1.92 2005/05/30 23:04:53 chs Exp $ */
|
||||
/* $NetBSD: malloc.h,v 1.93 2005/09/26 00:12:23 dyoung Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987, 1993
|
||||
@ -160,12 +160,13 @@ extern struct simplelock malloc_slock;
|
||||
#else /* do not collect statistics */
|
||||
#define MALLOC(space, cast, size, type, flags) \
|
||||
do { \
|
||||
struct kmembuckets *__kbp = &kmembuckets[BUCKETINDX((size))]; \
|
||||
unsigned long __size = (unsigned long)(size); \
|
||||
struct kmembuckets *__kbp = &kmembuckets[BUCKETINDX(__size)]; \
|
||||
int __s = splvm(); \
|
||||
simple_lock(&malloc_slock); \
|
||||
if (__kbp->kb_next == NULL) { \
|
||||
simple_unlock(&malloc_slock); \
|
||||
(space) = (cast)malloc((u_long)(size), (type), (flags)); \
|
||||
(space) = (cast)malloc(__size, (type), (flags)); \
|
||||
splx(__s); \
|
||||
} else { \
|
||||
(space) = (cast)__kbp->kb_next; \
|
||||
@ -173,7 +174,7 @@ do { \
|
||||
simple_unlock(&malloc_slock); \
|
||||
splx(__s); \
|
||||
if ((flags) & M_ZERO) \
|
||||
memset((space), 0, (size)); \
|
||||
memset((space), 0, __size); \
|
||||
} \
|
||||
} while (/* CONSTCOND */ 0)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user