summaryrefslogtreecommitdiff
path: root/sys/dev/raidframe/rf_utils.c
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2019-02-09 03:33:59 +0000
committerchristos <christos@NetBSD.org>2019-02-09 03:33:59 +0000
commitf9496794ff5670818d14b58cb9ffda8f702eaed7 (patch)
tree44b46fe0fb83d0c2f7514745778b296e33474227 /sys/dev/raidframe/rf_utils.c
parent96d63dcbe0bd602859527fcd9c280042831fea01 (diff)
- Change the allocation macros to be more like function calls
- Change sizeof(type) -> sizeof(*variable) - Use macros for the long buffer length allocations - Remove "bit polishing" memsets() -- do them only once - Remove unnecessary casts Thanks to oster@ for finding bugs and testing.
Diffstat (limited to 'sys/dev/raidframe/rf_utils.c')
-rw-r--r--sys/dev/raidframe/rf_utils.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/sys/dev/raidframe/rf_utils.c b/sys/dev/raidframe/rf_utils.c
index 015bd8525aa..a75d424e378 100644
--- a/sys/dev/raidframe/rf_utils.c
+++ b/sys/dev/raidframe/rf_utils.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_utils.c,v 1.16 2006/11/16 01:33:23 christos Exp $ */
+/* $NetBSD: rf_utils.c,v 1.17 2019/02/09 03:34:00 christos Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -33,7 +33,7 @@
****************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_utils.c,v 1.16 2006/11/16 01:33:23 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_utils.c,v 1.17 2019/02/09 03:34:00 christos Exp $");
#include "rf_archs.h"
#include "rf_utils.h"
@@ -46,10 +46,9 @@ rf_make_2d_array(int b, int k, RF_AllocListElem_t *allocList)
{
RF_RowCol_t **retval, i;
- RF_MallocAndAdd(retval, b * sizeof(RF_RowCol_t *), (RF_RowCol_t **), allocList);
+ retval = RF_MallocAndAdd(b * sizeof(*retval), allocList);
for (i = 0; i < b; i++) {
- RF_MallocAndAdd(retval[i], k * sizeof(RF_RowCol_t), (RF_RowCol_t *), allocList);
- (void) memset((char *) retval[i], 0, k * sizeof(RF_RowCol_t));
+ retval[i] = RF_MallocAndAdd(k * sizeof(*retval[i]), allocList);
}
return (retval);
}
@@ -73,8 +72,7 @@ rf_make_1d_array(int c, RF_AllocListElem_t *allocList)
{
RF_RowCol_t *retval;
- RF_MallocAndAdd(retval, c * sizeof(RF_RowCol_t), (RF_RowCol_t *), allocList);
- (void) memset((char *) retval, 0, c * sizeof(RF_RowCol_t));
+ retval = RF_MallocAndAdd(c * sizeof(*retval), allocList);
return (retval);
}