Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src remove M_CANFAIL flag for malloc(9) - it was completely igno...



details:   https://anonhg.NetBSD.org/src/rev/62b3f628eac5
branches:  trunk
changeset: 445122:62b3f628eac5
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Sun Oct 14 17:37:40 2018 +0000

description:
remove M_CANFAIL flag for malloc(9) - it was completely ignored, so had
actually no effect

diffstat:

 common/lib/libprop/prop_kern.c   |   6 ++----
 sys/arch/x86/x86/ipmi.c          |   8 ++++----
 sys/dev/ata/TODO.ncq             |   2 --
 sys/dev/pci/mpii.c               |  14 +++++++-------
 sys/dev/sdmmc/sbt.c              |   6 +++---
 sys/dev/sdmmc/sdmmc_io.c         |   9 ++++-----
 sys/fs/udf/udf_allocation.c      |   7 +++----
 sys/fs/udf/udf_subr.c            |  11 +++++------
 sys/kern/kern_sysctl.c           |  36 ++++++++++++++++--------------------
 sys/miscfs/procfs/procfs_vnops.c |   8 ++++----
 sys/sys/malloc.h                 |   5 ++---
 11 files changed, 50 insertions(+), 62 deletions(-)

diffs (truncated from 459 to 300 lines):

diff -r 60afa295a4d0 -r 62b3f628eac5 common/lib/libprop/prop_kern.c
--- a/common/lib/libprop/prop_kern.c    Sun Oct 14 17:25:21 2018 +0000
+++ b/common/lib/libprop/prop_kern.c    Sun Oct 14 17:37:40 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: prop_kern.c,v 1.23 2017/01/29 02:29:06 christos Exp $  */
+/*     $NetBSD: prop_kern.c,v 1.24 2018/10/14 17:37:40 jdolecek Exp $  */
 
 /*-
  * Copyright (c) 2006, 2009 The NetBSD Foundation, Inc.
@@ -412,10 +412,8 @@
 
        /*
         * Allocate an extra byte so we can guarantee NUL-termination.
-        *
-        * Allow malloc to fail in case pmap would be exhausted.
         */
-       buf = malloc(pref->pref_len + 1, M_TEMP, M_WAITOK | M_CANFAIL);
+       buf = malloc(pref->pref_len + 1, M_TEMP, M_WAITOK);
        if (buf == NULL)
                return (ENOMEM);
        error = copyin(pref->pref_plist, buf, pref->pref_len);
diff -r 60afa295a4d0 -r 62b3f628eac5 sys/arch/x86/x86/ipmi.c
--- a/sys/arch/x86/x86/ipmi.c   Sun Oct 14 17:25:21 2018 +0000
+++ b/sys/arch/x86/x86/ipmi.c   Sun Oct 14 17:37:40 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ipmi.c,v 1.66 2017/06/22 13:32:47 joerg Exp $ */
+/*     $NetBSD: ipmi.c,v 1.67 2018/10/14 17:37:40 jdolecek Exp $ */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -52,7 +52,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.66 2017/06/22 13:32:47 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.67 2018/10/14 17:37:40 jdolecek Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -1204,7 +1204,7 @@
        /* Allocate space for entire SDR Length of SDR in header does not
         * include header length */
        sdrlen = sizeof(shdr) + shdr.record_length;
-       psdr = malloc(sdrlen, M_DEVBUF, M_WAITOK|M_CANFAIL);
+       psdr = malloc(sdrlen, M_DEVBUF, M_WAITOK);
        if (psdr == NULL)
                return -1;
 
@@ -1832,7 +1832,7 @@
        sc->sc_nsensors += count;
        for (idx = 0; idx < count; idx++) {
                psensor = malloc(sizeof(struct ipmi_sensor), M_DEVBUF,
-                   M_WAITOK|M_CANFAIL);
+                   M_WAITOK);
                if (psensor == NULL)
                        break;
 
