Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/raidframe - Change the allocation macros to be more ...
details: https://anonhg.NetBSD.org/src/rev/e972a069a974
branches: trunk
changeset: 448782:e972a069a974
user: christos <christos%NetBSD.org@localhost>
date: Sat Feb 09 03:33:59 2019 +0000
description:
- 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:
sys/dev/raidframe/rf_alloclist.c | 6 +-
sys/dev/raidframe/rf_chaindecluster.c | 6 +-
sys/dev/raidframe/rf_compat32.c | 9 +-
sys/dev/raidframe/rf_compat50.c | 20 +++---
sys/dev/raidframe/rf_compat80.c | 40 ++++++------
sys/dev/raidframe/rf_copyback.c | 9 +-
sys/dev/raidframe/rf_cvscan.c | 7 +-
sys/dev/raidframe/rf_dagdegrd.c | 58 +++++++++-------
sys/dev/raidframe/rf_dagdegwr.c | 36 +++++-----
sys/dev/raidframe/rf_dagffwr.c | 11 +-
sys/dev/raidframe/rf_dagutils.c | 27 +++----
sys/dev/raidframe/rf_debugMem.c | 100 +++++++++++++++++------------
sys/dev/raidframe/rf_debugMem.h | 77 ++++++++++++----------
sys/dev/raidframe/rf_decluster.c | 23 +++---
sys/dev/raidframe/rf_declusterPQ.c | 6 +-
sys/dev/raidframe/rf_diskqueue.c | 13 +--
sys/dev/raidframe/rf_disks.c | 16 ++--
sys/dev/raidframe/rf_driver.c | 6 +-
sys/dev/raidframe/rf_evenodd.c | 20 +++--
sys/dev/raidframe/rf_evenodd_dagfuncs.c | 39 ++++-------
sys/dev/raidframe/rf_fifo.c | 7 +-
sys/dev/raidframe/rf_interdecluster.c | 7 +-
sys/dev/raidframe/rf_map.c | 30 ++++----
sys/dev/raidframe/rf_netbsdkintf.c | 19 ++---
sys/dev/raidframe/rf_paritylog.c | 8 +-
sys/dev/raidframe/rf_paritylogDiskMgr.c | 25 +-----
sys/dev/raidframe/rf_paritylogging.c | 60 +++++++----------
sys/dev/raidframe/rf_parityloggingdags.c | 18 ++---
sys/dev/raidframe/rf_paritymap.c | 10 +-
sys/dev/raidframe/rf_parityscan.c | 13 ++-
sys/dev/raidframe/rf_psstatus.c | 10 +-
sys/dev/raidframe/rf_raid0.c | 9 +-
sys/dev/raidframe/rf_raid1.c | 14 ++--
sys/dev/raidframe/rf_raid4.c | 9 +-
sys/dev/raidframe/rf_raid5.c | 6 +-
sys/dev/raidframe/rf_raid5_rotatedspare.c | 6 +-
sys/dev/raidframe/rf_reconmap.c | 11 +--
sys/dev/raidframe/rf_reconstruct.c | 12 +-
sys/dev/raidframe/rf_reconutil.c | 12 +-
sys/dev/raidframe/rf_sstf.c | 10 +-
sys/dev/raidframe/rf_stripelocks.c | 8 +-
sys/dev/raidframe/rf_utils.c | 12 +--
42 files changed, 416 insertions(+), 429 deletions(-)
diffs (truncated from 2694 to 300 lines):
diff -r adc3c7b63333 -r e972a069a974 sys/dev/raidframe/rf_alloclist.c
--- a/sys/dev/raidframe/rf_alloclist.c Sat Feb 09 02:43:11 2019 +0000
+++ b/sys/dev/raidframe/rf_alloclist.c Sat Feb 09 03:33:59 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_alloclist.c,v 1.26 2009/03/15 17:17:23 cegger Exp $ */
+/* $NetBSD: rf_alloclist.c,v 1.27 2019/02/09 03:33:59 christos Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -37,7 +37,7 @@
***************************************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_alloclist.c,v 1.26 2009/03/15 17:17:23 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_alloclist.c,v 1.27 2019/02/09 03:33:59 christos Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -125,6 +125,6 @@
RF_AllocListElem_t *p;
p = pool_get(&rf_pools.alloclist, PR_WAITOK);
- memset((char *) p, 0, sizeof(RF_AllocListElem_t));
+ memset(p, 0, sizeof(*p));
return (p);
}
diff -r adc3c7b63333 -r e972a069a974 sys/dev/raidframe/rf_chaindecluster.c
--- a/sys/dev/raidframe/rf_chaindecluster.c Sat Feb 09 02:43:11 2019 +0000
+++ b/sys/dev/raidframe/rf_chaindecluster.c Sat Feb 09 03:33:59 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_chaindecluster.c,v 1.15 2006/11/16 01:33:23 christos Exp $ */
+/* $NetBSD: rf_chaindecluster.c,v 1.16 2019/02/09 03:33:59 christos Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -33,7 +33,7 @@
*****************************************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_chaindecluster.c,v 1.15 2006/11/16 01:33:23 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_chaindecluster.c,v 1.16 2019/02/09 03:33:59 christos Exp $");
#include "rf_archs.h"
@@ -70,7 +70,7 @@
RF_RowCol_t i;
/* create a Chained Declustering configuration structure */
- RF_MallocAndAdd(info, sizeof(RF_ChaindeclusterConfigInfo_t), (RF_ChaindeclusterConfigInfo_t *), raidPtr->cleanupList);
+ info = RF_MallocAndAdd(sizeof(*info), raidPtr->cleanupList);
if (info == NULL)
return (ENOMEM);
layoutPtr->layoutSpecificInfo = (void *) info;
diff -r adc3c7b63333 -r e972a069a974 sys/dev/raidframe/rf_compat32.c
--- a/sys/dev/raidframe/rf_compat32.c Sat Feb 09 02:43:11 2019 +0000
+++ b/sys/dev/raidframe/rf_compat32.c Sat Feb 09 03:33:59 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_compat32.c,v 1.4 2019/02/06 15:39:41 christos Exp $ */
+/* $NetBSD: rf_compat32.c,v 1.5 2019/02/09 03:33:59 christos Exp $ */
/*
* Copyright (c) 2017 Matthew R. Green
@@ -88,7 +88,7 @@
RF_Config_t32 *k_cfg32;
int rv;
- RF_Malloc(k_cfg32, sizeof(RF_Config_t32), (RF_Config_t32 *));
+ k_cfg32 = RF_Malloc(sizeof(*k_cfg32));
if (k_cfg32 == NULL)
return ENOMEM;
@@ -98,7 +98,7 @@
return ENOMEM;
}
- RF_Malloc(k_cfg, sizeof(RF_Config_t), (RF_Config_t *));
+ k_cfg = RF_Malloc(sizeof(*k_cfg));
if (k_cfg == NULL) {
RF_Free(k_cfg32, sizeof(RF_Config_t32));
RF_Free(k_cfg, sizeof(RF_Config_t));
@@ -132,8 +132,7 @@
int retcode;
void *ucfgp = NETBSD32PTR64(*(netbsd32_pointer_t *)data);
- RF_DeviceConfig_t *d_cfg;
- RF_Malloc(d_cfg, sizeof(RF_DeviceConfig_t), (RF_DeviceConfig_t *));
+ RF_DeviceConfig_t *d_cfg = RF_Malloc(sizeof(*d_cfg));
if (d_cfg == NULL)
return ENOMEM;
diff -r adc3c7b63333 -r e972a069a974 sys/dev/raidframe/rf_compat50.c
--- a/sys/dev/raidframe/rf_compat50.c Sat Feb 09 02:43:11 2019 +0000
+++ b/sys/dev/raidframe/rf_compat50.c Sat Feb 09 03:33:59 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_compat50.c,v 1.8 2019/02/05 23:28:02 christos Exp $ */
+/* $NetBSD: rf_compat50.c,v 1.9 2019/02/09 03:33:59 christos Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -123,18 +123,18 @@
/* data points to a pointer to the configuration structure */
u50_cfg = *((RF_Config50_t **) data);
- RF_Malloc(k50_cfg, sizeof(RF_Config50_t), (RF_Config50_t *));
+ k50_cfg = RF_Malloc(sizeof(*k50_cfg));
if (k50_cfg == NULL)
return ENOMEM;
- error = copyin(u50_cfg, k50_cfg, sizeof(RF_Config50_t));
+ error = copyin(u50_cfg, k50_cfg, sizeof(*k50_cfg));
if (error) {
- RF_Free(k50_cfg, sizeof(RF_Config50_t));
+ RF_Free(k50_cfg, sizeof(*k50_cfg));
return error;
}
- RF_Malloc(k_cfg, sizeof(RF_Config_t), (RF_Config_t *));
+ k_cfg = RF_Malloc(sizeof(*k_cfg));
if (k_cfg == NULL) {
- RF_Free(k50_cfg, sizeof(RF_Config50_t));
+ RF_Free(k50_cfg, sizeof(*k50_cfg));
return ENOMEM;
}
@@ -171,7 +171,7 @@
k_cfg->layoutSpecific = k50_cfg->layoutSpecific;
k_cfg->force = k50_cfg->force;
- RF_Free(k50_cfg, sizeof(RF_Config50_t));
+ RF_Free(k50_cfg, sizeof(*k50_cfg));
return rf_construct(rs, k_cfg);
}
@@ -185,7 +185,7 @@
if (!raidPtr->valid)
return ENODEV;
- RF_Malloc(d_cfg, sizeof(RF_DeviceConfig50_t), (RF_DeviceConfig50_t *));
+ d_cfg = RF_Malloc(sizeof(*d_cfg));
if (d_cfg == NULL)
return ENOMEM;
@@ -211,10 +211,10 @@
for (j = d_cfg->cols, i = 0; i < d_cfg->nspares; i++, j++)
rf_disk_to_disk50(&d_cfg->spares[i], &raidPtr->Disks[j]);
- error = copyout(d_cfg, *ucfgp, sizeof(RF_DeviceConfig50_t));
+ error = copyout(d_cfg, *ucfgp, sizeof(**ucfgp));
out:
- RF_Free(d_cfg, sizeof(RF_DeviceConfig50_t));
+ RF_Free(d_cfg, sizeof(*d_cfg));
return error;
}
diff -r adc3c7b63333 -r e972a069a974 sys/dev/raidframe/rf_compat80.c
--- a/sys/dev/raidframe/rf_compat80.c Sat Feb 09 02:43:11 2019 +0000
+++ b/sys/dev/raidframe/rf_compat80.c Sat Feb 09 03:33:59 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_compat80.c,v 1.11 2019/02/05 23:28:02 christos Exp $ */
+/* $NetBSD: rf_compat80.c,v 1.12 2019/02/09 03:33:59 christos Exp $ */
/*
* Copyright (c) 2017 Matthew R. Green
@@ -119,7 +119,7 @@
RF_ProgressInfo_t info, **infoPtr = data;
rf_check_recon_status_ext(raidPtr, &info);
- return copyout(&info, *infoPtr, sizeof info);
+ return copyout(&info, *infoPtr, sizeof(info));
}
static int
@@ -128,7 +128,7 @@
RF_ProgressInfo_t info, **infoPtr = data;
rf_check_parityrewrite_status_ext(raidPtr, &info);
- return copyout(&info, *infoPtr, sizeof info);
+ return copyout(&info, *infoPtr, sizeof(info));
}
static int
@@ -137,7 +137,7 @@
RF_ProgressInfo_t info, **infoPtr = data;
rf_check_copyback_status_ext(raidPtr, &info);
- return copyout(&info, *infoPtr, sizeof info);
+ return copyout(&info, *infoPtr, sizeof(info));
}
static void
@@ -145,7 +145,7 @@
{
/* Be sure the padding areas don't have kernel memory. */
- memset(disk80, 0, sizeof *disk80);
+ memset(disk80, 0, sizeof(*disk80));
memcpy(disk80->devname, disk->devname, sizeof(disk80->devname));
disk80->status = disk->status;
disk80->spareRow = 0;
@@ -164,13 +164,13 @@
RF_DeviceConfig_t80 *config80, **configPtr80 = data;
int rv;
- RF_Malloc(config, sizeof *config, (RF_DeviceConfig_t *));
+ config = RF_Malloc(sizeof(*config));
if (config == NULL)
- return (ENOMEM);
- RF_Malloc(config80, sizeof *config80, (RF_DeviceConfig_t80 *));
+ return ENOMEM;
+ config80 = RF_Malloc(sizeof(*config80));
if (config80 == NULL) {
- RF_Free(config, sizeof(RF_DeviceConfig_t))
- return (ENOMEM);
+ RF_Free(config, sizeof(*config));
+ return ENOMEM;
}
rv = rf_get_info(raidPtr, config);
if (rv == 0) {
@@ -186,10 +186,10 @@
rf_copy_raiddisk80(&config->spares[i],
&config80->spares[i]);
}
- rv = copyout(config80, *configPtr80, sizeof *config80);
+ rv = copyout(config80, *configPtr80, sizeof(*config80));
}
- RF_Free(config, sizeof(RF_DeviceConfig_t));
- RF_Free(config80, sizeof(RF_DeviceConfig_t80));
+ RF_Free(config, sizeof(*config));
+ RF_Free(config80, sizeof(*config80));
return rv;
}
@@ -205,7 +205,7 @@
* Perhaps there should be an option to skip the in-core
* copy and hit the disk, as with disklabel(8).
*/
- RF_Malloc(clabel, sizeof(*clabel), (RF_ComponentLabel_t *));
+ clabel = RF_Malloc(sizeof(*clabel));
if (clabel == NULL)
return ENOMEM;
retcode = copyin(*clabel_ptr, clabel, sizeof(*clabel));
@@ -240,18 +240,18 @@
/* data points to a pointer to the configuration structure */
u80_cfg = *((RF_Config_t80 **) data);
- RF_Malloc(k80_cfg, sizeof(RF_Config_t80), (RF_Config_t80 *));
+ k80_cfg = RF_Malloc(sizeof(*k80_cfg));
if (k80_cfg == NULL)
return ENOMEM;
- error = copyin(u80_cfg, k80_cfg, sizeof(RF_Config_t80));
+ error = copyin(u80_cfg, k80_cfg, sizeof(*k80_cfg));
if (error) {
- RF_Free(k80_cfg, sizeof(RF_Config_t80));
+ RF_Free(k80_cfg, sizeof(*k80_cfg));
return error;
}
- RF_Malloc(k_cfg, sizeof(RF_Config_t), (RF_Config_t *));
+ k_cfg = RF_Malloc(sizeof(*k_cfg));
if (k_cfg == NULL) {
- RF_Free(k80_cfg, sizeof(RF_Config_t80));
+ RF_Free(k80_cfg, sizeof(*k80_cfg));
return ENOMEM;
}
@@ -288,7 +288,7 @@
k_cfg->layoutSpecific = k80_cfg->layoutSpecific;
k_cfg->force = k80_cfg->force;
- RF_Free(k80_cfg, sizeof(RF_Config_t80));
+ RF_Free(k80_cfg, sizeof(*k80_cfg));
return rf_construct(rs, k_cfg);
}
diff -r adc3c7b63333 -r e972a069a974 sys/dev/raidframe/rf_copyback.c
--- a/sys/dev/raidframe/rf_copyback.c Sat Feb 09 02:43:11 2019 +0000
+++ b/sys/dev/raidframe/rf_copyback.c Sat Feb 09 03:33:59 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_copyback.c,v 1.50 2014/06/14 07:39:00 hannken Exp $ */
+/* $NetBSD: rf_copyback.c,v 1.51 2019/02/09 03:33:59 christos Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -38,7 +38,7 @@
****************************************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_copyback.c,v 1.50 2014/06/14 07:39:00 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_copyback.c,v 1.51 2019/02/09 03:33:59 christos Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -185,10 +185,11 @@
return;
}
/* get a buffer to hold one SU */
- RF_Malloc(databuf, rf_RaidAddressToByte(raidPtr, raidPtr->Layout.sectorsPerStripeUnit), (char *));
+ databuf = RF_Malloc(rf_RaidAddressToByte(raidPtr,
+ raidPtr->Layout.sectorsPerStripeUnit));
Home |
Main Index |
Thread Index |
Old Index