From nobody Wed Jan 11 10:40:02 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NsPMQ62yYz2r1M7; Wed, 11 Jan 2023 10:40:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NsPMQ5Gw7z3PYj; Wed, 11 Jan 2023 10:40:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673433602; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=k+e3+P44IDUdW5yodyyy5SUTi0s9q6LynmJLj01a3YQ=; b=bLrxdYIah3ELA+5bb1U23pN1m4fL+S4GwjttYPE+v5/40DEkscpXcAsAiToFlfDa+FlLq5 2rPCHHb7TVtWE97QIF3d3AqkdcyPCUL7OhVDU0gXnjV5GaHwc9jC3Ci7GkQZYPTB2m1x9r 1MxH528xAjktJBAqRKInXeD5Ar/+3HHWrGrN0A9s+7mUcnkQpMVHr27TEZLGwFTcADW9WJ 65iSbciO86thW6sJCl99SG6glpdcgU8Gj4EyYXcbYO+cvTLrDPCqZZRUrgPbya1zvqe1bR /pqNbv2uBomZ0fwpFZjMME4sCM3/n6rBiwUoWjDFni9NYsIAnSS91K9KQIInGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673433602; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=k+e3+P44IDUdW5yodyyy5SUTi0s9q6LynmJLj01a3YQ=; b=eGmUgfJEF93YqjBlbZJaf90L2eUEZ2lAZxoP/kYRgHKd21gvWEsUJnind1W29yI2H410jQ qwLtmGF73IIc5JAx9rb/PVJN4KFw2L7vb2zg+fY1A8OpxicG6V1ARokxbm+mSevcWX1Ci8 koblQmbaDqj4W8szkClh5TG0t9dYSndrg3zjrcuy6KH9vLNk/tFsamUXGKLTZ+4f1wRzLC Abpd1I8oLruecmpLscyGMy2BvoVh72M9QCVV5J71w3gYmJoixanvg/uQm85KWfn3SAIhkE wLWjM4v8XXq1z+LJafGZsSrPGQfV4LCrb8LYwGsfpU1PU5resB2Nr7dVkcLH4g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673433602; a=rsa-sha256; cv=none; b=LNaI/Dz6NaRcDhzZ9A2bkAyT04zxRenZD07DYhWtrWAX8MZsZuWieJWtZwoa8+d417yeh7 0VDKP4XCDBruYkwyPi80kzxd40hW/+x9yTaTkOveN1Ph2Ml4OqGM0FFP004/Wmu5AtkTTE s7uiiN7qkGLK04eJpCcvzD5KgVVkd4UeBZi3IIutBdwT2QpEHkY7YImcHl8lxQL6wYzsAm 0DT+vzrwBpw+I6JVxFA9y/01jlkjG/NVuxOhZBAECaGpjGMraG5DCosv/qR6eXv96cIQON u3ZYn/XHoHK+77Gna5CWjpyjQsf9pg/yzeVd5SfvIMSiN9CiDg6To1ldUoPPDw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NsPMQ4CvGzlQR; Wed, 11 Jan 2023 10:40:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30BAe2nv070244; Wed, 11 Jan 2023 10:40:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30BAe25a070241; Wed, 11 Jan 2023 10:40:02 GMT (envelope-from git) Date: Wed, 11 Jan 2023 10:40:02 GMT Message-Id: <202301111040.30BAe25a070241@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Zhenlei Huang Subject: git: 71a44d641fe0 - stable/13 - GEOM: Remove redundant NULL pointer check before g_free() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: zlei X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 71a44d641fe0b06d873b72c0faa06849e1d9c66f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=71a44d641fe0b06d873b72c0faa06849e1d9c66f commit 71a44d641fe0b06d873b72c0faa06849e1d9c66f Author: Zhenlei Huang AuthorDate: 2022-12-28 15:34:09 +0000 Commit: Zhenlei Huang CommitDate: 2023-01-11 10:35:59 +0000 GEOM: Remove redundant NULL pointer check before g_free() Reviewed by: melifaro, pjd, imp Approved by: kp (mentor) Differential Revision: https://reviews.freebsd.org/D37779 (cherry picked from commit bd5d9037c5dd79390faf8ee37eecd99e1c378bf0) --- sys/geom/bde/g_bde.c | 3 +-- sys/geom/eli/g_eli.c | 3 +-- sys/geom/geom_ccd.c | 3 +-- sys/geom/geom_dev.c | 3 +-- sys/geom/geom_redboot.c | 6 ++---- sys/geom/geom_slice.c | 6 ++---- sys/geom/label/g_label_msdosfs.c | 6 ++---- sys/geom/label/g_label_ntfs.c | 6 ++---- sys/geom/part/g_part_bsd.c | 3 +-- sys/geom/part/g_part_gpt.c | 27 +++++++++------------------ sys/geom/vinum/geom_vinum_create.c | 3 +-- sys/geom/vinum/geom_vinum_events.c | 3 +-- sys/geom/vinum/geom_vinum_plex.c | 3 +-- 13 files changed, 25 insertions(+), 50 deletions(-) diff --git a/sys/geom/bde/g_bde.c b/sys/geom/bde/g_bde.c index 3d2de334e4bb..c9ef244bac81 100644 --- a/sys/geom/bde/g_bde.c +++ b/sys/geom/bde/g_bde.c @@ -208,8 +208,7 @@ g_bde_create_geom(struct gctl_req *req, struct g_class *mp, struct g_provider *p g_access(cp, -1, -1, -1); g_detach(cp); g_destroy_consumer(cp); - if (gp->softc != NULL) - g_free(gp->softc); + g_free(gp->softc); g_destroy_geom(gp); switch (error) { case ENOENT: diff --git a/sys/geom/eli/g_eli.c b/sys/geom/eli/g_eli.c index 2493fd31c7de..2dc93b1d9956 100644 --- a/sys/geom/eli/g_eli.c +++ b/sys/geom/eli/g_eli.c @@ -755,8 +755,7 @@ g_eli_read_metadata_offset(struct g_class *mp, struct g_provider *pp, goto end; /* Metadata was read and decoded successfully. */ end: - if (buf != NULL) - g_free(buf); + g_free(buf); if (cp->provider != NULL) { if (cp->acr == 1) g_access(cp, -1, 0, 0); diff --git a/sys/geom/geom_ccd.c b/sys/geom/geom_ccd.c index 7f4dd3ca11ff..8e3859f0ce2f 100644 --- a/sys/geom/geom_ccd.c +++ b/sys/geom/geom_ccd.c @@ -226,8 +226,7 @@ g_ccd_freesc(struct ccd_s *sc) g_free(sc->sc_cinfo); if (sc->sc_itable != NULL) { for (ii = sc->sc_itable; ii->ii_ndisk > 0; ii++) - if (ii->ii_index != NULL) - g_free(ii->ii_index); + g_free(ii->ii_index); g_free(sc->sc_itable); } g_free(sc); diff --git a/sys/geom/geom_dev.c b/sys/geom/geom_dev.c index e52f8b8cccc2..32974e3bf822 100644 --- a/sys/geom/geom_dev.c +++ b/sys/geom/geom_dev.c @@ -720,8 +720,7 @@ g_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread error = copyout(new_entries, old_entries, alloc_size); if (old_entries != NULL && rep != NULL) rep->entries = old_entries; - if (new_entries != NULL) - g_free(new_entries); + g_free(new_entries); break; } default: diff --git a/sys/geom/geom_redboot.c b/sys/geom/geom_redboot.c index ffdb64d16274..8f21dc30526e 100644 --- a/sys/geom/geom_redboot.c +++ b/sys/geom/geom_redboot.c @@ -298,15 +298,13 @@ again: if (buf != NULL) head = parse_fis_directory(buf, blksize, offset, offmask); if (head == NULL && offset != 0) { - if (buf != NULL) - g_free(buf); + g_free(buf); offset = 0; /* check the front */ goto again; } g_topology_lock(); if (head == NULL) { - if (buf != NULL) - g_free(buf); + g_free(buf); return NULL; } /* diff --git a/sys/geom/geom_slice.c b/sys/geom/geom_slice.c index 397a1fe5e974..ceb6754f9d15 100644 --- a/sys/geom/geom_slice.c +++ b/sys/geom/geom_slice.c @@ -88,10 +88,8 @@ g_slice_free(struct g_geom *gp) if (gsp == NULL) return; g_free(gsp->slices); - if (gsp->hotspot != NULL) - g_free(gsp->hotspot); - if (gsp->softc != NULL) - g_free(gsp->softc); + g_free(gsp->hotspot); + g_free(gsp->softc); g_free(gsp); } diff --git a/sys/geom/label/g_label_msdosfs.c b/sys/geom/label/g_label_msdosfs.c index 67ac879d62c2..9ee052c7c1ef 100644 --- a/sys/geom/label/g_label_msdosfs.c +++ b/sys/geom/label/g_label_msdosfs.c @@ -209,10 +209,8 @@ endofchecks: g_label_rtrim(label, size); error: - if (sector0 != NULL) - g_free(sector0); - if (sector != NULL) - g_free(sector); + g_free(sector0); + g_free(sector); } struct g_label_desc g_label_msdosfs = { diff --git a/sys/geom/label/g_label_ntfs.c b/sys/geom/label/g_label_ntfs.c index 888096164b09..bcaeebce99f2 100644 --- a/sys/geom/label/g_label_ntfs.c +++ b/sys/geom/label/g_label_ntfs.c @@ -175,10 +175,8 @@ g_label_ntfs_taste(struct g_consumer *cp, char *label, size_t size) } } done: - if (bf != NULL) - g_free(bf); - if (filerecp != NULL) - g_free(filerecp); + g_free(bf); + g_free(filerecp); } struct g_label_desc g_label_ntfs = { diff --git a/sys/geom/part/g_part_bsd.c b/sys/geom/part/g_part_bsd.c index 2432d1911493..0f23a277ce8e 100644 --- a/sys/geom/part/g_part_bsd.c +++ b/sys/geom/part/g_part_bsd.c @@ -249,8 +249,7 @@ g_part_bsd_destroy(struct g_part_table *basetable, struct g_part_parms *gpp) struct g_part_bsd_table *table; table = (struct g_part_bsd_table *)basetable; - if (table->bbarea != NULL) - g_free(table->bbarea); + g_free(table->bbarea); table->bbarea = NULL; /* Wipe the second sector to clear the partitioning. */ diff --git a/sys/geom/part/g_part_gpt.c b/sys/geom/part/g_part_gpt.c index 775ec20081ea..702474e23cd0 100644 --- a/sys/geom/part/g_part_gpt.c +++ b/sys/geom/part/g_part_gpt.c @@ -534,8 +534,7 @@ gpt_read_hdr(struct g_part_gpt_table *table, struct g_consumer *cp, return (hdr); fail: - if (hdr != NULL) - g_free(hdr); + g_free(hdr); g_free(buf); return (NULL); } @@ -983,14 +982,10 @@ g_part_gpt_read(struct g_part_table *basetable, struct g_consumer *cp) "GEOM: %s: GPT rejected -- may not be recoverable.\n", pp->name); } - if (prihdr != NULL) - g_free(prihdr); - if (pritbl != NULL) - g_free(pritbl); - if (sechdr != NULL) - g_free(sechdr); - if (sectbl != NULL) - g_free(sectbl); + g_free(prihdr); + g_free(pritbl); + g_free(sechdr); + g_free(sectbl); return (EINVAL); } @@ -1022,11 +1017,9 @@ g_part_gpt_read(struct g_part_table *basetable, struct g_consumer *cp) "strongly advised.\n", pp->name); table->hdr = sechdr; basetable->gpt_corrupt = 1; - if (prihdr != NULL) - g_free(prihdr); + g_free(prihdr); tbl = sectbl; - if (pritbl != NULL) - g_free(pritbl); + g_free(pritbl); } else { if (table->state[GPT_ELT_SECTBL] != GPT_STATE_OK) { printf("GEOM: %s: the secondary GPT table is corrupt " @@ -1040,11 +1033,9 @@ g_part_gpt_read(struct g_part_table *basetable, struct g_consumer *cp) basetable->gpt_corrupt = 1; } table->hdr = prihdr; - if (sechdr != NULL) - g_free(sechdr); + g_free(sechdr); tbl = pritbl; - if (sectbl != NULL) - g_free(sectbl); + g_free(sectbl); } basetable->gpt_first = table->hdr->hdr_lba_start; diff --git a/sys/geom/vinum/geom_vinum_create.c b/sys/geom/vinum/geom_vinum_create.c index 036ce82c45e8..42caa112e8fc 100644 --- a/sys/geom/vinum/geom_vinum_create.c +++ b/sys/geom/vinum/geom_vinum_create.c @@ -140,8 +140,7 @@ gv_create_drive(struct gv_softc *sc, struct gv_drive *d) g_topology_unlock(); G_VINUM_DEBUG(0, "create drive '%s': unable to update " "access counts", d->name); - if (d->hdr != NULL) - g_free(d->hdr); + g_free(d->hdr); g_free(d); return (GV_ERR_CREATE); } diff --git a/sys/geom/vinum/geom_vinum_events.c b/sys/geom/vinum/geom_vinum_events.c index 78aa0adab8cf..74b9bbe4de9d 100644 --- a/sys/geom/vinum/geom_vinum_events.c +++ b/sys/geom/vinum/geom_vinum_events.c @@ -185,8 +185,7 @@ gv_drive_tasted(struct gv_softc *sc, struct g_provider *pp) return; failed: - if (hdr != NULL) - g_free(hdr); + g_free(hdr); g_topology_lock(); g_access(cp, -1, 0, 0); g_detach(cp); diff --git a/sys/geom/vinum/geom_vinum_plex.c b/sys/geom/vinum/geom_vinum_plex.c index a7b1e1e5a8bd..3e5b2e3d51a3 100644 --- a/sys/geom/vinum/geom_vinum_plex.c +++ b/sys/geom/vinum/geom_vinum_plex.c @@ -860,8 +860,7 @@ gv_init_complete(struct gv_plex *p, struct bio *bp) */ if (start >= s->drive_offset + s->size) { /* Free the data we initialized. */ - if (data != NULL) - g_free(data); + g_free(data); g_topology_assert_not(); g_topology_lock(); g_access(cp, 0, -1, 0);