diff -r 60afa295a4d0 -r 62b3f628eac5 sys/dev/ata/TODO.ncq
--- a/sys/dev/ata/TODO.ncq      Sun Oct 14 17:25:21 2018 +0000
+++ b/sys/dev/ata/TODO.ncq      Sun Oct 14 17:37:40 2018 +0000
@@ -36,5 +36,3 @@
 
 mvsata(4) 64-bit DMA
 - at least with AHA1430SA does not really work, crash in mvsata_intr() on boot
-
-malloc(M_CANFAIL) actually doesn't do anything
diff -r 60afa295a4d0 -r 62b3f628eac5 sys/dev/pci/mpii.c
--- a/sys/dev/pci/mpii.c        Sun Oct 14 17:25:21 2018 +0000
+++ b/sys/dev/pci/mpii.c        Sun Oct 14 17:37:40 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mpii.c,v 1.11 2018/01/15 12:58:06 maya Exp $ */
+/* $NetBSD: mpii.c,v 1.12 2018/10/14 17:37:40 jdolecek Exp $ */
 /*     OpenBSD: mpii.c,v 1.51 2012/04/11 13:29:14 naddy Exp    */
 /*
  * Copyright (c) 2010 Mike Belopuhov <mkb%crypt.org.ru@localhost>
@@ -20,7 +20,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.11 2018/01/15 12:58:06 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.12 2018/10/14 17:37:40 jdolecek Exp $");
 
 #include "bio.h"
 
@@ -4905,7 +4905,7 @@
                return (EINVAL);
 
        pagelen = hdr.page_length * 4;
-       vpg = malloc(pagelen, M_TEMP, M_WAITOK | M_CANFAIL | M_ZERO);
+       vpg = malloc(pagelen, M_TEMP, M_WAITOK | M_ZERO);
        if (vpg == NULL)
                return (ENOMEM);
 
@@ -5131,7 +5131,7 @@
        }
 
        pagelen = hdr.page_length * 4;
-       vpg = malloc(pagelen, M_TEMP, M_WAITOK | M_CANFAIL | M_ZERO);
+       vpg = malloc(pagelen, M_TEMP, M_WAITOK | M_ZERO);
        if (vpg == NULL) {
                printf("%s: unable to allocate space for raid "
                    "volume page 0\n", DEVNAME(sc));
@@ -5236,7 +5236,7 @@
        }
 
        pagelen = hdr.page_length * 4;
-       vpg = malloc(pagelen, M_TEMP, M_WAITOK | M_CANFAIL | M_ZERO);
+       vpg = malloc(pagelen, M_TEMP, M_WAITOK | M_ZERO);
        if (vpg == NULL) {
                printf("%s: unable to allocate space for raid "
                    "volume page 0\n", DEVNAME(sc));
@@ -5293,7 +5293,7 @@
        }
 
        pagelen = le16toh(ehdr.ext_page_length) * 4;
-       cpg = malloc(pagelen, M_TEMP, M_WAITOK | M_CANFAIL | M_ZERO);
+       cpg = malloc(pagelen, M_TEMP, M_WAITOK | M_ZERO);
        if (cpg == NULL) {
                printf("%s: unable to allocate space for raid config page 0\n",
                    DEVNAME(sc));
@@ -5348,7 +5348,7 @@
        DNPRINTF(MPII_D_IOCTL, "%s: mpii_bio_disk %d\n", DEVNAME(sc),
            bd->bd_diskid);
 
-       ppg = malloc(sizeof(*ppg), M_TEMP, M_WAITOK | M_CANFAIL | M_ZERO);
+       ppg = malloc(sizeof(*ppg), M_TEMP, M_WAITOK | M_ZERO);
        if (ppg == NULL) {
                printf("%s: unable to allocate space for raid physical disk "
                    "page 0\n", DEVNAME(sc));
diff -r 60afa295a4d0 -r 62b3f628eac5 sys/dev/sdmmc/sbt.c
--- a/sys/dev/sdmmc/sbt.c       Sun Oct 14 17:25:21 2018 +0000
+++ b/sys/dev/sdmmc/sbt.c       Sun Oct 14 17:37:40 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sbt.c,v 1.6 2018/04/18 14:56:35 maxv Exp $     */
+/*     $NetBSD: sbt.c,v 1.7 2018/10/14 17:37:40 jdolecek Exp $ */
 /*     $OpenBSD: sbt.c,v 1.9 2007/06/19 07:59:57 uwe Exp $     */
 
 /*
@@ -20,7 +20,7 @@
 /* Driver for Type-A/B SDIO Bluetooth cards */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sbt.c,v 1.6 2018/04/18 14:56:35 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sbt.c,v 1.7 2018/10/14 17:37:40 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -182,7 +182,7 @@
        /* It may be Type-B, but we use it only in Type-A mode. */
        printf("%s: SDIO Bluetooth Type-A\n", DEVNAME(sc));
 
