Module Name: src Committed By: christos Date: Sat Feb 9 03:34:00 UTC 2019
Modified Files: src/sys/dev/raidframe: rf_alloclist.c rf_chaindecluster.c rf_compat32.c rf_compat50.c rf_compat80.c rf_copyback.c rf_cvscan.c rf_dagdegrd.c rf_dagdegwr.c rf_dagffwr.c rf_dagutils.c rf_debugMem.c rf_debugMem.h rf_decluster.c rf_declusterPQ.c rf_diskqueue.c rf_disks.c rf_driver.c rf_evenodd.c rf_evenodd_dagfuncs.c rf_fifo.c rf_interdecluster.c rf_map.c rf_netbsdkintf.c rf_paritylog.c rf_paritylogDiskMgr.c rf_paritylogging.c rf_parityloggingdags.c rf_paritymap.c rf_parityscan.c rf_psstatus.c rf_raid0.c rf_raid1.c rf_raid4.c rf_raid5.c rf_raid5_rotatedspare.c rf_reconmap.c rf_reconstruct.c rf_reconutil.c rf_sstf.c rf_stripelocks.c rf_utils.c Log Message: - 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. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/dev/raidframe/rf_alloclist.c cvs rdiff -u -r1.15 -r1.16 src/sys/dev/raidframe/rf_chaindecluster.c \ src/sys/dev/raidframe/rf_fifo.c src/sys/dev/raidframe/rf_raid0.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/raidframe/rf_compat32.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/raidframe/rf_compat50.c \ src/sys/dev/raidframe/rf_paritymap.c cvs rdiff -u -r1.11 -r1.12 src/sys/dev/raidframe/rf_compat80.c cvs rdiff -u -r1.50 -r1.51 src/sys/dev/raidframe/rf_copyback.c cvs rdiff -u -r1.16 -r1.17 src/sys/dev/raidframe/rf_cvscan.c \ src/sys/dev/raidframe/rf_declusterPQ.c src/sys/dev/raidframe/rf_sstf.c \ src/sys/dev/raidframe/rf_utils.c cvs rdiff -u -r1.29 -r1.30 src/sys/dev/raidframe/rf_dagdegrd.c cvs rdiff -u -r1.33 -r1.34 src/sys/dev/raidframe/rf_dagdegwr.c cvs rdiff -u -r1.34 -r1.35 src/sys/dev/raidframe/rf_dagffwr.c \ src/sys/dev/raidframe/rf_paritylogging.c \ src/sys/dev/raidframe/rf_parityscan.c src/sys/dev/raidframe/rf_psstatus.c cvs rdiff -u -r1.54 -r1.55 src/sys/dev/raidframe/rf_dagutils.c cvs rdiff -u -r1.21 -r1.22 src/sys/dev/raidframe/rf_debugMem.c \ src/sys/dev/raidframe/rf_evenodd.c \ src/sys/dev/raidframe/rf_parityloggingdags.c cvs rdiff -u -r1.13 -r1.14 src/sys/dev/raidframe/rf_debugMem.h \ src/sys/dev/raidframe/rf_raid5_rotatedspare.c cvs rdiff -u -r1.25 -r1.26 src/sys/dev/raidframe/rf_decluster.c cvs rdiff -u -r1.53 -r1.54 src/sys/dev/raidframe/rf_diskqueue.c cvs rdiff -u -r1.90 -r1.91 src/sys/dev/raidframe/rf_disks.c cvs rdiff -u -r1.134 -r1.135 src/sys/dev/raidframe/rf_driver.c cvs rdiff -u -r1.22 -r1.23 src/sys/dev/raidframe/rf_evenodd_dagfuncs.c cvs rdiff -u -r1.14 -r1.15 src/sys/dev/raidframe/rf_interdecluster.c cvs rdiff -u -r1.47 -r1.48 src/sys/dev/raidframe/rf_map.c cvs rdiff -u -r1.373 -r1.374 src/sys/dev/raidframe/rf_netbsdkintf.c cvs rdiff -u -r1.18 -r1.19 src/sys/dev/raidframe/rf_paritylog.c cvs rdiff -u -r1.28 -r1.29 src/sys/dev/raidframe/rf_paritylogDiskMgr.c cvs rdiff -u -r1.35 -r1.36 src/sys/dev/raidframe/rf_raid1.c cvs rdiff -u -r1.12 -r1.13 src/sys/dev/raidframe/rf_raid4.c cvs rdiff -u -r1.19 -r1.20 src/sys/dev/raidframe/rf_raid5.c cvs rdiff -u -r1.36 -r1.37 src/sys/dev/raidframe/rf_reconmap.c \ src/sys/dev/raidframe/rf_reconutil.c cvs rdiff -u -r1.121 -r1.122 src/sys/dev/raidframe/rf_reconstruct.c cvs rdiff -u -r1.32 -r1.33 src/sys/dev/raidframe/rf_stripelocks.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/raidframe/rf_alloclist.c diff -u src/sys/dev/raidframe/rf_alloclist.c:1.26 src/sys/dev/raidframe/rf_alloclist.c:1.27 --- src/sys/dev/raidframe/rf_alloclist.c:1.26 Sun Mar 15 13:17:23 2009 +++ src/sys/dev/raidframe/rf_alloclist.c Fri Feb 8 22:33:59 2019 @@ -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_real_MakeAllocList(void) 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); } Index: src/sys/dev/raidframe/rf_chaindecluster.c diff -u src/sys/dev/raidframe/rf_chaindecluster.c:1.15 src/sys/dev/raidframe/rf_chaindecluster.c:1.16 --- src/sys/dev/raidframe/rf_chaindecluster.c:1.15 Wed Nov 15 20:33:23 2006 +++ src/sys/dev/raidframe/rf_chaindecluster.c Fri Feb 8 22:33:59 2019 @@ -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_ConfigureChainDecluster(RF_ShutdownLi 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; Index: src/sys/dev/raidframe/rf_fifo.c diff -u src/sys/dev/raidframe/rf_fifo.c:1.15 src/sys/dev/raidframe/rf_fifo.c:1.16 --- src/sys/dev/raidframe/rf_fifo.c:1.15 Wed Nov 15 20:33:23 2006 +++ src/sys/dev/raidframe/rf_fifo.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_fifo.c,v 1.15 2006/11/16 01:33:23 christos Exp $ */ +/* $NetBSD: rf_fifo.c,v 1.16 2019/02/09 03:34:00 christos Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -36,7 +36,7 @@ ***************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_fifo.c,v 1.15 2006/11/16 01:33:23 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_fifo.c,v 1.16 2019/02/09 03:34:00 christos Exp $"); #include <dev/raidframe/raidframevar.h> @@ -58,8 +58,7 @@ rf_FifoCreate(RF_SectorCount_t sectPerDi { RF_FifoHeader_t *q; - RF_MallocAndAdd(q, sizeof(RF_FifoHeader_t), - (RF_FifoHeader_t *), clList); + q = RF_MallocAndAdd(sizeof(*q), clList); q->hq_count = q->lq_count = 0; return ((void *) q); } Index: src/sys/dev/raidframe/rf_raid0.c diff -u src/sys/dev/raidframe/rf_raid0.c:1.15 src/sys/dev/raidframe/rf_raid0.c:1.16 --- src/sys/dev/raidframe/rf_raid0.c:1.15 Wed Nov 15 20:33:23 2006 +++ src/sys/dev/raidframe/rf_raid0.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_raid0.c,v 1.15 2006/11/16 01:33:23 christos Exp $ */ +/* $NetBSD: rf_raid0.c,v 1.16 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_raid0.c,v 1.15 2006/11/16 01:33:23 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_raid0.c,v 1.16 2019/02/09 03:34:00 christos Exp $"); #include <dev/raidframe/raidframevar.h> @@ -60,12 +60,13 @@ rf_ConfigureRAID0(RF_ShutdownList_t **li RF_RowCol_t i; /* create a RAID level 0 configuration structure */ - RF_MallocAndAdd(info, sizeof(RF_Raid0ConfigInfo_t), (RF_Raid0ConfigInfo_t *), raidPtr->cleanupList); + info = RF_MallocAndAdd(sizeof(*info), raidPtr->cleanupList); if (info == NULL) return (ENOMEM); layoutPtr->layoutSpecificInfo = (void *) info; - RF_MallocAndAdd(info->stripeIdentifier, raidPtr->numCol * sizeof(RF_RowCol_t), (RF_RowCol_t *), raidPtr->cleanupList); + info->stripeIdentifier = RF_MallocAndAdd(raidPtr->numCol + * sizeof(*info->stripeIdentifier), raidPtr->cleanupList); if (info->stripeIdentifier == NULL) return (ENOMEM); for (i = 0; i < raidPtr->numCol; i++) Index: src/sys/dev/raidframe/rf_compat32.c diff -u src/sys/dev/raidframe/rf_compat32.c:1.4 src/sys/dev/raidframe/rf_compat32.c:1.5 --- src/sys/dev/raidframe/rf_compat32.c:1.4 Wed Feb 6 10:39:41 2019 +++ src/sys/dev/raidframe/rf_compat32.c Fri Feb 8 22:33:59 2019 @@ -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_netbsd32(struct raid_softc *rs 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 @@ rf_config_netbsd32(struct raid_softc *rs 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 @@ rf_get_info_netbsd32(RF_Raid_t *raidPtr, 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; Index: src/sys/dev/raidframe/rf_compat50.c diff -u src/sys/dev/raidframe/rf_compat50.c:1.8 src/sys/dev/raidframe/rf_compat50.c:1.9 --- src/sys/dev/raidframe/rf_compat50.c:1.8 Tue Feb 5 18:28:02 2019 +++ src/sys/dev/raidframe/rf_compat50.c Fri Feb 8 22:33:59 2019 @@ -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 @@ rf_config50(struct raid_softc *rs, void /* 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 @@ rf_config50(struct raid_softc *rs, void 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 @@ rf_get_info50(RF_Raid_t *raidPtr, void * 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 @@ rf_get_info50(RF_Raid_t *raidPtr, void * 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; } Index: src/sys/dev/raidframe/rf_paritymap.c diff -u src/sys/dev/raidframe/rf_paritymap.c:1.8 src/sys/dev/raidframe/rf_paritymap.c:1.9 --- src/sys/dev/raidframe/rf_paritymap.c:1.8 Wed Apr 27 03:55:15 2011 +++ src/sys/dev/raidframe/rf_paritymap.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_paritymap.c,v 1.8 2011/04/27 07:55:15 mrg Exp $ */ +/* $NetBSD: rf_paritymap.c,v 1.9 2019/02/09 03:34:00 christos Exp $ */ /*- * Copyright (c) 2009 Jed Davis. @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_paritymap.c,v 1.8 2011/04/27 07:55:15 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_paritymap.c,v 1.9 2019/02/09 03:34:00 christos Exp $"); #include <sys/param.h> #include <sys/callout.h> @@ -231,8 +231,7 @@ void rf_paritymap_invalidate(struct rf_paritymap *pm) { mutex_enter(&pm->lock); - memset(pm->disk_boot, ~(unsigned char)0, - sizeof(struct rf_paritymap_ondisk)); + memset(pm->disk_boot, (unsigned char)~0, sizeof(*pm->disk_boot)); mutex_exit(&pm->lock); } @@ -241,8 +240,7 @@ void rf_paritymap_forceclean(struct rf_paritymap *pm) { mutex_enter(&pm->lock); - memset(pm->disk_boot, (unsigned char)0, - sizeof(struct rf_paritymap_ondisk)); + memset(pm->disk_boot, 0, sizeof(*pm->disk_boot)); mutex_exit(&pm->lock); } Index: src/sys/dev/raidframe/rf_compat80.c diff -u src/sys/dev/raidframe/rf_compat80.c:1.11 src/sys/dev/raidframe/rf_compat80.c:1.12 --- src/sys/dev/raidframe/rf_compat80.c:1.11 Tue Feb 5 18:28:02 2019 +++ src/sys/dev/raidframe/rf_compat80.c Fri Feb 8 22:33:59 2019 @@ -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_check_recon_status_ext80(RF_Raid_t *r 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_check_parityrewrite_status_ext80(RF_R 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_check_copyback_status_ext80(RF_Raid_t 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 @@ rf_copy_raiddisk80(RF_RaidDisk_t *disk, { /* 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_get_info80(RF_Raid_t *raidPtr, void * 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_get_info80(RF_Raid_t *raidPtr, void * 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 @@ rf_get_component_label80(RF_Raid_t *raid * 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 @@ rf_config80(struct raid_softc *rs, void /* 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 @@ rf_config80(struct raid_softc *rs, void 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); } Index: src/sys/dev/raidframe/rf_copyback.c diff -u src/sys/dev/raidframe/rf_copyback.c:1.50 src/sys/dev/raidframe/rf_copyback.c:1.51 --- src/sys/dev/raidframe/rf_copyback.c:1.50 Sat Jun 14 03:39:00 2014 +++ src/sys/dev/raidframe/rf_copyback.c Fri Feb 8 22:33:59 2019 @@ -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 @@ rf_CopybackReconstructedData(RF_Raid_t * 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)); /* create a descriptor */ - RF_Malloc(desc, sizeof(*desc), (RF_CopybackDesc_t *)); + desc = RF_Malloc(sizeof(*desc)); desc->raidPtr = raidPtr; desc->status = 0; desc->fcol = fcol; Index: src/sys/dev/raidframe/rf_cvscan.c diff -u src/sys/dev/raidframe/rf_cvscan.c:1.16 src/sys/dev/raidframe/rf_cvscan.c:1.17 --- src/sys/dev/raidframe/rf_cvscan.c:1.16 Wed Aug 31 14:31:02 2011 +++ src/sys/dev/raidframe/rf_cvscan.c Fri Feb 8 22:33:59 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_cvscan.c,v 1.16 2011/08/31 18:31:02 plunky Exp $ */ +/* $NetBSD: rf_cvscan.c,v 1.17 2019/02/09 03:33:59 christos Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -35,7 +35,7 @@ ******************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_cvscan.c,v 1.16 2011/08/31 18:31:02 plunky Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_cvscan.c,v 1.17 2019/02/09 03:33:59 christos Exp $"); #include <dev/raidframe/raidframevar.h> #include "rf_alloclist.h" @@ -326,8 +326,7 @@ rf_CvscanCreate(RF_SectorCount_t sectPer long range = 2; /* Currently no mechanism to change these */ long penalty = sectPerDisk / 5; - RF_MallocAndAdd(hdr, sizeof(RF_CvscanHeader_t), (RF_CvscanHeader_t *), clList); - memset((char *) hdr, 0, sizeof(RF_CvscanHeader_t)); + hdr = RF_MallocAndAdd(sizeof(*hdr), clList); hdr->range_for_avg = RF_MAX(range, 1); hdr->change_penalty = RF_MAX(penalty, 0); hdr->direction = rf_cvscan_RIGHT; Index: src/sys/dev/raidframe/rf_declusterPQ.c diff -u src/sys/dev/raidframe/rf_declusterPQ.c:1.16 src/sys/dev/raidframe/rf_declusterPQ.c:1.17 --- src/sys/dev/raidframe/rf_declusterPQ.c:1.16 Sun Mar 23 05:30:59 2014 +++ src/sys/dev/raidframe/rf_declusterPQ.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_declusterPQ.c,v 1.16 2014/03/23 09:30:59 christos Exp $ */ +/* $NetBSD: rf_declusterPQ.c,v 1.17 2019/02/09 03:34:00 christos Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -35,7 +35,7 @@ *--------------------------------------------------*/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_declusterPQ.c,v 1.16 2014/03/23 09:30:59 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_declusterPQ.c,v 1.17 2019/02/09 03:34:00 christos Exp $"); #include <dev/raidframe/raidframevar.h> @@ -87,7 +87,7 @@ rf_ConfigureDeclusteredPQ(RF_ShutdownLis return (EINVAL); } /* 1. create layout specific structure */ - RF_MallocAndAdd(info, sizeof(RF_DeclusteredConfigInfo_t), (RF_DeclusteredConfigInfo_t *), raidPtr->cleanupList); + info = RF_MallocAndAdd(sizeof(*info), raidPtr->cleanupList); if (info == NULL) return (ENOMEM); layoutPtr->layoutSpecificInfo = (void *) info; Index: src/sys/dev/raidframe/rf_sstf.c diff -u src/sys/dev/raidframe/rf_sstf.c:1.16 src/sys/dev/raidframe/rf_sstf.c:1.17 --- src/sys/dev/raidframe/rf_sstf.c:1.16 Sat Mar 14 11:36:20 2009 +++ src/sys/dev/raidframe/rf_sstf.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_sstf.c,v 1.16 2009/03/14 15:36:20 dsl Exp $ */ +/* $NetBSD: rf_sstf.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_sstf.c,v 1.16 2009/03/14 15:36:20 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_sstf.c,v 1.17 2019/02/09 03:34:00 christos Exp $"); #include <dev/raidframe/raidframevar.h> @@ -246,7 +246,7 @@ rf_SstfCreate( { RF_Sstf_t *sstfq; - RF_MallocAndAdd(sstfq, sizeof(RF_Sstf_t), (RF_Sstf_t *), cl_list); + sstfq = RF_MallocAndAdd(sizeof(*sstfq), cl_list); sstfq->dir = DIR_EITHER; sstfq->allow_reverse = 1; return ((void *) sstfq); @@ -260,7 +260,7 @@ rf_ScanCreate( { RF_Sstf_t *scanq; - RF_MallocAndAdd(scanq, sizeof(RF_Sstf_t), (RF_Sstf_t *), cl_list); + scanq = RF_MallocAndAdd(sizeof(*scanq), cl_list); scanq->dir = DIR_RIGHT; scanq->allow_reverse = 1; return ((void *) scanq); @@ -274,7 +274,7 @@ rf_CscanCreate( { RF_Sstf_t *cscanq; - RF_MallocAndAdd(cscanq, sizeof(RF_Sstf_t), (RF_Sstf_t *), cl_list); + cscanq = RF_MallocAndAdd(sizeof(*cscanq), cl_list); cscanq->dir = DIR_RIGHT; return ((void *) cscanq); } Index: src/sys/dev/raidframe/rf_utils.c diff -u src/sys/dev/raidframe/rf_utils.c:1.16 src/sys/dev/raidframe/rf_utils.c:1.17 --- src/sys/dev/raidframe/rf_utils.c:1.16 Wed Nov 15 20:33:23 2006 +++ src/sys/dev/raidframe/rf_utils.c Fri Feb 8 22:34:00 2019 @@ -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_AllocL { 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 { 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); } Index: src/sys/dev/raidframe/rf_dagdegrd.c diff -u src/sys/dev/raidframe/rf_dagdegrd.c:1.29 src/sys/dev/raidframe/rf_dagdegrd.c:1.30 --- src/sys/dev/raidframe/rf_dagdegrd.c:1.29 Sun Sep 15 08:13:56 2013 +++ src/sys/dev/raidframe/rf_dagdegrd.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_dagdegrd.c,v 1.29 2013/09/15 12:13:56 martin Exp $ */ +/* $NetBSD: rf_dagdegrd.c,v 1.30 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_dagdegrd.c,v 1.29 2013/09/15 12:13:56 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_dagdegrd.c,v 1.30 2019/02/09 03:34:00 christos Exp $"); #include <dev/raidframe/raidframevar.h> @@ -605,7 +605,7 @@ rf_CreateRaidCDegradedReadDAG(RF_Raid_t useMirror = RF_TRUE; /* total number of nodes = 1 + (block + commit + terminator) */ - RF_MallocAndAdd(nodes, 4 * sizeof(RF_DagNode_t), (RF_DagNode_t *), allocList); + nodes = RF_MallocAndAdd(4 * sizeof(*nodes), allocList); i = 0; rdNode = &nodes[i]; i++; @@ -724,17 +724,19 @@ rf_DD_GenerateFailedAccessASMs(RF_Raid_t fone_start = rf_StripeUnitOffset(layoutPtr, fone->startSector); fone_end = fone_start + fone->numSector; +#define BUF_ALLOC(num) \ + RF_MallocAndAdd(rf_RaidAddressToByte(raidPtr, num), allocList) #define CONS_PDA(if,start,num) \ pda_p->col = asmap->if->col; \ pda_p->startSector = ((asmap->if->startSector / secPerSU) * secPerSU) + start; \ pda_p->numSector = num; \ pda_p->next = NULL; \ - RF_MallocAndAdd(pda_p->bufPtr,rf_RaidAddressToByte(raidPtr,num),(char *), allocList) + pda_p->bufPtr = BUF_ALLOC(num) if (asmap->numDataFailed == 1) { PDAPerDisk = 1; state = 1; - RF_MallocAndAdd(*pqpdap, 2 * sizeof(RF_PhysDiskAddr_t), (RF_PhysDiskAddr_t *), allocList); + *pqpdap = RF_MallocAndAdd(2 * sizeof(**pqpdap), allocList); pda_p = *pqpdap; /* build p */ CONS_PDA(parityInfo, fone_start, fone->numSector); @@ -749,7 +751,7 @@ rf_DD_GenerateFailedAccessASMs(RF_Raid_t if (fone->numSector + ftwo->numSector > secPerSU) { PDAPerDisk = 1; state = 2; - RF_MallocAndAdd(*pqpdap, 2 * sizeof(RF_PhysDiskAddr_t), (RF_PhysDiskAddr_t *), allocList); + *pqpdap = RF_MallocAndAdd(2 * sizeof(**pqpdap), allocList); pda_p = *pqpdap; CONS_PDA(parityInfo, 0, secPerSU); pda_p->type = RF_PDA_TYPE_PARITY; @@ -760,7 +762,7 @@ rf_DD_GenerateFailedAccessASMs(RF_Raid_t PDAPerDisk = 2; state = 3; /* four of them, fone, then ftwo */ - RF_MallocAndAdd(*pqpdap, 4 * sizeof(RF_PhysDiskAddr_t), (RF_PhysDiskAddr_t *), allocList); + *pqpdap = RF_MallocAndAdd(4 * sizeof(**pqpdap), allocList); pda_p = *pqpdap; CONS_PDA(parityInfo, fone_start, fone->numSector); pda_p->type = RF_PDA_TYPE_PARITY; @@ -819,8 +821,7 @@ rf_DD_GenerateFailedAccessASMs(RF_Raid_t /* allocate up our list of pda's */ - RF_MallocAndAdd(pda_p, napdas * sizeof(RF_PhysDiskAddr_t), - (RF_PhysDiskAddr_t *), allocList); + pda_p = RF_MallocAndAdd(napdas * sizeof(*pdap), allocList); *pdap = pda_p; /* linkem together */ @@ -844,17 +845,17 @@ rf_DD_GenerateFailedAccessASMs(RF_Raid_t pda_p->numSector = fone->numSector; pda_p->raidAddress += fone_start; pda_p->startSector += fone_start; - RF_MallocAndAdd(pda_p->bufPtr, rf_RaidAddressToByte(raidPtr, pda_p->numSector), (char *), allocList); + pda_p->bufPtr = BUF_ALLOC(pda_p->numSector); break; case 2: /* full stripe */ pda_p->numSector = secPerSU; - RF_MallocAndAdd(pda_p->bufPtr, rf_RaidAddressToByte(raidPtr, secPerSU), (char *), allocList); + pda_p->bufPtr = BUF_ALLOC(secPerSU); break; case 3: /* two slabs */ pda_p->numSector = fone->numSector; pda_p->raidAddress += fone_start; pda_p->startSector += fone_start; - RF_MallocAndAdd(pda_p->bufPtr, rf_RaidAddressToByte(raidPtr, pda_p->numSector), (char *), allocList); + pda_p->bufPtr = BUF_ALLOC(pda_p->numSector); pda_p++; pda_p->type = RF_PDA_TYPE_DATA; pda_p->raidAddress = sosAddr + (i * secPerSU); @@ -862,7 +863,7 @@ rf_DD_GenerateFailedAccessASMs(RF_Raid_t pda_p->numSector = ftwo->numSector; pda_p->raidAddress += ftwo_start; pda_p->startSector += ftwo_start; - RF_MallocAndAdd(pda_p->bufPtr, rf_RaidAddressToByte(raidPtr, pda_p->numSector), (char *), allocList); + pda_p->bufPtr = BUF_ALLOC(pda_p->numSector); break; default: RF_PANIC(); @@ -885,7 +886,7 @@ rf_DD_GenerateFailedAccessASMs(RF_Raid_t pda_p->numSector = suoff - fone_start; pda_p->raidAddress = sosAddr + (i * secPerSU) + fone_start; (raidPtr->Layout.map->MapSector) (raidPtr, pda_p->raidAddress, &(pda_p->col), &(pda_p->startSector), 0); - RF_MallocAndAdd(pda_p->bufPtr, rf_RaidAddressToByte(raidPtr, pda_p->numSector), (char *), allocList); + pda_p->bufPtr = BUF_ALLOC(pda_p->numSector); pda_p++; } if (suend < fone_end) { @@ -895,7 +896,7 @@ rf_DD_GenerateFailedAccessASMs(RF_Raid_t pda_p->numSector = fone_end - suend; pda_p->raidAddress = sosAddr + (i * secPerSU) + suend; /* off by one? */ (raidPtr->Layout.map->MapSector) (raidPtr, pda_p->raidAddress, &(pda_p->col), &(pda_p->startSector), 0); - RF_MallocAndAdd(pda_p->bufPtr, rf_RaidAddressToByte(raidPtr, pda_p->numSector), (char *), allocList); + pda_p->bufPtr = BUF_ALLOC(pda_p->numSector); pda_p++; } break; @@ -906,14 +907,15 @@ rf_DD_GenerateFailedAccessASMs(RF_Raid_t pda_p->numSector = secPerSU - suend; pda_p->raidAddress = sosAddr + (i * secPerSU) + suend; /* off by one? */ (raidPtr->Layout.map->MapSector) (raidPtr, pda_p->raidAddress, &(pda_p->col), &(pda_p->startSector), 0); - RF_MallocAndAdd(pda_p->bufPtr, rf_RaidAddressToByte(raidPtr, pda_p->numSector), (char *), allocList); + pda_p->bufPtr = BUF_ALLOC(pda_p->numSector); pda_p++; } else if (suoff > 0) { /* short at front */ pda_p->numSector = suoff; pda_p->raidAddress = sosAddr + (i * secPerSU); (raidPtr->Layout.map->MapSector) (raidPtr, pda_p->raidAddress, &(pda_p->col), &(pda_p->startSector), 0); - RF_MallocAndAdd(pda_p->bufPtr, rf_RaidAddressToByte(raidPtr, pda_p->numSector), (char *), allocList); + pda_p->bufPtr = + BUF_ALLOC(pda_p->numSector); pda_p++; } break; @@ -927,7 +929,8 @@ rf_DD_GenerateFailedAccessASMs(RF_Raid_t pda_p->numSector = suoff - fone_start; pda_p->raidAddress = sosAddr + (i * secPerSU) + fone_start; (raidPtr->Layout.map->MapSector) (raidPtr, pda_p->raidAddress, &(pda_p->col), &(pda_p->startSector), 0); - RF_MallocAndAdd(pda_p->bufPtr, rf_RaidAddressToByte(raidPtr, pda_p->numSector), (char *), allocList); + pda_p->bufPtr = + BUF_ALLOC(pda_p->numSector); pda_p++; } if (suend < fone_end) { @@ -937,7 +940,8 @@ rf_DD_GenerateFailedAccessASMs(RF_Raid_t pda_p->numSector = fone_end - suend; pda_p->raidAddress = sosAddr + (i * secPerSU) + suend; /* off by one? */ (raidPtr->Layout.map->MapSector) (raidPtr, pda_p->raidAddress, &(pda_p->col), &(pda_p->startSector), 0); - RF_MallocAndAdd(pda_p->bufPtr, rf_RaidAddressToByte(raidPtr, pda_p->numSector), (char *), allocList); + pda_p->bufPtr = + BUF_ALLOC(pda_p->numSector); pda_p++; } } @@ -950,7 +954,8 @@ rf_DD_GenerateFailedAccessASMs(RF_Raid_t pda_p->numSector = suoff - ftwo_start; pda_p->raidAddress = sosAddr + (i * secPerSU) + ftwo_start; (raidPtr->Layout.map->MapSector) (raidPtr, pda_p->raidAddress, &(pda_p->col), &(pda_p->startSector), 0); - RF_MallocAndAdd(pda_p->bufPtr, rf_RaidAddressToByte(raidPtr, pda_p->numSector), (char *), allocList); + pda_p->bufPtr = + BUF_ALLOC(pda_p->numSector); pda_p++; } if (suend < ftwo_end) { @@ -960,7 +965,8 @@ rf_DD_GenerateFailedAccessASMs(RF_Raid_t pda_p->numSector = ftwo_end - suend; pda_p->raidAddress = sosAddr + (i * secPerSU) + suend; /* off by one? */ (raidPtr->Layout.map->MapSector) (raidPtr, pda_p->raidAddress, &(pda_p->col), &(pda_p->startSector), 0); - RF_MallocAndAdd(pda_p->bufPtr, rf_RaidAddressToByte(raidPtr, pda_p->numSector), (char *), allocList); + pda_p->bufPtr = + BUF_ALLOC(pda_p->numSector); pda_p++; } } @@ -985,17 +991,17 @@ rf_DD_GenerateFailedAccessASMs(RF_Raid_t pda_p->numSector = fone->numSector; pda_p->raidAddress += fone_start; pda_p->startSector += fone_start; - RF_MallocAndAdd(pda_p->bufPtr, rf_RaidAddressToByte(raidPtr, pda_p->numSector), (char *), allocList); + pda_p->bufPtr = BUF_ALLOC(pda_p->numSector); break; case 2: /* full stripe */ pda_p->numSector = secPerSU; - RF_MallocAndAdd(pda_p->bufPtr, rf_RaidAddressToByte(raidPtr, secPerSU), (char *), allocList); + pda_p->bufPtr = BUF_ALLOC(secPerSU); break; case 3: /* two slabs */ pda_p->numSector = fone->numSector; pda_p->raidAddress += fone_start; pda_p->startSector += fone_start; - RF_MallocAndAdd(pda_p->bufPtr, rf_RaidAddressToByte(raidPtr, pda_p->numSector), (char *), allocList); + pda_p->bufPtr = BUF_ALLOC(pda_p->numSector); pda_p++; pda_p->type = RF_PDA_TYPE_DATA; pda_p->raidAddress = sosAddr + (i * secPerSU); @@ -1003,7 +1009,7 @@ rf_DD_GenerateFailedAccessASMs(RF_Raid_t pda_p->numSector = ftwo->numSector; pda_p->raidAddress += ftwo_start; pda_p->startSector += ftwo_start; - RF_MallocAndAdd(pda_p->bufPtr, rf_RaidAddressToByte(raidPtr, pda_p->numSector), (char *), allocList); + pda_p->bufPtr = BUF_ALLOC(pda_p->numSector); break; default: RF_PANIC(); @@ -1058,7 +1064,7 @@ rf_DoubleDegRead(RF_Raid_t *raidPtr, RF_ nReadNodes = nRrdNodes + nRudNodes + 2 * nPQNodes; nNodes = 4 /* block, unblock, recovery, term */ + nReadNodes; - RF_MallocAndAdd(nodes, nNodes * sizeof(RF_DagNode_t), (RF_DagNode_t *), allocList); + nodes = RF_MallocAndAdd(nNodes * sizeof(*nodes), allocList); i = 0; blockNode = &nodes[i]; i += 1; Index: src/sys/dev/raidframe/rf_dagdegwr.c diff -u src/sys/dev/raidframe/rf_dagdegwr.c:1.33 src/sys/dev/raidframe/rf_dagdegwr.c:1.34 --- src/sys/dev/raidframe/rf_dagdegwr.c:1.33 Sat Mar 22 23:42:39 2014 +++ src/sys/dev/raidframe/rf_dagdegwr.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_dagdegwr.c,v 1.33 2014/03/23 03:42:39 christos Exp $ */ +/* $NetBSD: rf_dagdegwr.c,v 1.34 2019/02/09 03:34:00 christos Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_dagdegwr.c,v 1.33 2014/03/23 03:42:39 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_dagdegwr.c,v 1.34 2019/02/09 03:34:00 christos Exp $"); #include <dev/raidframe/raidframevar.h> @@ -116,6 +116,8 @@ rf_CreateDegradedWriteDAG(RF_Raid_t *rai * * DAG creation code begins here */ +#define BUF_ALLOC(num) \ + RF_MallocAndAdd(rf_RaidAddressToByte(raidPtr, num), allocList) @@ -380,8 +382,8 @@ rf_CommonCreateSimpleDegradedWriteDAG(RF /* fill in the Wnq Node */ if (nfaults == 2) { { - RF_MallocAndAdd(parityPDA, sizeof(RF_PhysDiskAddr_t), - (RF_PhysDiskAddr_t *), allocList); + parityPA = RF_MallocAndAdd(sizeof(*parityPA), + allocList); parityPDA->col = asmap->qInfo->col; parityPDA->startSector = ((asmap->qInfo->startSector / sectorsPerSU) * sectorsPerSU) + (failedPDA->startSector % sectorsPerSU); @@ -390,8 +392,7 @@ rf_CommonCreateSimpleDegradedWriteDAG(RF rf_InitNode(wnqNode, rf_wait, RF_FALSE, rf_DiskWriteFunc, rf_DiskWriteUndoFunc, rf_GenericWakeupFunc, 1, 1, 4, 0, dag_h, "Wnq", allocList); wnqNode->params[0].p = parityPDA; - RF_MallocAndAdd(xorNode->results[1], - rf_RaidAddressToByte(raidPtr, failedPDA->numSector), (char *), allocList); + xorNode->results[1] = BUF_ALLOC(failedPDA->numSector); wnqNode->params[1].p = xorNode->results[1]; wnqNode->params[2].v = parityStripeID; wnqNode->params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); @@ -564,7 +565,7 @@ rf_CommonCreateSimpleDegradedWriteDAG(RF pda_p->startSector = ((asmap->if->startSector / secPerSU) * secPerSU) + start; \ pda_p->numSector = num; \ pda_p->next = NULL; \ - RF_MallocAndAdd(pda_p->bufPtr,rf_RaidAddressToByte(raidPtr,num),(char *), allocList) + pda_p->bufPtr = BUF_ALLOC(num) #if (RF_INCLUDE_PQ > 0) || (RF_INCLUDE_EVENODD > 0) void rf_WriteGenerateFailedAccessASMs( @@ -596,7 +597,7 @@ rf_WriteGenerateFailedAccessASMs( if (asmap->numDataFailed == 1) { PDAPerDisk = 1; state = 1; - RF_MallocAndAdd(*pqpdap, 2 * sizeof(RF_PhysDiskAddr_t), (RF_PhysDiskAddr_t *), allocList); + *pqpdap = RF_MallocAndAdd(2 * sizeof(**pqpdap), allocList); pda_p = *pqpdap; /* build p */ CONS_PDA(parityInfo, fone_start, fone->numSector); @@ -610,7 +611,8 @@ rf_WriteGenerateFailedAccessASMs( if (fone->numSector + ftwo->numSector > secPerSU) { PDAPerDisk = 1; state = 2; - RF_MallocAndAdd(*pqpdap, 2 * sizeof(RF_PhysDiskAddr_t), (RF_PhysDiskAddr_t *), allocList); + *pqpdap = RF_MallocAndAdd(2 * sizeof(**pqpdap), + allocList); pda_p = *pqpdap; CONS_PDA(parityInfo, 0, secPerSU); pda_p->type = RF_PDA_TYPE_PARITY; @@ -621,7 +623,8 @@ rf_WriteGenerateFailedAccessASMs( PDAPerDisk = 2; state = 3; /* four of them, fone, then ftwo */ - RF_MallocAndAdd(*pqpdap, 4 * sizeof(RF_PhysDiskAddr_t), (RF_PhysDiskAddr_t *), allocList); + *pqpdap = RF_MallocAndAdd(4 * sizeof(*pqpdap), + allocList); pda_p = *pqpdap; CONS_PDA(parityInfo, fone_start, fone->numSector); pda_p->type = RF_PDA_TYPE_PARITY; @@ -646,8 +649,7 @@ rf_WriteGenerateFailedAccessASMs( /* allocate up our list of pda's */ - RF_MallocAndAdd(pda_p, napdas * sizeof(RF_PhysDiskAddr_t), - (RF_PhysDiskAddr_t *), allocList); + pda_p = RF_MallocAndAdd(napdas * sizeof(*pda_p), allocList); *pdap = pda_p; /* linkem together */ @@ -669,17 +671,17 @@ rf_WriteGenerateFailedAccessASMs( pda_p->numSector = fone->numSector; pda_p->raidAddress += fone_start; pda_p->startSector += fone_start; - RF_MallocAndAdd(pda_p->bufPtr, rf_RaidAddressToByte(raidPtr, pda_p->numSector), (char *), allocList); + pda_p->bufPtr = BUF_ALLOC(pda_p->numSector); break; case 2: /* full stripe */ pda_p->numSector = secPerSU; - RF_MallocAndAdd(pda_p->bufPtr, rf_RaidAddressToByte(raidPtr, secPerSU), (char *), allocList); + pda_p->bufPtr = BUF_ALLOC(secPerSU); break; case 3: /* two slabs */ pda_p->numSector = fone->numSector; pda_p->raidAddress += fone_start; pda_p->startSector += fone_start; - RF_MallocAndAdd(pda_p->bufPtr, rf_RaidAddressToByte(raidPtr, pda_p->numSector), (char *), allocList); + pda_p->bufPtr = BUF_ALLOC(pda_p->numSector); pda_p++; pda_p->type = RF_PDA_TYPE_DATA; pda_p->raidAddress = sosAddr + (i * secPerSU); @@ -687,7 +689,7 @@ rf_WriteGenerateFailedAccessASMs( pda_p->numSector = ftwo->numSector; pda_p->raidAddress += ftwo_start; pda_p->startSector += ftwo_start; - RF_MallocAndAdd(pda_p->bufPtr, rf_RaidAddressToByte(raidPtr, pda_p->numSector), (char *), allocList); + pda_p->bufPtr = BUF_ALLOC(pda_p->numSector); break; default: RF_PANIC(); @@ -750,7 +752,7 @@ rf_DoubleDegSmallWrite(RF_Raid_t *raidPt nWriteNodes = nWudNodes + 2 * nPQNodes; nNodes = 4 + nReadNodes + nWriteNodes; - RF_MallocAndAdd(nodes, nNodes * sizeof(RF_DagNode_t), (RF_DagNode_t *), allocList); + nodes = RF_MallocAndAdd(nNodes * sizeof(*nodes), allocList); blockNode = nodes; unblockNode = blockNode + 1; termNode = unblockNode + 1; Index: src/sys/dev/raidframe/rf_dagffwr.c diff -u src/sys/dev/raidframe/rf_dagffwr.c:1.34 src/sys/dev/raidframe/rf_dagffwr.c:1.35 --- src/sys/dev/raidframe/rf_dagffwr.c:1.34 Sun Sep 15 08:41:17 2013 +++ src/sys/dev/raidframe/rf_dagffwr.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_dagffwr.c,v 1.34 2013/09/15 12:41:17 martin Exp $ */ +/* $NetBSD: rf_dagffwr.c,v 1.35 2019/02/09 03:34:00 christos Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_dagffwr.c,v 1.34 2013/09/15 12:41:17 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_dagffwr.c,v 1.35 2019/02/09 03:34:00 christos Exp $"); #include <dev/raidframe/raidframevar.h> @@ -125,6 +125,8 @@ rf_CreateLargeWriteDAG(RF_Raid_t *raidPt * * DAG creation code begins here */ +#define BUF_ALLOC(num) \ + RF_MallocAndAdd(rf_RaidAddressToByte(raidPtr, num), allocList) /****************************************************************************** @@ -382,9 +384,8 @@ rf_CommonCreateLargeWriteDAG(RF_Raid_t * * to get smashed during the P and Q calculation, guaranteeing * one would be wrong. */ - RF_MallocAndAdd(xorNode->results[1], - rf_RaidAddressToByte(raidPtr, raidPtr->Layout.sectorsPerStripeUnit), - (void *), allocList); + xorNode->results[1] = + BUF_ALLOC(raidPtr->Layout.sectorsPerStripeUnit); rf_InitNode(wnqNode, rf_wait, RF_FALSE, rf_DiskWriteFunc, rf_DiskWriteUndoFunc, rf_GenericWakeupFunc, 1, 1, 4, 0, dag_h, "Wnq", allocList); Index: src/sys/dev/raidframe/rf_paritylogging.c diff -u src/sys/dev/raidframe/rf_paritylogging.c:1.34 src/sys/dev/raidframe/rf_paritylogging.c:1.35 --- src/sys/dev/raidframe/rf_paritylogging.c:1.34 Wed May 11 02:20:33 2011 +++ src/sys/dev/raidframe/rf_paritylogging.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_paritylogging.c,v 1.34 2011/05/11 06:20:33 mrg Exp $ */ +/* $NetBSD: rf_paritylogging.c,v 1.35 2019/02/09 03:34:00 christos Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_paritylogging.c,v 1.34 2011/05/11 06:20:33 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_paritylogging.c,v 1.35 2019/02/09 03:34:00 christos Exp $"); #include "rf_archs.h" @@ -97,9 +97,7 @@ rf_ConfigureParityLogging( raidPtr->numSectorsPerLog = RF_DEFAULT_NUM_SECTORS_PER_LOG; /* create a parity logging configuration structure */ - RF_MallocAndAdd(info, sizeof(RF_ParityLoggingConfigInfo_t), - (RF_ParityLoggingConfigInfo_t *), - raidPtr->cleanupList); + info = RF_MallocAndAdd(sizeof(*info), raidPtr->cleanupList); if (info == NULL) return (ENOMEM); layoutPtr->layoutSpecificInfo = (void *) info; @@ -202,9 +200,8 @@ rf_ConfigureParityLogging( /* create region information structs */ printf("Allocating %d bytes for in-core parity region info\n", (int) (rf_numParityRegions * sizeof(RF_RegionInfo_t))); - RF_Malloc(raidPtr->regionInfo, - (rf_numParityRegions * sizeof(RF_RegionInfo_t)), - (RF_RegionInfo_t *)); + raidPtr->regionInfo = RF_Malloc( + rf_numParityRegions * sizeof(*raidPtr->regionInfo)); if (raidPtr->regionInfo == NULL) return (ENOMEM); @@ -228,17 +225,17 @@ rf_ConfigureParityLogging( raidPtr->numParityLogs * raidPtr->numSectorsPerLog * raidPtr->bytesPerSector, raidPtr->numParityLogs); - RF_Malloc(raidPtr->parityLogBufferHeap, raidPtr->numParityLogs * - raidPtr->numSectorsPerLog * raidPtr->bytesPerSector, - (void *)); + raidPtr->parityLogBufferHeap = RF_Malloc(raidPtr->numParityLogs + * raidPtr->numSectorsPerLog * raidPtr->bytesPerSector); if (raidPtr->parityLogBufferHeap == NULL) return (ENOMEM); lHeapPtr = raidPtr->parityLogBufferHeap; rf_init_mutex2(raidPtr->parityLogPool.mutex, IPL_VM); for (i = 0; i < raidPtr->numParityLogs; i++) { if (i == 0) { - RF_Malloc(raidPtr->parityLogPool.parityLogs, - sizeof(RF_ParityLog_t), (RF_ParityLog_t *)); + raidPtr->parityLogPool.parityLogs = + RF_Malloc( + sizeof(*raidPtr->parityLogPool.parityLogs)); if (raidPtr->parityLogPool.parityLogs == NULL) { RF_Free(raidPtr->parityLogBufferHeap, raidPtr->numParityLogs * @@ -248,8 +245,7 @@ rf_ConfigureParityLogging( } l = raidPtr->parityLogPool.parityLogs; } else { - RF_Malloc(l->next, sizeof(RF_ParityLog_t), - (RF_ParityLog_t *)); + l->next = RF_Malloc(sizeof(*l->next)); if (l->next == NULL) { RF_Free(raidPtr->parityLogBufferHeap, raidPtr->numParityLogs * @@ -270,9 +266,8 @@ rf_ConfigureParityLogging( l->bufPtr = lHeapPtr; lHeapPtr = (char *)lHeapPtr + raidPtr->numSectorsPerLog * raidPtr->bytesPerSector; - RF_Malloc(l->records, (raidPtr->numSectorsPerLog * - sizeof(RF_ParityLogRecord_t)), - (RF_ParityLogRecord_t *)); + l->records = RF_Malloc(raidPtr->numSectorsPerLog * + sizeof(*l->records)); if (l->records == NULL) { RF_Free(raidPtr->parityLogBufferHeap, raidPtr->numParityLogs * @@ -310,9 +305,9 @@ rf_ConfigureParityLogging( printf("Allocating %d bytes for regionBufferPool\n", (int) (raidPtr->regionBufferPool.totalBuffers * sizeof(void *))); - RF_Malloc(raidPtr->regionBufferPool.buffers, - raidPtr->regionBufferPool.totalBuffers * sizeof(void *), - (void **)); + raidPtr->regionBufferPool.buffers = RF_Malloc( + raidPtr->regionBufferPool.totalBuffers * + sizeof(*raidPtr->regionBufferPool.buffers)); if (raidPtr->regionBufferPool.buffers == NULL) { return (ENOMEM); } @@ -320,9 +315,8 @@ rf_ConfigureParityLogging( printf("Allocating %d bytes for regionBufferPool#%d\n", (int) (raidPtr->regionBufferPool.bufferSize * sizeof(char)), i); - RF_Malloc(raidPtr->regionBufferPool.buffers[i], - raidPtr->regionBufferPool.bufferSize * sizeof(char), - (void *)); + raidPtr->regionBufferPool.buffers[i] = + RF_Malloc(raidPtr->regionBufferPool.bufferSize); if (raidPtr->regionBufferPool.buffers[i] == NULL) { for (j = 0; j < i; j++) { RF_Free(raidPtr->regionBufferPool.buffers[i], @@ -360,9 +354,9 @@ rf_ConfigureParityLogging( (int) (raidPtr->parityBufferPool.totalBuffers * sizeof(void *)), raidPtr->parityBufferPool.totalBuffers ); - RF_Malloc(raidPtr->parityBufferPool.buffers, - raidPtr->parityBufferPool.totalBuffers * sizeof(void *), - (void **)); + raidPtr->parityBufferPool.buffers = RF_Malloc( + raidPtr->parityBufferPool.totalBuffers * + sizeof(*raidPtr->parityBufferPool.buffers)); if (raidPtr->parityBufferPool.buffers == NULL) { return (ENOMEM); } @@ -370,9 +364,8 @@ rf_ConfigureParityLogging( printf("Allocating %d bytes for parityBufferPool#%d\n", (int) (raidPtr->parityBufferPool.bufferSize * sizeof(char)),i); - RF_Malloc(raidPtr->parityBufferPool.buffers[i], - raidPtr->parityBufferPool.bufferSize * sizeof(char), - (void *)); + raidPtr->parityBufferPool.buffers[i] = RF_Malloc( + raidPtr->parityBufferPool.bufferSize); if (raidPtr->parityBufferPool.buffers == NULL) { for (j = 0; j < i; j++) { RF_Free(raidPtr->parityBufferPool.buffers[i], @@ -443,10 +436,9 @@ rf_ConfigureParityLogging( printf("Allocating %d bytes for region %d\n", (int) (raidPtr->regionInfo[i].capacity * sizeof(RF_DiskMap_t)), i); - RF_Malloc(raidPtr->regionInfo[i].diskMap, - (raidPtr->regionInfo[i].capacity * - sizeof(RF_DiskMap_t)), - (RF_DiskMap_t *)); + raidPtr->regionInfo[i].diskMap = RF_Malloc( + raidPtr->regionInfo[i].capacity * + sizeof(*raidPtr->regionInfo[i].diskMap)); if (raidPtr->regionInfo[i].diskMap == NULL) { for (j = 0; j < i; j++) FreeRegionInfo(raidPtr, j); Index: src/sys/dev/raidframe/rf_parityscan.c diff -u src/sys/dev/raidframe/rf_parityscan.c:1.34 src/sys/dev/raidframe/rf_parityscan.c:1.35 --- src/sys/dev/raidframe/rf_parityscan.c:1.34 Sat Apr 30 21:09:05 2011 +++ src/sys/dev/raidframe/rf_parityscan.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_parityscan.c,v 1.34 2011/05/01 01:09:05 mrg Exp $ */ +/* $NetBSD: rf_parityscan.c,v 1.35 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_parityscan.c,v 1.34 2011/05/01 01:09:05 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_parityscan.c,v 1.35 2019/02/09 03:34:00 christos Exp $"); #include <dev/raidframe/raidframevar.h> @@ -220,8 +220,9 @@ rf_VerifyParityBasic(RF_Raid_t *raidPtr, mcpair = rf_AllocMCPair(); rf_MakeAllocList(alloclist); - RF_MallocAndAdd(bf, numbytes * (layoutPtr->numDataCol + layoutPtr->numParityCol), (char *), alloclist); - RF_MallocAndAdd(pbuf, numbytes, (char *), alloclist); + bf = RF_MallocAndAdd(numbytes + * (layoutPtr->numDataCol + layoutPtr->numParityCol), alloclist); + pbuf = RF_MallocAndAdd(numbytes, alloclist); end_p = bf + bytesPerStripe; rd_dag_h = rf_MakeSimpleDAG(raidPtr, stripeWidth, numbytes, bf, rf_DiskReadFunc, rf_DiskReadUndoFunc, @@ -253,7 +254,7 @@ rf_VerifyParityBasic(RF_Raid_t *raidPtr, /* fire off the DAG */ #if RF_ACC_TRACE > 0 - memset((char *) &tracerec, 0, sizeof(tracerec)); + memset(&tracerec, 0, sizeof(tracerec)); rd_dag_h->tracerec = &tracerec; #endif #if 0 @@ -299,7 +300,7 @@ rf_VerifyParityBasic(RF_Raid_t *raidPtr, wrBlock->succedents[0]->params[2].v = psID; wrBlock->succedents[0]->params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); #if RF_ACC_TRACE > 0 - memset((char *) &tracerec, 0, sizeof(tracerec)); + memset(&tracerec, 0, sizeof(tracerec)); wr_dag_h->tracerec = &tracerec; #endif #if 0 Index: src/sys/dev/raidframe/rf_psstatus.c diff -u src/sys/dev/raidframe/rf_psstatus.c:1.34 src/sys/dev/raidframe/rf_psstatus.c:1.35 --- src/sys/dev/raidframe/rf_psstatus.c:1.34 Tue May 3 04:18:43 2011 +++ src/sys/dev/raidframe/rf_psstatus.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_psstatus.c,v 1.34 2011/05/03 08:18:43 mrg Exp $ */ +/* $NetBSD: rf_psstatus.c,v 1.35 2019/02/09 03:34:00 christos Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -37,7 +37,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_psstatus.c,v 1.34 2011/05/03 08:18:43 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_psstatus.c,v 1.35 2019/02/09 03:34:00 christos Exp $"); #include <dev/raidframe/raidframevar.h> @@ -102,9 +102,7 @@ rf_MakeParityStripeStatusTable(RF_Raid_t RF_PSStatusHeader_t *pssTable; int i; - RF_Malloc(pssTable, - raidPtr->pssTableSize * sizeof(RF_PSStatusHeader_t), - (RF_PSStatusHeader_t *)); + pssTable = RF_Malloc(raidPtr->pssTableSize * sizeof(*pssTable)); for (i = 0; i < raidPtr->pssTableSize; i++) { rf_init_mutex2(pssTable[i].mutex, IPL_VM); rf_init_cond2(pssTable[i].cond, "rfpsslk"); @@ -272,7 +270,7 @@ rf_AllocPSStatus(RF_Raid_t *raidPtr) RF_ReconParityStripeStatus_t *p; p = pool_get(&rf_pools.pss, PR_WAITOK); - memset(p, 0, sizeof(RF_ReconParityStripeStatus_t)); + memset(p, 0, sizeof(*p)); return (p); } Index: src/sys/dev/raidframe/rf_dagutils.c diff -u src/sys/dev/raidframe/rf_dagutils.c:1.54 src/sys/dev/raidframe/rf_dagutils.c:1.55 --- src/sys/dev/raidframe/rf_dagutils.c:1.54 Thu Jan 7 16:57:00 2016 +++ src/sys/dev/raidframe/rf_dagutils.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_dagutils.c,v 1.54 2016/01/07 21:57:00 joerg Exp $ */ +/* $NetBSD: rf_dagutils.c,v 1.55 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_dagutils.c,v 1.54 2016/01/07 21:57:00 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_dagutils.c,v 1.55 2019/02/09 03:34:00 christos Exp $"); #include <dev/raidframe/raidframevar.h> @@ -142,8 +142,7 @@ rf_InitNode(RF_DagNode_t *node, RF_NodeS node->big_dag_ptrs = rf_AllocDAGPCache(); ptrs = (void **) node->big_dag_ptrs; } else { - RF_MallocAndAdd(ptrs, nptrs * sizeof(void *), - (void **), alist); + ptrs = RF_MallocAndAdd(nptrs * sizeof(*ptrs), alist); } node->succedents = (nSucc) ? (RF_DagNode_t **) ptrs : NULL; node->antecedents = (nAnte) ? (RF_DagNode_t **) (ptrs + nSucc) : NULL; @@ -157,9 +156,8 @@ rf_InitNode(RF_DagNode_t *node, RF_NodeS node->big_dag_params = rf_AllocDAGPCache(); node->params = node->big_dag_params; } else { - RF_MallocAndAdd(node->params, - nParam * sizeof(RF_DagParam_t), - (RF_DagParam_t *), alist); + node->params = RF_MallocAndAdd( + nParam * sizeof(*node->params), alist); } } else { node->params = NULL; @@ -259,7 +257,7 @@ rf_AllocDAGHeader(void) RF_DagHeader_t *dh; dh = pool_get(&rf_pools.dagh, PR_WAITOK); - memset((char *) dh, 0, sizeof(RF_DagHeader_t)); + memset(dh, 0, sizeof(*dh)); return (dh); } @@ -275,7 +273,7 @@ rf_AllocDAGNode(void) RF_DagNode_t *node; node = pool_get(&rf_pools.dagnode, PR_WAITOK); - memset(node, 0, sizeof(RF_DagNode_t)); + memset(node, 0, sizeof(*node)); return (node); } @@ -297,7 +295,7 @@ rf_AllocDAGList(void) RF_DagList_t *dagList; dagList = pool_get(&rf_pools.daglist, PR_WAITOK); - memset(dagList, 0, sizeof(RF_DagList_t)); + memset(dagList, 0, sizeof(*dagList)); return (dagList); } @@ -330,7 +328,7 @@ rf_AllocFuncList(void) RF_FuncList_t *funcList; funcList = pool_get(&rf_pools.funclist, PR_WAITOK); - memset(funcList, 0, sizeof(RF_FuncList_t)); + memset(funcList, 0, sizeof(*funcList)); return (funcList); } @@ -853,10 +851,9 @@ rf_ValidateDAG(RF_DagHeader_t *dag_h) unvisited = dag_h->succedents[0]->visited; - RF_Malloc(scount, nodecount * sizeof(int), (int *)); - RF_Malloc(acount, nodecount * sizeof(int), (int *)); - RF_Malloc(nodes, nodecount * sizeof(RF_DagNode_t *), - (RF_DagNode_t **)); + scount = RF_Malloc(nodecount * sizeof(*scount)); + acount = RF_Malloc(nodecount * sizeof(*acount)); + nodes = RF_Malloc(nodecount * sizeof(*nodes)); for (i = 0; i < dag_h->numSuccedents; i++) { if ((dag_h->succedents[i]->visited == unvisited) && rf_ValidateBranch(dag_h->succedents[i], scount, Index: src/sys/dev/raidframe/rf_debugMem.c diff -u src/sys/dev/raidframe/rf_debugMem.c:1.21 src/sys/dev/raidframe/rf_debugMem.c:1.22 --- src/sys/dev/raidframe/rf_debugMem.c:1.21 Sun May 1 02:49:43 2011 +++ src/sys/dev/raidframe/rf_debugMem.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_debugMem.c,v 1.21 2011/05/01 06:49:43 mrg Exp $ */ +/* $NetBSD: rf_debugMem.c,v 1.22 2019/02/09 03:34:00 christos Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_debugMem.c,v 1.21 2011/05/01 06:49:43 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_debugMem.c,v 1.22 2019/02/09 03:34:00 christos Exp $"); #include <dev/raidframe/raidframevar.h> @@ -44,16 +44,16 @@ __KERNEL_RCSID(0, "$NetBSD: rf_debugMem. #if RF_DEBUG_MEM -static long tot_mem_in_use = 0; +static size_t tot_mem_in_use = 0; /* Hash table of information about memory allocations */ #define RF_MH_TABLESIZE 1000 struct mh_struct { void *address; - int size; - int line; - const char *filen; + size_t size; + const char *file; + uint32_t line; char allocated; struct mh_struct *next; }; @@ -61,56 +61,63 @@ static struct mh_struct *mh_table[RF_MH_ static rf_declare_mutex2(rf_debug_mem_mutex); static int mh_table_initialized = 0; -static void memory_hash_insert(void *addr, int size, int line, const char *filen); -static int memory_hash_remove(void *addr, int sz); +static void memory_hash_insert(void *, size_t, const char *, uint32_t); +static int memory_hash_remove(void *, size_t); void -rf_record_malloc(void *p, int size, int line, const char *filen) +rf_record_malloc(void *p, size_t size, const char *file, uint32_t line) { RF_ASSERT(size != 0); /* rf_lock_mutex2(rf_debug_mem_mutex); */ - memory_hash_insert(p, size, line, filen); + memory_hash_insert(p, size, file, line); tot_mem_in_use += size; /* rf_unlock_mutex2(rf_debug_mem_mutex); */ - if ((long) p == rf_memDebugAddress) { - printf("Allocate: debug address allocated from line %d file %s\n", line, filen); + if ((intptr_t)p == rf_memDebugAddress) { + printf("%s,%d: %s: Debug address allocated\n", file, line, + __func__); } } void -rf_unrecord_malloc(void *p, int sz) +rf_unrecord_malloc(void *p, size_t sz) { - int size; + size_t size; /* rf_lock_mutex2(rf_debug_mem_mutex); */ size = memory_hash_remove(p, sz); tot_mem_in_use -= size; /* rf_unlock_mutex2(rf_debug_mem_mutex); */ - if ((long) p == rf_memDebugAddress) { - printf("Free: Found debug address\n"); /* this is really only a - * flag line for gdb */ + if ((intptr_t) p == rf_memDebugAddress) { + /* this is really only a flag line for gdb */ + printf("%s: Found debug address\n", __func__); } } void rf_print_unfreed(void) { - int i, foundone = 0; + size_t i; + int foundone = 0; struct mh_struct *p; for (i = 0; i < RF_MH_TABLESIZE; i++) { - for (p = mh_table[i]; p; p = p->next) - if (p->allocated) { - if (!foundone) - printf("\n\nThere are unfreed memory locations at program shutdown:\n"); - foundone = 1; - printf("Addr 0x%lx Size %d line %d file %s\n", - (long) p->address, p->size, p->line, p->filen); + for (p = mh_table[i]; p; p = p->next) { + if (!p->allocated) + continue; + if (foundone) { + printf("\n\n:%s: There are unfreed memory" + " locations at program shutdown:\n", + __func__); } + foundone = 1; + printf("%s: @%s,%d: addr %p size %zu\n", __func__, + p->file, p->line, p->address, p->size); + } } if (tot_mem_in_use) { - printf("%ld total bytes in use\n", tot_mem_in_use); + printf("%s: %zu total bytes in use\n", + __func__, tot_mem_in_use); } } #endif /* RF_DEBUG_MEM */ @@ -127,7 +134,7 @@ int rf_ConfigureDebugMem(RF_ShutdownList_t **listp) { #if RF_DEBUG_MEM - int i; + size_t i; rf_init_mutex2(rf_debug_mem_mutex, IPL_VM); if (rf_memDebug) { @@ -142,20 +149,21 @@ rf_ConfigureDebugMem(RF_ShutdownList_t * #if RF_DEBUG_MEM -#define HASHADDR(_a_) ( (((unsigned long) _a_)>>3) % RF_MH_TABLESIZE ) +#define HASHADDR(a) ((size_t)((((uintptr_t)a) >> 3) % RF_MH_TABLESIZE)) static void -memory_hash_insert(void *addr, int size, int line, const char *filen) +memory_hash_insert(void *addr, size_t size, const char *file, uint32_t line) { - unsigned long bucket = HASHADDR(addr); + size_t bucket = (size_t)HASHADDR(addr); struct mh_struct *p; RF_ASSERT(mh_table_initialized); /* search for this address in the hash table */ - for (p = mh_table[bucket]; p && (p->address != addr); p = p->next); + for (p = mh_table[bucket]; p && (p->address != addr); p = p->next) + continue; if (!p) { - RF_Malloc(p, sizeof(struct mh_struct), (struct mh_struct *)); + p = RF_Malloc(sizeof(*p)); RF_ASSERT(p); p->next = mh_table[bucket]; mh_table[bucket] = p; @@ -163,40 +171,48 @@ memory_hash_insert(void *addr, int size, p->allocated = 0; } if (p->allocated) { - printf("ERROR: reallocated address 0x%lx from line %d, file %s without intervening free\n", (long) addr, line, filen); - printf(" last allocated from line %d file %s\n", p->line, p->filen); + printf("%s: @%s,%u: ERROR: Reallocated addr %p without free\n", + __func__, file, line, addr); + printf("%s: last allocated @%s,%u\n", + __func__, p->file, p->line); RF_ASSERT(0); } p->size = size; p->line = line; - p->filen = filen; + p->file = file; p->allocated = 1; } static int -memory_hash_remove(void *addr, int sz) +memory_hash_remove(void *addr, size_t sz) { - unsigned long bucket = HASHADDR(addr); + size_t bucket = HASHADDR(addr); struct mh_struct *p; RF_ASSERT(mh_table_initialized); - for (p = mh_table[bucket]; p && (p->address != addr); p = p->next); + for (p = mh_table[bucket]; p && (p->address != addr); p = p->next) + continue; if (!p) { - printf("ERROR: freeing never-allocated address 0x%lx\n", (long) addr); + printf("%s: ERROR: Freeing never-allocated address %p\n", + __func__, addr); RF_PANIC(); } if (!p->allocated) { - printf("ERROR: freeing unallocated address 0x%lx. Last allocation line %d file %s\n", (long) addr, p->line, p->filen); + printf("%s: ERROR: Freeing unallocated address %p." + " Last allocation @%s,%u\n", + __func__, addr, p->file, p->line); RF_PANIC(); } if (sz > 0 && p->size != sz) { /* you can suppress this error by * using a negative value as the size * to free */ - printf("ERROR: incorrect size at free for address 0x%lx: is %d should be %d. Alloc at line %d of file %s\n", (unsigned long) addr, sz, p->size, p->line, p->filen); + printf("%s: ERROR: Incorrect size (%zu should be %zu) at" + " free for address %p. Allocated @%s,%u\n", __func__, + sz, p->size, addr, p->file, p->line); RF_PANIC(); } p->allocated = 0; - return (p->size); + return p->size; } #endif /* RF_DEBUG_MEM */ Index: src/sys/dev/raidframe/rf_evenodd.c diff -u src/sys/dev/raidframe/rf_evenodd.c:1.21 src/sys/dev/raidframe/rf_evenodd.c:1.22 --- src/sys/dev/raidframe/rf_evenodd.c:1.21 Sun Mar 23 05:30:59 2014 +++ src/sys/dev/raidframe/rf_evenodd.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_evenodd.c,v 1.21 2014/03/23 09:30:59 christos Exp $ */ +/* $NetBSD: rf_evenodd.c,v 1.22 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_evenodd.c,v 1.21 2014/03/23 09:30:59 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_evenodd.c,v 1.22 2019/02/09 03:34:00 christos Exp $"); #include "rf_archs.h" @@ -74,7 +74,7 @@ rf_ConfigureEvenOdd(RF_ShutdownList_t ** RF_EvenOddConfigInfo_t *info; RF_RowCol_t i, j, startdisk; - RF_MallocAndAdd(info, sizeof(RF_EvenOddConfigInfo_t), (RF_EvenOddConfigInfo_t *), raidPtr->cleanupList); + info = RF_MallocAndAdd(sizeof(*info), raidPtr->cleanupList); layoutPtr->layoutSpecificInfo = (void *) info; info->stripeIdentifier = rf_make_2d_array(raidPtr->numCol, raidPtr->numCol, raidPtr->cleanupList); @@ -358,10 +358,12 @@ rf_VerifyParityEvenOdd(RF_Raid_t *raidPt mcpair = rf_AllocMCPair(); rf_MakeAllocList(alloclist); - RF_MallocAndAdd(buf, numbytes * (layoutPtr->numDataCol + layoutPtr->numParityCol), (char *), alloclist); - RF_MallocAndAdd(pbuf, numbytes, (char *), alloclist); + buf = RF_MallocAndAdd( + numbytes * (layoutPtr->numDataCol + layoutPtr->numParityCol), + alloclist); + pbuf = RF_MallocAndAdd(numbytes, alloclist); end_p = buf + bytesPerStripe; - RF_MallocAndAdd(redundantbuf2, numbytes, (char *), alloclist); + redundantbuf2 = RF_MallocAndAdd(numbytes, alloclist); rd_dag_h = rf_MakeSimpleDAG(raidPtr, stripeWidth, numbytes, buf, rf_DiskReadFunc, rf_DiskReadUndoFunc, "Rod", alloclist, flags, RF_IO_NORMAL_PRIORITY); @@ -401,7 +403,7 @@ rf_VerifyParityEvenOdd(RF_Raid_t *raidPt blockNode->succedents[layoutPtr->numDataCol + 1]->params[0].p = asmap->qInfo; /* fire off the DAG */ - memset((char *) &tracerec, 0, sizeof(tracerec)); + memset(&tracerec, 0, sizeof(tracerec)); rd_dag_h->tracerec = &tracerec; #if RF_DEBUG_VALIDATE_DAG @@ -463,7 +465,7 @@ rf_VerifyParityEvenOdd(RF_Raid_t *raidPt wrBlock->succedents[0]->params[0].p = asmap->parityInfo; wrBlock->succedents[0]->params[2].v = psID; wrBlock->succedents[0]->params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); - memset((char *) &tracerec, 0, sizeof(tracerec)); + memset(&tracerec, 0, sizeof(tracerec)); wr_dag_h->tracerec = &tracerec; #if RF_DEBUG_VALIDATE_DAG if (rf_verifyParityDebug) { @@ -493,7 +495,7 @@ rf_VerifyParityEvenOdd(RF_Raid_t *raidPt wrBlock->succedents[0]->params[0].p = asmap->qInfo; wrBlock->succedents[0]->params[2].v = psID; wrBlock->succedents[0]->params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); - memset((char *) &tracerec, 0, sizeof(tracerec)); + memset(&tracerec, 0, sizeof(tracerec)); wr_dag_h->tracerec = &tracerec; #if RF_DEBUG_VALIDATE_DAG if (rf_verifyParityDebug) { Index: src/sys/dev/raidframe/rf_parityloggingdags.c diff -u src/sys/dev/raidframe/rf_parityloggingdags.c:1.21 src/sys/dev/raidframe/rf_parityloggingdags.c:1.22 --- src/sys/dev/raidframe/rf_parityloggingdags.c:1.21 Sun Mar 23 05:30:59 2014 +++ src/sys/dev/raidframe/rf_parityloggingdags.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_parityloggingdags.c,v 1.21 2014/03/23 09:30:59 christos Exp $ */ +/* $NetBSD: rf_parityloggingdags.c,v 1.22 2019/02/09 03:34:00 christos Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_parityloggingdags.c,v 1.21 2014/03/23 09:30:59 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_parityloggingdags.c,v 1.22 2019/02/09 03:34:00 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_raid_diagnostic.h" @@ -102,8 +102,7 @@ rf_CommonCreateParityLoggingLargeWriteDA /* alloc the Wnd nodes, the xor node, and the Lpo node */ nWndNodes = asmap->numStripeUnitsAccessed; - RF_MallocAndAdd(nodes, (nWndNodes + 6) * sizeof(RF_DagNode_t), - (RF_DagNode_t *), allocList); + nodes = RF_MallocAndAdd((nWndNodes + 6) * sizeof(*nodes), allocList); i = 0; wndNodes = &nodes[i]; i += nWndNodes; @@ -126,8 +125,8 @@ rf_CommonCreateParityLoggingLargeWriteDA rf_MapUnaccessedPortionOfStripe(raidPtr, layoutPtr, asmap, dag_h, new_asm_h, &nRodNodes, &sosBuffer, &eosBuffer, allocList); if (nRodNodes > 0) - RF_MallocAndAdd(rodNodes, nRodNodes * sizeof(RF_DagNode_t), - (RF_DagNode_t *), allocList); + rodNodes = RF_MallocAndAdd(nRodNodes * sizeof(*rodNodes), + allocList); /* begin node initialization */ rf_InitNode(blockNode, rf_wait, RF_FALSE, rf_NullNodeFunc, rf_NullNodeUndoFunc, NULL, nRodNodes + 1, 0, 0, 0, dag_h, "Nil", allocList); @@ -186,8 +185,8 @@ rf_CommonCreateParityLoggingLargeWriteDA if (((RF_PhysDiskAddr_t *) rodNodes[i].params[0].p)->numSector == raidPtr->Layout.sectorsPerStripeUnit) break; if (i == nRodNodes) { - RF_MallocAndAdd(xorNode->results[0], - rf_RaidAddressToByte(raidPtr, raidPtr->Layout.sectorsPerStripeUnit), (void *), allocList); + xorNode->results[0] = RF_MallocAndAdd(rf_RaidAddressToByte( + raidPtr, raidPtr->Layout.sectorsPerStripeUnit), allocList); } else { xorNode->results[0] = rodNodes[i].params[1].p; } @@ -368,8 +367,7 @@ rf_CommonCreateParityLoggingSmallWriteDA dag_h->numSuccedents = 1; /* Step 2. create the nodes */ - RF_MallocAndAdd(nodes, totalNumNodes * sizeof(RF_DagNode_t), - (RF_DagNode_t *), allocList); + nodes = RF_MallocAndAdd(totalNumNodes * sizeof(*nodes), allocList); i = 0; blockNode = &nodes[i]; i += 1; Index: src/sys/dev/raidframe/rf_debugMem.h diff -u src/sys/dev/raidframe/rf_debugMem.h:1.13 src/sys/dev/raidframe/rf_debugMem.h:1.14 --- src/sys/dev/raidframe/rf_debugMem.h:1.13 Sun May 1 02:49:43 2011 +++ src/sys/dev/raidframe/rf_debugMem.h Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_debugMem.h,v 1.13 2011/05/01 06:49:43 mrg Exp $ */ +/* $NetBSD: rf_debugMem.h,v 1.14 2019/02/09 03:34:00 christos Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -42,47 +42,54 @@ #include <sys/types.h> #include <sys/malloc.h> -#ifndef RF_DEBUG_MEM -#define RF_DEBUG_MEM 0 -#endif +int rf_ConfigureDebugMem(RF_ShutdownList_t **); -#if RF_DEBUG_MEM -#define RF_Malloc(_p_, _size_, _cast_) \ - { \ - _p_ = _cast_ malloc((u_long)_size_, M_RAIDFRAME, M_WAITOK); \ - memset((char *)_p_, 0, _size_); \ - if (rf_memDebug) rf_record_malloc(_p_, _size_, __LINE__, __FILE__); \ - } +#ifndef RF_DEBUG_MEM +# define RF_DEBUG_MEM 0 +# define RF_Malloc(s) malloc(s, M_RAIDFRAME, M_WAITOK | M_ZERO) +# define RF_Free(p, s) free(p, M_RAIDFRAME) +# define RF_MallocAndAdd(s, l) _RF_MallocAndAdd(s, l) #else -#define RF_Malloc(_p_, _size_, _cast_) \ - { \ - _p_ = _cast_ malloc((u_long)_size_, M_RAIDFRAME, M_WAITOK); \ - memset((char *)_p_, 0, _size_); \ - } -#endif +extern long rf_memDebug; + +void rf_record_malloc(void *, size_t, const char *, uint32_t); +void rf_unrecord_malloc(void *, size_t); +void rf_print_unfreed(void); -#define RF_MallocAndAdd(__p_, __size_, __cast_, __alist_) \ - { \ - RF_Malloc(__p_, __size_, __cast_); \ - if (__alist_) rf_AddToAllocList(__alist_, __p_, __size_); \ +# define RF_Malloc(s) _RF_Malloc(s, __FILE__, __LINE__) +# define RF_MallocAndAdd(s, l) \ + _RF_MallocAndAdd(s, l, __FILE__, __LINE__) + +static __inline void * +_RF_Malloc(size_t size, const char *file, uint32_t line) +{ + void *p = malloc(size, M_RAIDFRAME, M_WAITOK | M_ZERO); + if (rf_memDebug) rf_record_malloc(p, size, file, line); + return p; +} + +static __inline void +RF_Free(void *p, size_t size) +{ + free(p, M_RAIDFRAME); + if (rf_memDebug) rf_unrecord_malloc(p, size); } +#endif +static __inline void * +_RF_MallocAndAdd(size_t size, RF_AllocListElem_t *l #if RF_DEBUG_MEM -#define RF_Free(_p_, _sz_) \ - { \ - free((void *)(_p_), M_RAIDFRAME); \ - if (rf_memDebug) rf_unrecord_malloc(_p_, (u_int32_t) (_sz_)); \ - } -#else -#define RF_Free(_p_, _sz_) \ - { \ - free((void *)(_p_), M_RAIDFRAME); \ - } + , const char *file, uint32_t line +#endif +) +{ + void *p = malloc(size, M_RAIDFRAME, M_WAITOK | M_ZERO); +#if RF_DEBUG_MEM + if (rf_memDebug) rf_record_malloc(p, size, file, line); #endif + if (l) rf_AddToAllocList(l, p, size); + return p; +} -void rf_record_malloc(void *p, int size, int line, const char *filen); -void rf_unrecord_malloc(void *p, int sz); -void rf_print_unfreed(void); -int rf_ConfigureDebugMem(RF_ShutdownList_t ** listp); #endif /* !_RF__RF_DEBUGMEM_H_ */ Index: src/sys/dev/raidframe/rf_raid5_rotatedspare.c diff -u src/sys/dev/raidframe/rf_raid5_rotatedspare.c:1.13 src/sys/dev/raidframe/rf_raid5_rotatedspare.c:1.14 --- src/sys/dev/raidframe/rf_raid5_rotatedspare.c:1.13 Sat Mar 14 11:36:20 2009 +++ src/sys/dev/raidframe/rf_raid5_rotatedspare.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_raid5_rotatedspare.c,v 1.13 2009/03/14 15:36:20 dsl Exp $ */ +/* $NetBSD: rf_raid5_rotatedspare.c,v 1.14 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_raid5_rotatedspare.c,v 1.13 2009/03/14 15:36:20 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_raid5_rotatedspare.c,v 1.14 2019/02/09 03:34:00 christos Exp $"); #include "rf_archs.h" @@ -64,7 +64,7 @@ rf_ConfigureRAID5_RS( RF_RowCol_t i, j, startdisk; /* create a RAID level 5 configuration structure */ - RF_MallocAndAdd(info, sizeof(RF_Raid5RSConfigInfo_t), (RF_Raid5RSConfigInfo_t *), raidPtr->cleanupList); + info = RF_MallocAndAdd(sizeof(*info), raidPtr->cleanupList); if (info == NULL) return (ENOMEM); layoutPtr->layoutSpecificInfo = (void *) info; Index: src/sys/dev/raidframe/rf_decluster.c diff -u src/sys/dev/raidframe/rf_decluster.c:1.25 src/sys/dev/raidframe/rf_decluster.c:1.26 --- src/sys/dev/raidframe/rf_decluster.c:1.25 Wed Jan 17 19:32:49 2018 +++ src/sys/dev/raidframe/rf_decluster.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_decluster.c,v 1.25 2018/01/18 00:32:49 mrg Exp $ */ +/* $NetBSD: rf_decluster.c,v 1.26 2019/02/09 03:34:00 christos Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -48,7 +48,7 @@ *--------------------------------------------------------------------*/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_decluster.c,v 1.25 2018/01/18 00:32:49 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_decluster.c,v 1.26 2019/02/09 03:34:00 christos Exp $"); #include <dev/raidframe/raidframevar.h> @@ -89,7 +89,7 @@ rf_ConfigureDeclustered(RF_ShutdownList_ numCompleteSpareRegionsPerDisk = 0; /* 1. create layout specific structure */ - RF_MallocAndAdd(info, sizeof(RF_DeclusteredConfigInfo_t), (RF_DeclusteredConfigInfo_t *), raidPtr->cleanupList); + info = RF_MallocAndAdd(sizeof(*info), raidPtr->cleanupList); if (info == NULL) return (ENOMEM); layoutPtr->layoutSpecificInfo = (void *) info; @@ -614,7 +614,7 @@ rf_InstallSpareTable(RF_Raid_t *raidPtr, RF_SparetWait_t *req; int retcode; - RF_Malloc(req, sizeof(*req), (RF_SparetWait_t *)); + req = RF_Malloc(sizeof(*req)); req->C = raidPtr->numCol; req->G = raidPtr->Layout.numDataCol + raidPtr->Layout.numParityCol; req->fcol = fcol; @@ -643,20 +643,23 @@ rf_SetSpareTable(RF_Raid_t *raidPtr, voi /* what we need to copyin is a 2-d array, so first copyin the user * pointers to the rows in the table */ - RF_Malloc(ptrs, info->TablesPerSpareRegion * sizeof(RF_SpareTableEntry_t *), (RF_SpareTableEntry_t **)); - retcode = copyin((void *) data, (void *) ptrs, info->TablesPerSpareRegion * sizeof(RF_SpareTableEntry_t *)); + size_t ptrslen = info->TablesPerSpareRegion * sizeof(*ptrs); + ptrs = RF_Malloc(ptrslen); + retcode = copyin(data, ptrs, ptrslen); if (retcode) return (retcode); /* now allocate kernel space for the row pointers */ - RF_Malloc(info->SpareTable, info->TablesPerSpareRegion * sizeof(RF_SpareTableEntry_t *), (RF_SpareTableEntry_t **)); + info->SpareTable = RF_Malloc(info->TablesPerSpareRegion * + sizeof(*info->SpareTable)); /* now allocate kernel space for each row in the table, and copy it in * from user space */ + size_t len = info->BlocksPerTable * sizeof(**info->SpareTable); for (i = 0; i < info->TablesPerSpareRegion; i++) { - RF_Malloc(info->SpareTable[i], info->BlocksPerTable * sizeof(RF_SpareTableEntry_t), (RF_SpareTableEntry_t *)); - retcode = copyin(ptrs[i], info->SpareTable[i], info->BlocksPerTable * sizeof(RF_SpareTableEntry_t)); + info->SpareTable[i] = RF_Malloc(len); + retcode = copyin(ptrs[i], info->SpareTable[i], len); if (retcode) { info->SpareTable = NULL; /* blow off the memory * we've allocated */ @@ -665,7 +668,7 @@ rf_SetSpareTable(RF_Raid_t *raidPtr, voi } /* free up the temporary array we used */ - RF_Free(ptrs, info->TablesPerSpareRegion * sizeof(RF_SpareTableEntry_t *)); + RF_Free(ptrs, ptrslen); return (0); } Index: src/sys/dev/raidframe/rf_diskqueue.c diff -u src/sys/dev/raidframe/rf_diskqueue.c:1.53 src/sys/dev/raidframe/rf_diskqueue.c:1.54 --- src/sys/dev/raidframe/rf_diskqueue.c:1.53 Thu May 5 02:04:09 2011 +++ src/sys/dev/raidframe/rf_diskqueue.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_diskqueue.c,v 1.53 2011/05/05 06:04:09 mrg Exp $ */ +/* $NetBSD: rf_diskqueue.c,v 1.54 2019/02/09 03:34:00 christos Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -66,7 +66,7 @@ ****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_diskqueue.c,v 1.53 2011/05/05 06:04:09 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_diskqueue.c,v 1.54 2019/02/09 03:34:00 christos Exp $"); #include <dev/raidframe/raidframevar.h> @@ -225,10 +225,9 @@ rf_ConfigureDiskQueues(RF_ShutdownList_t } raidPtr->qType = p; - RF_MallocAndAdd(diskQueues, - (raidPtr->numCol + RF_MAXSPARE) * - sizeof(RF_DiskQueue_t), (RF_DiskQueue_t *), - raidPtr->cleanupList); + diskQueues = RF_MallocAndAdd( + (raidPtr->numCol + RF_MAXSPARE) * sizeof(*diskQueues), + raidPtr->cleanupList); if (diskQueues == NULL) return (ENOMEM); raidPtr->Queues = diskQueues; @@ -372,7 +371,7 @@ rf_CreateDiskQueueData(RF_IoType_t typ, if (p == NULL) return (NULL); - memset(p, 0, sizeof(RF_DiskQueueData_t)); + memset(p, 0, sizeof(*p)); if (waitflag == PR_WAITOK) { p->bp = getiobuf(NULL, true); } else { Index: src/sys/dev/raidframe/rf_disks.c diff -u src/sys/dev/raidframe/rf_disks.c:1.90 src/sys/dev/raidframe/rf_disks.c:1.91 --- src/sys/dev/raidframe/rf_disks.c:1.90 Fri Feb 8 08:37:46 2019 +++ src/sys/dev/raidframe/rf_disks.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_disks.c,v 1.90 2019/02/08 13:37:46 christos Exp $ */ +/* $NetBSD: rf_disks.c,v 1.91 2019/02/09 03:34:00 christos Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. * All rights reserved. @@ -60,7 +60,7 @@ ***************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.90 2019/02/08 13:37:46 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.91 2019/02/09 03:34:00 christos Exp $"); #include <dev/raidframe/raidframevar.h> @@ -321,19 +321,17 @@ rf_AllocDiskStructures(RF_Raid_t *raidPt /* We allocate RF_MAXSPARE on the first row so that we have room to do hot-swapping of spares */ - RF_MallocAndAdd(raidPtr->Disks, (raidPtr->numCol + RF_MAXSPARE) * - sizeof(RF_RaidDisk_t), (RF_RaidDisk_t *), - raidPtr->cleanupList); + raidPtr->Disks = RF_MallocAndAdd((raidPtr->numCol + RF_MAXSPARE) * + sizeof(*raidPtr->Disks), raidPtr->cleanupList); if (raidPtr->Disks == NULL) { ret = ENOMEM; goto fail; } /* get space for device specific stuff.. */ - RF_MallocAndAdd(raidPtr->raid_cinfo, - (raidPtr->numCol + RF_MAXSPARE) * - sizeof(struct raidcinfo), (struct raidcinfo *), - raidPtr->cleanupList); + raidPtr->raid_cinfo = RF_MallocAndAdd( + (raidPtr->numCol + RF_MAXSPARE) * sizeof(*raidPtr->raid_cinfo), + raidPtr->cleanupList); if (raidPtr->raid_cinfo == NULL) { ret = ENOMEM; Index: src/sys/dev/raidframe/rf_driver.c diff -u src/sys/dev/raidframe/rf_driver.c:1.134 src/sys/dev/raidframe/rf_driver.c:1.135 --- src/sys/dev/raidframe/rf_driver.c:1.134 Tue Jan 8 02:18:18 2019 +++ src/sys/dev/raidframe/rf_driver.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_driver.c,v 1.134 2019/01/08 07:18:18 mrg Exp $ */ +/* $NetBSD: rf_driver.c,v 1.135 2019/02/09 03:34:00 christos Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. * All rights reserved. @@ -66,7 +66,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.134 2019/01/08 07:18:18 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.135 2019/02/09 03:34:00 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_raid_diagnostic.h" @@ -587,7 +587,7 @@ rf_AllocRaidAccDesc(RF_Raid_t *raidPtr, desc->status = 0; desc->numRetries = 0; #if RF_ACC_TRACE > 0 - memset((char *) &desc->tracerec, 0, sizeof(RF_AccTraceEntry_t)); + memset(&desc->tracerec, 0, sizeof(desc->tracerec)); #endif desc->callbackFunc = NULL; desc->callbackArg = NULL; Index: src/sys/dev/raidframe/rf_evenodd_dagfuncs.c diff -u src/sys/dev/raidframe/rf_evenodd_dagfuncs.c:1.22 src/sys/dev/raidframe/rf_evenodd_dagfuncs.c:1.23 --- src/sys/dev/raidframe/rf_evenodd_dagfuncs.c:1.22 Sun Mar 23 05:30:59 2014 +++ src/sys/dev/raidframe/rf_evenodd_dagfuncs.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_evenodd_dagfuncs.c,v 1.22 2014/03/23 09:30:59 christos Exp $ */ +/* $NetBSD: rf_evenodd_dagfuncs.c,v 1.23 2019/02/09 03:34:00 christos Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_evenodd_dagfuncs.c,v 1.22 2014/03/23 09:30:59 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_evenodd_dagfuncs.c,v 1.23 2019/02/09 03:34:00 christos Exp $"); #include "rf_archs.h" @@ -411,7 +411,7 @@ rf_RecoveryEFunc(RF_DagNode_t *node) RF_AccTraceEntry_t *tracerec = node->dagHdr->tracerec; RF_Etimer_t timer; - memset((char *) node->results[0], 0, + memset(node->results[0], 0, rf_RaidAddressToByte(raidPtr, failedPDA->numSector)); if (node->dagHdr->status == rf_enable) { RF_ETIMER_START(timer); @@ -482,8 +482,6 @@ rf_doubleEOdecode( short *P; RF_ASSERT(bytesPerEU % sizeof(short) == 0); - RF_Malloc(P, bytesPerEU, (short *)); - RF_Malloc(temp, bytesPerEU, (short *)); #elif RF_EO_MATRIX_DIM == 17 int longsPerEU = bytesPerEU / sizeof(long); long *rrdbuf_current, *pbuf_current, *ebuf_current; @@ -492,13 +490,11 @@ rf_doubleEOdecode( long *P; RF_ASSERT(bytesPerEU % sizeof(long) == 0); - RF_Malloc(P, bytesPerEU, (long *)); - RF_Malloc(temp, bytesPerEU, (long *)); #endif + P = RF_Malloc(bytesPerEU); + temp = RF_Malloc(bytesPerEU); RF_ASSERT(*((long *) dest[0]) == 0); RF_ASSERT(*((long *) dest[1]) == 0); - memset((char *) P, 0, bytesPerEU); - memset((char *) temp, 0, bytesPerEU); RF_ASSERT(*P == 0); /* calculate the 'P' parameter, which, not parity, is the Xor of all * elements in the last two column, ie. 'E' and 'parity' colume, see @@ -680,11 +676,11 @@ rf_EvenOddDoubleRecoveryFunc(RF_DagNode_ ndataParam = i; break; } - RF_Malloc(buf, numDataCol * sizeof(char *), (char **)); + buf = RF_Malloc(numDataCol * sizeof(*buf)); if (ndataParam != 0) { - RF_Malloc(suoff, ndataParam * sizeof(long), (long *)); - RF_Malloc(suend, ndataParam * sizeof(long), (long *)); - RF_Malloc(prmToCol, ndataParam * sizeof(long), (long *)); + suoff = RF_Malloc(ndataParam * sizeof(*suoff)); + suend = RF_Malloc(ndataParam * sizeof(*suend)); + prmToCol = RF_Malloc(ndataParam * sizeof(*prmToCol)); } if (asmap->failedPDAs[1] && (asmap->failedPDAs[1]->numSector + asmap->failedPDAs[0]->numSector < secPerSU)) { @@ -788,22 +784,19 @@ rf_EvenOddDoubleRecoveryFunc(RF_DagNode_ if (nresults == 1) { dest[0] = (char *)((RF_PhysDiskAddr_t *) node->results[0])->bufPtr + rf_RaidAddressToByte(raidPtr, sector - fsuoff[0]); /* Always malloc temp buffer to dest[1] */ - RF_Malloc(dest[1], bytesPerSector, (char *)); - memset(dest[1], 0, bytesPerSector); + dest[1] = RF_Malloc(bytesPerSector); mallc_two = 1; } else { if (fsuoff[0] <= sector && sector < fsuend[0]) dest[0] = (char *)((RF_PhysDiskAddr_t *) node->results[0])->bufPtr + rf_RaidAddressToByte(raidPtr, sector - fsuoff[0]); else { - RF_Malloc(dest[0], bytesPerSector, (char *)); - memset(dest[0], 0, bytesPerSector); + dest[0] = RF_Malloc(bytesPerSector); mallc_one = 1; } if (fsuoff[1] <= sector && sector < fsuend[1]) dest[1] = (char *)((RF_PhysDiskAddr_t *) node->results[1])->bufPtr + rf_RaidAddressToByte(raidPtr, sector - fsuoff[1]); else { - RF_Malloc(dest[1], bytesPerSector, (char *)); - memset(dest[1], 0, bytesPerSector); + dest[1] = RF_Malloc(bytesPerSector); mallc_two = 1; } RF_ASSERT(mallc_one == 0 || mallc_two == 0); @@ -874,7 +867,7 @@ rf_EOWriteDoubleRecoveryFunc(RF_DagNode_ * case, the other failed SU * is not being accessed */ RF_ETIMER_START(timer); - RF_Malloc(buf, numDataCol * sizeof(char *), (char **)); + buf = RF_Malloc(numDataCol * sizeof(*buf)); ppda = node->results[0];/* Instead of being buffers, node->results[0] * and [1] are Ppda and Epda */ @@ -915,12 +908,10 @@ rf_EOWriteDoubleRecoveryFunc(RF_DagNode_ fcol[1] = i; /* assign temporary space to put recovered failed SU */ numbytes = fpda->numSector * bytesPerSector; - RF_Malloc(olddata[0], numbytes, (char *)); - RF_Malloc(olddata[1], numbytes, (char *)); + olddata[0] = RF_Malloc(numbytes); + olddata[1] = RF_Malloc(numbytes); dest[0] = olddata[0]; dest[1] = olddata[1]; - memset(olddata[0], 0, numbytes); - memset(olddata[1], 0, numbytes); /* Begin the recovery decoding, initially buf[j], ebuf, pbuf, dest[j] * have already pointed at the beginning of each source buffers and * destination buffers */ Index: src/sys/dev/raidframe/rf_interdecluster.c diff -u src/sys/dev/raidframe/rf_interdecluster.c:1.14 src/sys/dev/raidframe/rf_interdecluster.c:1.15 --- src/sys/dev/raidframe/rf_interdecluster.c:1.14 Wed Nov 15 20:33:23 2006 +++ src/sys/dev/raidframe/rf_interdecluster.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_interdecluster.c,v 1.14 2006/11/16 01:33:23 christos Exp $ */ +/* $NetBSD: rf_interdecluster.c,v 1.15 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_interdecluster.c,v 1.14 2006/11/16 01:33:23 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_interdecluster.c,v 1.15 2019/02/09 03:34:00 christos Exp $"); #include "rf_archs.h" @@ -73,8 +73,7 @@ rf_ConfigureInterDecluster( RF_RowCol_t i, tmp, SUs_per_region; /* create an Interleaved Declustering configuration structure */ - RF_MallocAndAdd(info, sizeof(RF_InterdeclusterConfigInfo_t), (RF_InterdeclusterConfigInfo_t *), - raidPtr->cleanupList); + info = RF_MallocAndAdd(sizeof(*info), raidPtr->cleanupList); if (info == NULL) return (ENOMEM); layoutPtr->layoutSpecificInfo = (void *) info; Index: src/sys/dev/raidframe/rf_map.c diff -u src/sys/dev/raidframe/rf_map.c:1.47 src/sys/dev/raidframe/rf_map.c:1.48 --- src/sys/dev/raidframe/rf_map.c:1.47 Sat Oct 15 16:31:15 2016 +++ src/sys/dev/raidframe/rf_map.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_map.c,v 1.47 2016/10/15 20:31:15 oster Exp $ */ +/* $NetBSD: rf_map.c,v 1.48 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_map.c,v 1.47 2016/10/15 20:31:15 oster Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_map.c,v 1.48 2019/02/09 03:34:00 christos Exp $"); #include <dev/raidframe/raidframevar.h> @@ -129,7 +129,7 @@ rf_MapAccess(RF_Raid_t *raidPtr, RF_Raid RF_ASSERT(asmList); t_asm = asmList; asmList = asmList->next; - memset((char *) t_asm, 0, sizeof(RF_AccessStripeMap_t)); + memset(t_asm, 0, sizeof(*t_asm)); if (!asm_p) asm_list = asm_p = t_asm; else { @@ -157,7 +157,7 @@ rf_MapAccess(RF_Raid_t *raidPtr, RF_Raid RF_ASSERT(pdaList); t_pda = pdaList; pdaList = pdaList->next; - memset((char *) t_pda, 0, sizeof(RF_PhysDiskAddr_t)); + memset(t_pda, 0, sizeof(*t_pda)); if (!pda_p) asm_p->physInfo = pda_p = t_pda; else { @@ -200,7 +200,7 @@ rf_MapAccess(RF_Raid_t *raidPtr, RF_Raid RF_ASSERT(pdaList); t_pda = pdaList; pdaList = pdaList->next; - memset((char *) t_pda, 0, sizeof(RF_PhysDiskAddr_t)); + memset(t_pda, 0, sizeof(*t_pda)); pda_p = asm_p->parityInfo = t_pda; pda_p->type = RF_PDA_TYPE_PARITY; (layoutPtr->map->MapParity) (raidPtr, rf_RaidAddressOfPrevStripeUnitBoundary(layoutPtr, startAddrWithinStripe), @@ -217,12 +217,12 @@ rf_MapAccess(RF_Raid_t *raidPtr, RF_Raid RF_ASSERT(pdaList && pdaList->next); t_pda = pdaList; pdaList = pdaList->next; - memset((char *) t_pda, 0, sizeof(RF_PhysDiskAddr_t)); + memset(t_pda, 0, sizeof(*t_pda)); pda_p = asm_p->parityInfo = t_pda; pda_p->type = RF_PDA_TYPE_PARITY; t_pda = pdaList; pdaList = pdaList->next; - memset((char *) t_pda, 0, sizeof(RF_PhysDiskAddr_t)); + memset(t_pda, 0, sizeof(*t_pda)); pda_q = asm_p->qInfo = t_pda; pda_q->type = RF_PDA_TYPE_Q; (layoutPtr->map->MapParity) (raidPtr, rf_RaidAddressOfPrevStripeUnitBoundary(layoutPtr, startAddrWithinStripe), @@ -278,8 +278,8 @@ rf_MarkFailuresInASMList(RF_Raid_t *raid asmap->numParityFailed = 0; asmap->numQFailed = 0; asmap->numFailedPDAs = 0; - memset((char *) asmap->failedPDAs, 0, - RF_MAX_FAILED_PDA * sizeof(RF_PhysDiskAddr_t *)); + memset(asmap->failedPDAs, 0, + RF_MAX_FAILED_PDA * sizeof(*asmap->failedPDAs)); for (pda = asmap->physInfo; pda; pda = pda->next) { if (RF_DEAD_DISK(disks[pda->col].status)) { asmap->numDataFailed++; @@ -379,7 +379,7 @@ rf_AllocAccessStripeMapHeader(void) RF_AccessStripeMapHeader_t *p; p = pool_get(&rf_pools.asm_hdr, PR_WAITOK); - memset((char *) p, 0, sizeof(RF_AccessStripeMapHeader_t)); + memset(p, 0, sizeof(*p)); return (p); } @@ -397,7 +397,7 @@ rf_AllocVFPListElem(void) RF_VoidFunctionPointerListElem_t *p; p = pool_get(&rf_pools.vfple, PR_WAITOK); - memset((char *) p, 0, sizeof(RF_VoidFunctionPointerListElem_t)); + memset(p, 0, sizeof(*p)); return (p); } @@ -416,7 +416,7 @@ rf_AllocVPListElem(void) RF_VoidPointerListElem_t *p; p = pool_get(&rf_pools.vple, PR_WAITOK); - memset((char *) p, 0, sizeof(RF_VoidPointerListElem_t)); + memset(p, 0, sizeof(*p)); return (p); } @@ -434,7 +434,7 @@ rf_AllocASMHeaderListElem(void) RF_ASMHeaderListElem_t *p; p = pool_get(&rf_pools.asmhle, PR_WAITOK); - memset((char *) p, 0, sizeof(RF_ASMHeaderListElem_t)); + memset(p, 0, sizeof(*p)); return (p); } @@ -452,7 +452,7 @@ rf_AllocFailedStripeStruct(void) RF_FailedStripe_t *p; p = pool_get(&rf_pools.fss, PR_WAITOK); - memset((char *) p, 0, sizeof(RF_FailedStripe_t)); + memset(p, 0, sizeof(*p)); return (p); } @@ -473,7 +473,7 @@ rf_AllocPhysDiskAddr(void) RF_PhysDiskAddr_t *p; p = pool_get(&rf_pools.pda, PR_WAITOK); - memset((char *) p, 0, sizeof(RF_PhysDiskAddr_t)); + memset(p, 0, sizeof(*p)); return (p); } Index: src/sys/dev/raidframe/rf_netbsdkintf.c diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.373 src/sys/dev/raidframe/rf_netbsdkintf.c:1.374 --- src/sys/dev/raidframe/rf_netbsdkintf.c:1.373 Wed Feb 6 22:03:00 2019 +++ src/sys/dev/raidframe/rf_netbsdkintf.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_netbsdkintf.c,v 1.373 2019/02/07 03:03:00 christos Exp $ */ +/* $NetBSD: rf_netbsdkintf.c,v 1.374 2019/02/09 03:34:00 christos Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc. @@ -101,7 +101,7 @@ ***********************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.373 2019/02/07 03:03:00 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.374 2019/02/09 03:34:00 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_raid_autoconfig.h" @@ -1107,7 +1107,7 @@ rf_fail_disk(RF_Raid_t *raidPtr, struct /* make a copy of the recon request so that we don't rely on * the user's buffer */ - RF_Malloc(rrint, sizeof(*rrint), (struct rf_recon_req_internal *)); + rrint = RF_Malloc(sizeof(*rrint)); if (rrint == NULL) return(ENOMEM); rrint->col = rr->col; @@ -1134,7 +1134,7 @@ rf_copyinspecificbuf(RF_Config_t *k_cfg) } u_char *specific_buf; - RF_Malloc(specific_buf, k_cfg->layoutSpecificSize, (u_char *)); + specific_buf = RF_Malloc(k_cfg->layoutSpecificSize); if (specific_buf == NULL) return ENOMEM; @@ -1163,7 +1163,7 @@ rf_getConfiguration(struct raid_softc *r /* copy-in the configuration information */ /* data points to a pointer to the configuration structure */ - RF_Malloc(*k_cfg, sizeof(RF_Config_t), (RF_Config_t *)); + *k_cfg = RF_Malloc(sizeof(**k_cfg)); if (*k_cfg == NULL) { return ENOMEM; } @@ -1358,7 +1358,7 @@ rf_rebuild_in_place(RF_Raid_t *raidPtr, rf_unlock_mutex2(raidPtr->mutex); struct rf_recon_req_internal *rrint; - RF_Malloc(rrint, sizeof(*rrint), (struct rf_recon_req_internal *)); + rrint = RF_Malloc(sizeof(*rrint)); if (rrint == NULL) return ENOMEM; @@ -1516,8 +1516,7 @@ raidioctl(dev_t dev, u_long cmd, void *d case RAIDFRAME_GET_INFO: ucfgp = *(RF_DeviceConfig_t **)data; - RF_Malloc(d_cfg, sizeof(RF_DeviceConfig_t), - (RF_DeviceConfig_t *)); + d_cfg = RF_Malloc(sizeof(*d_cfg)); if (d_cfg == NULL) return ENOMEM; retcode = rf_get_info(raidPtr, d_cfg); @@ -1680,7 +1679,7 @@ raidioctl(dev_t dev, u_long cmd, void *d /* wakes up a process waiting on SPARET_WAIT and puts an error * code in it that will cause the dameon to exit */ case RAIDFRAME_ABORT_SPARET_WAIT: - RF_Malloc(waitreq, sizeof(*waitreq), (RF_SparetWait_t *)); + waitreq = RF_Malloc(sizeof(*waitreq)); waitreq->fcol = -1; rf_lock_mutex2(rf_sparet_wait_mutex); waitreq->next = rf_sparet_wait_queue; @@ -1698,7 +1697,7 @@ raidioctl(dev_t dev, u_long cmd, void *d /* respond to the requestor. the return status of the spare * table installation is passed in the "fcol" field */ - RF_Malloc(waitreq, sizeof(*waitreq), (RF_SparetWait_t *)); + waitred = RF_Malloc(sizeof(*waitreq)); waitreq->fcol = retcode; rf_lock_mutex2(rf_sparet_wait_mutex); waitreq->next = rf_sparet_resp_queue; Index: src/sys/dev/raidframe/rf_paritylog.c diff -u src/sys/dev/raidframe/rf_paritylog.c:1.18 src/sys/dev/raidframe/rf_paritylog.c:1.19 --- src/sys/dev/raidframe/rf_paritylog.c:1.18 Wed May 11 02:03:06 2011 +++ src/sys/dev/raidframe/rf_paritylog.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_paritylog.c,v 1.18 2011/05/11 06:03:06 mrg Exp $ */ +/* $NetBSD: rf_paritylog.c,v 1.19 2019/02/09 03:34:00 christos Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_paritylog.c,v 1.18 2011/05/11 06:03:06 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_paritylog.c,v 1.19 2019/02/09 03:34:00 christos Exp $"); #include "rf_archs.h" @@ -74,7 +74,7 @@ AllocParityLogCommonData(RF_Raid_t * rai rf_unlock_mutex2(raidPtr->parityLogDiskQueue.mutex); } else { rf_unlock_mutex2(raidPtr->parityLogDiskQueue.mutex); - RF_Malloc(common, sizeof(RF_CommonLogData_t), (RF_CommonLogData_t *)); + common = RF_Malloc(sizeof(*common)); /* destroy is in rf_paritylogging.c */ rf_init_mutex2(common->mutex, IPL_VM); } @@ -114,7 +114,7 @@ AllocParityLogData(RF_Raid_t * raidPtr) rf_unlock_mutex2(raidPtr->parityLogDiskQueue.mutex); } else { rf_unlock_mutex2(raidPtr->parityLogDiskQueue.mutex); - RF_Malloc(data, sizeof(RF_ParityLogData_t), (RF_ParityLogData_t *)); + data = RF_Malloc(sizeof(*data)); } data->next = NULL; data->prev = NULL; Index: src/sys/dev/raidframe/rf_paritylogDiskMgr.c diff -u src/sys/dev/raidframe/rf_paritylogDiskMgr.c:1.28 src/sys/dev/raidframe/rf_paritylogDiskMgr.c:1.29 --- src/sys/dev/raidframe/rf_paritylogDiskMgr.c:1.28 Wed May 11 02:20:33 2011 +++ src/sys/dev/raidframe/rf_paritylogDiskMgr.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_paritylogDiskMgr.c,v 1.28 2011/05/11 06:20:33 mrg Exp $ */ +/* $NetBSD: rf_paritylogDiskMgr.c,v 1.29 2019/02/09 03:34:00 christos Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_paritylogDiskMgr.c,v 1.28 2011/05/11 06:20:33 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_paritylogDiskMgr.c,v 1.29 2019/02/09 03:34:00 christos Exp $"); #include "rf_archs.h" @@ -134,8 +134,6 @@ ReadRegionLog( RF_IO_NORMAL_PRIORITY); /* create and initialize PDA for the core log */ - /* RF_Malloc(*rrd_pda, sizeof(RF_PhysDiskAddr_t), (RF_PhysDiskAddr_t - * *)); */ *rrd_pda = rf_AllocPDAList(1); rf_MapLogParityLogging(raidPtr, regionID, 0, &((*rrd_pda)->col), &((*rrd_pda)->startSector)); @@ -146,8 +144,7 @@ ReadRegionLog( printf("set rrd_pda->next to NULL\n"); } /* initialize DAG parameters */ - RF_Malloc(tracerec,sizeof(RF_AccTraceEntry_t), (RF_AccTraceEntry_t *)); - memset((char *) tracerec, 0, sizeof(RF_AccTraceEntry_t)); + tracerec = RF_Malloc(sizeof(*tracerec)); (*rrd_dag_h)->tracerec = tracerec; rrd_rdNode = (*rrd_dag_h)->succedents[0]->succedents[0]; rrd_rdNode->params[0].p = *rrd_pda; @@ -187,9 +184,6 @@ WriteCoreLog( rf_DiskWriteFunc, rf_DiskWriteUndoFunc, "Wcl", *fwr_alloclist, RF_DAG_FLAGS_NONE, RF_IO_NORMAL_PRIORITY); - /* create and initialize PDA for the region log */ - /* RF_Malloc(*fwr_pda, sizeof(RF_PhysDiskAddr_t), (RF_PhysDiskAddr_t - * *)); */ *fwr_pda = rf_AllocPDAList(1); regionOffset = log->diskOffset; rf_MapLogParityLogging(raidPtr, regionID, regionOffset, @@ -198,8 +192,7 @@ WriteCoreLog( (*fwr_pda)->numSector = raidPtr->numSectorsPerLog; /* initialize DAG parameters */ - RF_Malloc(tracerec,sizeof(RF_AccTraceEntry_t), (RF_AccTraceEntry_t *)); - memset((char *) tracerec, 0, sizeof(RF_AccTraceEntry_t)); + tracerec = RF_Malloc(sizeof(*tracerec)); (*fwr_dag_h)->tracerec = tracerec; fwr_wrNode = (*fwr_dag_h)->succedents[0]->succedents[0]; fwr_wrNode->params[0].p = *fwr_pda; @@ -239,8 +232,6 @@ ReadRegionParity( RF_IO_NORMAL_PRIORITY); /* create and initialize PDA for region parity */ - /* RF_Malloc(*prd_pda, sizeof(RF_PhysDiskAddr_t), (RF_PhysDiskAddr_t - * *)); */ *prd_pda = rf_AllocPDAList(1); rf_MapRegionParity(raidPtr, regionID, &((*prd_pda)->col), &((*prd_pda)->startSector), @@ -253,8 +244,7 @@ ReadRegionParity( printf("set prd_pda->next to NULL\n"); } /* initialize DAG parameters */ - RF_Malloc(tracerec,sizeof(RF_AccTraceEntry_t), (RF_AccTraceEntry_t *)); - memset((char *) tracerec, 0, sizeof(RF_AccTraceEntry_t)); + tracerec = RF_Malloc(sizeof(*tracerec)); (*prd_dag_h)->tracerec = tracerec; prd_rdNode = (*prd_dag_h)->succedents[0]->succedents[0]; prd_rdNode->params[0].p = *prd_pda; @@ -297,16 +287,13 @@ WriteRegionParity( RF_IO_NORMAL_PRIORITY); /* create and initialize PDA for region parity */ - /* RF_Malloc(*pwr_pda, sizeof(RF_PhysDiskAddr_t), (RF_PhysDiskAddr_t - * *)); */ *pwr_pda = rf_AllocPDAList(1); rf_MapRegionParity(raidPtr, regionID, &((*pwr_pda)->col), &((*pwr_pda)->startSector), &((*pwr_pda)->numSector)); /* initialize DAG parameters */ - RF_Malloc(tracerec,sizeof(RF_AccTraceEntry_t), (RF_AccTraceEntry_t *)); - memset((char *) tracerec, 0, sizeof(RF_AccTraceEntry_t)); + tracerec = RF_Malloc(sizeof(*tracerec)); (*pwr_dag_h)->tracerec = tracerec; pwr_wrNode = (*pwr_dag_h)->succedents[0]->succedents[0]; pwr_wrNode->params[0].p = *pwr_pda; Index: src/sys/dev/raidframe/rf_raid1.c diff -u src/sys/dev/raidframe/rf_raid1.c:1.35 src/sys/dev/raidframe/rf_raid1.c:1.36 --- src/sys/dev/raidframe/rf_raid1.c:1.35 Sun Sep 15 08:47:26 2013 +++ src/sys/dev/raidframe/rf_raid1.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_raid1.c,v 1.35 2013/09/15 12:47:26 martin Exp $ */ +/* $NetBSD: rf_raid1.c,v 1.36 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_raid1.c,v 1.35 2013/09/15 12:47:26 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_raid1.c,v 1.36 2019/02/09 03:34:00 christos Exp $"); #include "rf_raid.h" #include "rf_raid1.h" @@ -66,7 +66,7 @@ rf_ConfigureRAID1(RF_ShutdownList_t **li RF_RowCol_t i; /* create a RAID level 1 configuration structure */ - RF_MallocAndAdd(info, sizeof(RF_Raid1ConfigInfo_t), (RF_Raid1ConfigInfo_t *), raidPtr->cleanupList); + info = RF_MallocAndAdd(sizeof(*info), raidPtr->cleanupList); if (info == NULL) return (ENOMEM); layoutPtr->layoutSpecificInfo = (void *) info; @@ -292,7 +292,7 @@ rf_VerifyParityRAID1(RF_Raid_t *raidPtr, RF_ASSERT(layoutPtr->numDataCol == layoutPtr->numParityCol); stripeWidth = layoutPtr->numDataCol + layoutPtr->numParityCol; bcount = nbytes * (layoutPtr->numDataCol + layoutPtr->numParityCol); - RF_MallocAndAdd(bf, bcount, (char *), allocList); + bf = RF_MallocAndAdd(bcount, allocList); if (bf == NULL) goto done; #if RF_DEBUG_VERIFYPARITY @@ -368,7 +368,7 @@ rf_VerifyParityRAID1(RF_Raid_t *raidPtr, RF_ASSERT(pda == NULL); #if RF_ACC_TRACE > 0 - memset((char *) &tracerec, 0, sizeof(tracerec)); + memset(&tracerec, 0, sizeof(tracerec)); rd_dag_h->tracerec = &tracerec; #endif #if 0 @@ -409,7 +409,7 @@ rf_VerifyParityRAID1(RF_Raid_t *raidPtr, * and column 1 of the array are mirror copies, and are considered * "data column 0" for this purpose). */ - RF_MallocAndAdd(bbufs, layoutPtr->numParityCol * sizeof(int), (int *), + bbufs = RF_MallocAndAdd(layoutPtr->numParityCol * sizeof(*bbufs), allocList); nbad = 0; /* @@ -488,7 +488,7 @@ rf_VerifyParityRAID1(RF_Raid_t *raidPtr, wrBlock->succedents[i]->params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); } #if RF_ACC_TRACE > 0 - memset((char *) &tracerec, 0, sizeof(tracerec)); + memset(&tracerec, 0, sizeof(tracerec)); wr_dag_h->tracerec = &tracerec; #endif #if 0 Index: src/sys/dev/raidframe/rf_raid4.c diff -u src/sys/dev/raidframe/rf_raid4.c:1.12 src/sys/dev/raidframe/rf_raid4.c:1.13 --- src/sys/dev/raidframe/rf_raid4.c:1.12 Wed Nov 15 20:33:23 2006 +++ src/sys/dev/raidframe/rf_raid4.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_raid4.c,v 1.12 2006/11/16 01:33:23 christos Exp $ */ +/* $NetBSD: rf_raid4.c,v 1.13 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_raid4.c,v 1.12 2006/11/16 01:33:23 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_raid4.c,v 1.13 2019/02/09 03:34:00 christos Exp $"); #include "rf_raid.h" #include "rf_dag.h" @@ -62,13 +62,14 @@ rf_ConfigureRAID4(RF_ShutdownList_t **li int i; /* create a RAID level 4 configuration structure ... */ - RF_MallocAndAdd(info, sizeof(RF_Raid4ConfigInfo_t), (RF_Raid4ConfigInfo_t *), raidPtr->cleanupList); + info = RF_MallocAndAdd(sizeof(*info), raidPtr->cleanupList); if (info == NULL) return (ENOMEM); layoutPtr->layoutSpecificInfo = (void *) info; /* ... and fill it in. */ - RF_MallocAndAdd(info->stripeIdentifier, raidPtr->numCol * sizeof(RF_RowCol_t), (RF_RowCol_t *), raidPtr->cleanupList); + info->stripeIdentifier = RF_MallocAndAdd(raidPtr->numCol * + sizeof(*info->stripeIdentifier), raidPtr->cleanupList); if (info->stripeIdentifier == NULL) return (ENOMEM); for (i = 0; i < raidPtr->numCol; i++) Index: src/sys/dev/raidframe/rf_raid5.c diff -u src/sys/dev/raidframe/rf_raid5.c:1.19 src/sys/dev/raidframe/rf_raid5.c:1.20 --- src/sys/dev/raidframe/rf_raid5.c:1.19 Wed Nov 15 20:33:23 2006 +++ src/sys/dev/raidframe/rf_raid5.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_raid5.c,v 1.19 2006/11/16 01:33:23 christos Exp $ */ +/* $NetBSD: rf_raid5.c,v 1.20 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_raid5.c,v 1.19 2006/11/16 01:33:23 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_raid5.c,v 1.20 2019/02/09 03:34:00 christos Exp $"); #include <dev/raidframe/raidframevar.h> @@ -63,7 +63,7 @@ rf_ConfigureRAID5(RF_ShutdownList_t **li RF_RowCol_t i, j, startdisk; /* create a RAID level 5 configuration structure */ - RF_MallocAndAdd(info, sizeof(RF_Raid5ConfigInfo_t), (RF_Raid5ConfigInfo_t *), raidPtr->cleanupList); + info = RF_MallocAndAdd(sizeof(*info), raidPtr->cleanupList); if (info == NULL) return (ENOMEM); layoutPtr->layoutSpecificInfo = (void *) info; Index: src/sys/dev/raidframe/rf_reconmap.c diff -u src/sys/dev/raidframe/rf_reconmap.c:1.36 src/sys/dev/raidframe/rf_reconmap.c:1.37 --- src/sys/dev/raidframe/rf_reconmap.c:1.36 Tue Nov 14 09:27:54 2017 +++ src/sys/dev/raidframe/rf_reconmap.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_reconmap.c,v 1.36 2017/11/14 14:27:54 christos Exp $ */ +/* $NetBSD: rf_reconmap.c,v 1.37 2019/02/09 03:34:00 christos Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -34,7 +34,7 @@ *************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_reconmap.c,v 1.36 2017/11/14 14:27:54 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_reconmap.c,v 1.37 2019/02/09 03:34:00 christos Exp $"); #include "rf_raid.h" #include <sys/time.h> @@ -88,7 +88,7 @@ rf_MakeReconMap(RF_Raid_t *raidPtr, RF_S RF_ReconMap_t *p; int error; - RF_Malloc(p, sizeof(RF_ReconMap_t), (RF_ReconMap_t *)); + p = RF_Malloc(sizeof(*p)); p->sectorsPerReconUnit = ru_sectors; p->sectorsInDisk = disk_sectors; @@ -100,12 +100,9 @@ rf_MakeReconMap(RF_Raid_t *raidPtr, RF_S p->high_ru = p->status_size - 1; p->head = 0; - RF_Malloc(p->status, p->status_size * sizeof(RF_ReconMapListElem_t *), (RF_ReconMapListElem_t **)); + p->status = RF_Malloc(p->status_size * sizeof(*p->status)); RF_ASSERT(p->status != NULL); - (void) memset((char *) p->status, 0, - p->status_size * sizeof(RF_ReconMapListElem_t *)); - pool_init(&p->elem_pool, sizeof(RF_ReconMapListElem_t), 0, 0, 0, "raidreconpl", NULL, IPL_BIO); if ((error = pool_prime(&p->elem_pool, RF_NUM_RECON_POOL_ELEM)) != 0) Index: src/sys/dev/raidframe/rf_reconutil.c diff -u src/sys/dev/raidframe/rf_reconutil.c:1.36 src/sys/dev/raidframe/rf_reconutil.c:1.37 --- src/sys/dev/raidframe/rf_reconutil.c:1.36 Wed Jan 17 19:32:49 2018 +++ src/sys/dev/raidframe/rf_reconutil.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_reconutil.c,v 1.36 2018/01/18 00:32:49 mrg Exp $ */ +/* $NetBSD: rf_reconutil.c,v 1.37 2019/02/09 03:34:00 christos Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -31,7 +31,7 @@ ********************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_reconutil.c,v 1.36 2018/01/18 00:32:49 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_reconutil.c,v 1.37 2019/02/09 03:34:00 christos Exp $"); #include <dev/raidframe/raidframevar.h> @@ -73,11 +73,11 @@ rf_MakeReconControl(RF_RaidReconDesc_t * /* make and zero the global reconstruction structure and the per-disk * structure */ - RF_Malloc(reconCtrlPtr, sizeof(RF_ReconCtrl_t), (RF_ReconCtrl_t *)); + reconCtrlPtr = RF_Malloc(sizeof(*reconCtrlPtr)); /* note: this zeros the perDiskInfo */ - RF_Malloc(reconCtrlPtr->perDiskInfo, raidPtr->numCol * - sizeof(RF_PerDiskReconCtrl_t), (RF_PerDiskReconCtrl_t *)); + reconCtrlPtr->perDiskInfo = RF_Malloc(raidPtr->numCol * + sizeof(*reconCtrlPtr->perDiskInfo)); reconCtrlPtr->reconDesc = reconDesc; reconCtrlPtr->fcol = fcol; reconCtrlPtr->spareCol = scol; @@ -232,7 +232,7 @@ rf_MakeReconBuffer(RF_Raid_t *raidPtr, R u_int recon_buffer_size = rf_RaidAddressToByte(raidPtr, layoutPtr->SUsPerRU * layoutPtr->sectorsPerStripeUnit); t = pool_get(&rf_pools.reconbuffer, PR_WAITOK); - RF_Malloc(t->buffer, recon_buffer_size, (void *)); + t->buffer = RF_Malloc(recon_buffer_size); t->raidPtr = raidPtr; t->col = col; t->priority = RF_IO_RECON_PRIORITY; Index: src/sys/dev/raidframe/rf_reconstruct.c diff -u src/sys/dev/raidframe/rf_reconstruct.c:1.121 src/sys/dev/raidframe/rf_reconstruct.c:1.122 --- src/sys/dev/raidframe/rf_reconstruct.c:1.121 Fri Nov 14 09:29:16 2014 +++ src/sys/dev/raidframe/rf_reconstruct.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_reconstruct.c,v 1.121 2014/11/14 14:29:16 oster Exp $ */ +/* $NetBSD: rf_reconstruct.c,v 1.122 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_reconstruct.c,v 1.121 2014/11/14 14:29:16 oster Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.122 2019/02/09 03:34:00 christos Exp $"); #include <sys/param.h> #include <sys/time.h> @@ -169,8 +169,7 @@ AllocRaidReconDesc(RF_Raid_t *raidPtr, R RF_RaidReconDesc_t *reconDesc; - RF_Malloc(reconDesc, sizeof(RF_RaidReconDesc_t), - (RF_RaidReconDesc_t *)); + reconDesc = RF_Malloc(sizeof(*reconDesc)); reconDesc->raidPtr = raidPtr; reconDesc->col = col; reconDesc->spareDiskPtr = spareDiskPtr; @@ -579,7 +578,8 @@ rf_ContinueReconstructFailedDisk(RF_Raid raidPtr->accumXorTimeUs = 0; #if RF_ACC_TRACE > 0 /* create one trace record per physical disk */ - RF_Malloc(raidPtr->recon_tracerecs, raidPtr->numCol * sizeof(RF_AccTraceEntry_t), (RF_AccTraceEntry_t *)); + raidPtr->recon_tracerecs = + RF_Malloc(raidPtr->numCol * sizeof(*raidPtr->recon_tracerecs)); #endif /* quiesce the array prior to starting recon. this is needed @@ -1220,7 +1220,7 @@ IssueNextReadRequest(RF_Raid_t *raidPtr, rbuf->parityStripeID = ctrl->curPSID; rbuf->which_ru = ctrl->ru_count; #if RF_ACC_TRACE > 0 - memset((char *) &raidPtr->recon_tracerecs[col], 0, + memset(&raidPtr->recon_tracerecs[col], 0, sizeof(raidPtr->recon_tracerecs[col])); raidPtr->recon_tracerecs[col].reconacc = 1; RF_ETIMER_START(raidPtr->recon_tracerecs[col].recon_timer); Index: src/sys/dev/raidframe/rf_stripelocks.c diff -u src/sys/dev/raidframe/rf_stripelocks.c:1.32 src/sys/dev/raidframe/rf_stripelocks.c:1.33 --- src/sys/dev/raidframe/rf_stripelocks.c:1.32 Thu May 5 04:21:29 2011 +++ src/sys/dev/raidframe/rf_stripelocks.c Fri Feb 8 22:34:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_stripelocks.c,v 1.32 2011/05/05 08:21:29 mrg Exp $ */ +/* $NetBSD: rf_stripelocks.c,v 1.33 2019/02/09 03:34:00 christos Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -57,7 +57,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_stripelocks.c,v 1.32 2011/05/05 08:21:29 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_stripelocks.c,v 1.33 2019/02/09 03:34:00 christos Exp $"); #include <dev/raidframe/raidframevar.h> @@ -199,9 +199,7 @@ rf_MakeLockTable(void) RF_LockTableEntry_t *lockTable; int i; - RF_Malloc(lockTable, - ((int) rf_lockTableSize) * sizeof(RF_LockTableEntry_t), - (RF_LockTableEntry_t *)); + lockTable = RF_Malloc(rf_lockTableSize * sizeof(*lockTable)); if (lockTable == NULL) return (NULL); for (i = 0; i < rf_lockTableSize; i++) {