From 67d07b9daf593179c4e4e8e58fd4be3e2bf4df15 Mon Sep 17 00:00:00 2001 From: jsg Date: Mon, 19 Aug 2024 03:08:27 +0000 Subject: [PATCH] test malloc return against NULL not 0 --- sys/dev/isa/if_eg.c | 6 +++--- sys/dev/isa/if_le_isapnp.c | 4 ++-- sys/dev/pci/if_bnx.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sys/dev/isa/if_eg.c b/sys/dev/isa/if_eg.c index 686eb1f2b4a..cd9c14b5104 100644 --- a/sys/dev/isa/if_eg.c +++ b/sys/dev/isa/if_eg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_eg.c,v 1.52 2023/09/11 08:41:26 mvs Exp $ */ +/* $OpenBSD: if_eg.c,v 1.53 2024/08/19 03:08:27 jsg Exp $ */ /* $NetBSD: if_eg.c,v 1.26 1996/05/12 23:52:27 mycroft Exp $ */ /* @@ -442,11 +442,11 @@ eginit(register struct eg_softc *sc) printf("%s: configure card command failed\n", sc->sc_dev.dv_xname); - if (sc->eg_inbuf == 0) + if (sc->eg_inbuf == NULL) sc->eg_inbuf = malloc(EG_BUFLEN, M_TEMP, M_NOWAIT); sc->eg_incount = 0; - if (sc->eg_outbuf == 0) + if (sc->eg_outbuf == NULL) sc->eg_outbuf = malloc(EG_BUFLEN, M_TEMP, M_NOWAIT); bus_space_write_1(bst, bsh, EG_CONTROL, EG_CTL_CMDE); diff --git a/sys/dev/isa/if_le_isapnp.c b/sys/dev/isa/if_le_isapnp.c index 867efd83431..48813c37c8d 100644 --- a/sys/dev/isa/if_le_isapnp.c +++ b/sys/dev/isa/if_le_isapnp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_le_isapnp.c,v 1.15 2022/04/06 18:59:28 naddy Exp $ */ +/* $OpenBSD: if_le_isapnp.c,v 1.16 2024/08/19 03:08:27 jsg Exp $ */ /* $NetBSD: if_le_isa.c,v 1.2 1996/05/12 23:52:56 mycroft Exp $ */ /*- @@ -102,7 +102,7 @@ le_isapnp_attach(struct device *parent, struct device *self, void *aux) sc->sc_arpcom.ac_enaddr[i] = bus_space_read_1(iot, ioh, i); sc->sc_mem = malloc(16384, M_DEVBUF, M_NOWAIT); - if (sc->sc_mem == 0) { + if (sc->sc_mem == NULL) { printf(": couldn't allocate memory for card\n"); return; } diff --git a/sys/dev/pci/if_bnx.c b/sys/dev/pci/if_bnx.c index c2eff8bd701..6d18e3a2279 100644 --- a/sys/dev/pci/if_bnx.c +++ b/sys/dev/pci/if_bnx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bnx.c,v 1.133 2023/11/10 15:51:20 bluhm Exp $ */ +/* $OpenBSD: if_bnx.c,v 1.134 2024/08/19 03:08:27 jsg Exp $ */ /*- * Copyright (c) 2006 Broadcom Corporation @@ -1950,7 +1950,7 @@ bnx_nvram_write(struct bnx_softc *sc, u_int32_t offset, u_int8_t *data_buf, if (align_start || align_end) { buf = malloc(len32, M_DEVBUF, M_NOWAIT); - if (buf == 0) + if (buf == NULL) return (ENOMEM); if (align_start) -- 2.20.1