-       sc->sc_buf = malloc(SBT_PKT_BUFSIZ, M_DEVBUF, M_NOWAIT | M_CANFAIL);
+       sc->sc_buf = malloc(SBT_PKT_BUFSIZ, M_DEVBUF, M_NOWAIT);
        if (sc->sc_buf == NULL) {
                aprint_error("%s: can't allocate cmd buffer\n", DEVNAME(sc));
                return;
diff -r 60afa295a4d0 -r 62b3f628eac5 sys/dev/sdmmc/sdmmc_io.c
--- a/sys/dev/sdmmc/sdmmc_io.c  Sun Oct 14 17:25:21 2018 +0000
+++ b/sys/dev/sdmmc/sdmmc_io.c  Sun Oct 14 17:37:40 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sdmmc_io.c,v 1.13 2017/10/23 13:47:17 jmcneill Exp $   */
+/*     $NetBSD: sdmmc_io.c,v 1.14 2018/10/14 17:37:40 jdolecek Exp $   */
 /*     $OpenBSD: sdmmc_io.c,v 1.10 2007/09/17 01:33:33 krw Exp $       */
 
 /*
@@ -20,7 +20,7 @@
 /* Routines for SD I/O cards. */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sdmmc_io.c,v 1.13 2017/10/23 13:47:17 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdmmc_io.c,v 1.14 2018/10/14 17:37:40 jdolecek Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -636,12 +636,11 @@
        if (sc->sc_sct->card_enable_intr == NULL)
                return NULL;
 
-       ih = malloc(sizeof *ih, M_DEVBUF, M_WAITOK|M_CANFAIL|M_ZERO);
+       ih = malloc(sizeof *ih, M_DEVBUF, M_WAITOK|M_ZERO);
        if (ih == NULL)
                return NULL;
 
-       ih->ih_name = malloc(strlen(name) + 1, M_DEVBUF,
-           M_WAITOK|M_CANFAIL|M_ZERO);
+       ih->ih_name = malloc(strlen(name) + 1, M_DEVBUF, M_WAITOK|M_ZERO);
        if (ih->ih_name == NULL) {
                free(ih, M_DEVBUF);
                return NULL;
diff -r 60afa295a4d0 -r 62b3f628eac5 sys/fs/udf/udf_allocation.c
--- a/sys/fs/udf/udf_allocation.c       Sun Oct 14 17:25:21 2018 +0000
+++ b/sys/fs/udf/udf_allocation.c       Sun Oct 14 17:37:40 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_allocation.c,v 1.39 2017/01/04 15:53:14 christos Exp $ */
+/* $NetBSD: udf_allocation.c,v 1.40 2018/10/14 17:37:40 jdolecek Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_allocation.c,v 1.39 2017/01/04 15:53:14 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_allocation.c,v 1.40 2018/10/14 17:37:40 jdolecek Exp $");
 #endif /* not lint */
 
 
@@ -1540,8 +1540,7 @@
        *sizepos = udf_rw32(*sizepos) - to_trunc;
 
        /* realloc bitmap for better memory usage */
-       new_sbd = realloc(sbd, inf_len, M_UDFVOLD,
-               M_CANFAIL | M_WAITOK);
+       new_sbd = realloc(sbd, inf_len, M_UDFVOLD, M_WAITOK);
        if (new_sbd) {
                /* update pointers */
                ump->metadata_unalloc_dscr = new_sbd;
diff -r 60afa295a4d0 -r 62b3f628eac5 sys/fs/udf/udf_subr.c
--- a/sys/fs/udf/udf_subr.c     Sun Oct 14 17:25:21 2018 +0000
+++ b/sys/fs/udf/udf_subr.c     Sun Oct 14 17:37:40 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.143 2018/08/09 20:30:26 reinoud Exp $ */
+/* $NetBSD: udf_subr.c,v 1.144 2018/10/14 17:37:40 jdolecek Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.143 2018/08/09 20:30:26 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.144 2018/10/14 17:37:40 jdolecek Exp $");
 #endif /* not lint */
 
 
@@ -1771,7 +1771,7 @@
                "%"PRIu64" bytes\n", inflen));
 
        /* allocate space for bitmap */
-       dscr = malloc(inflen, M_UDFVOLD, M_CANFAIL | M_WAITOK);
+       dscr = malloc(inflen, M_UDFVOLD, M_WAITOK);
        if (!dscr)
                return ENOMEM;
 
@@ -2739,7 +2739,7 @@
                /* realloc */
                new_vat_table = realloc(ump->vat_table,
                        ump->vat_table_alloc_len + UDF_VAT_CHUNKSIZE,
-                       M_UDFVOLD, M_WAITOK | M_CANFAIL);
+                       M_UDFVOLD, M_WAITOK);
                if (!new_vat_table) {
                        printf("udf_vat_write: can't extent VAT, out of mem\n");
                        return ENOMEM;
@@ -2936,8 +2936,7 @@
                ((vat_length + UDF_VAT_CHUNKSIZE-1) / UDF_VAT_CHUNKSIZE)
                        * UDF_VAT_CHUNKSIZE;
 
-       vat_table = malloc(vat_table_alloc_len, M_UDFVOLD,
-               M_CANFAIL | M_WAITOK);
+       vat_table = malloc(vat_table_alloc_len, M_UDFVOLD, M_WAITOK);
        if (vat_table == NULL) {
                printf("allocation of %d bytes failed for VAT\n",
                        vat_table_alloc_len);
diff -r 60afa295a4d0 -r 62b3f628eac5 sys/kern/kern_sysctl.c
--- a/sys/kern/kern_sysctl.c    Sun Oct 14 17:25:21 2018 +0000
+++ b/sys/kern/kern_sysctl.c    Sun Oct 14 17:37:40 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_sysctl.c,v 1.261 2018/01/27 00:00:26 christos Exp $       */
+/*     $NetBSD: kern_sysctl.c,v 1.262 2018/10/14 17:37:40 jdolecek Exp $       */
 
 /*-
  * Copyright (c) 2003, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.261 2018/01/27 00:00:26 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.262 2018/10/14 17:37:40 jdolecek Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_defcorename.h"
@@ -945,8 +945,7 @@
                                 * we want a rough idea of what the
                                 * size is now
                                 */
-                               vp = malloc(PAGE_SIZE, M_SYSCTLDATA,
-                                            M_WAITOK|M_CANFAIL);
+                               vp = malloc(PAGE_SIZE, M_SYSCTLDATA, M_WAITOK);
                                if (vp == NULL)
                                        return (ENOMEM);
                                e = nnode.sysctl_data;
@@ -1015,8 +1014,7 @@
        if (type != CTLTYPE_NODE) {
                if (sz != 0) {
                        if (flags & CTLFLAG_OWNDATA) {
-                               own = malloc(sz, M_SYSCTLDATA,
-                                            M_WAITOK|M_CANFAIL);
+                               own = malloc(sz, M_SYSCTLDATA, M_WAITOK);
                                if (own == NULL)
                                        return ENOMEM;



Home | Main Index | Thread Index | Old Index