From nobody Tue Sep 2 15:41:35 2025 X-Original-To: dev-commits-src-main@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 4cGVNK630wz66vMg for ; Tue, 02 Sep 2025 15:41:53 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cGVNK1mQ5z3wFV for ; Tue, 02 Sep 2025 15:41:53 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-2445805aa2eso55087145ad.1 for ; Tue, 02 Sep 2025 08:41:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1756827707; x=1757432507; darn=freebsd.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=FfreeMblx2zc88Pwx7lFpBSmBUKWvAUj9ALF3mcwGqU=; b=SWO+GJG9/srVU5OzjFi7+mp21YY2ismRYMGu3yFAOsrOBZ1qU4a6CpACwmg4gAlUi/ ko5a54AuUu4nkwrxITzTlsb0Y/L2rPn0gyeF2yyz02gxvf/11yIJExKE4mJJ78/zzQaN TRsirXX7iqScaHYZ2arQ2He8xnepQmdJdHrJvEG52Qw3l/UTnbsHtCnnpjrVvzEPI6B2 nPelOe1BdDZoUHwJNz/rYBL6Qtx42LP/n+iP21aExhDEfNl//Q5ZFHLHhfofTIgwOS3D MkTdBqtmvmjLAdThlQmlwq6liiam6hZfTOXaM+MTMtuI04tt+KaygzkHeG7QFNzVxUKW 32iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756827707; x=1757432507; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FfreeMblx2zc88Pwx7lFpBSmBUKWvAUj9ALF3mcwGqU=; b=jNDyiG5dl8mOoUf2pXYSTNikz945iWKle+E99eXo50Ka1i57bU5CYpB53oNA/P5GWn B+IIkI9qJ0RCtgy/1mtnUoDnMgZ/49SOQOBVEBSbJuj04jwRZ7y/ixg319LpVZyvxmdw SqxgHypKwDFl04PcRlmK2uIFzjHDWLNTcjwsarZT2Nk0lD5xJ6Mh0jSc4dw5KRYsuGxw kDz0f+ZHMGnT03wM2c970l2vcAwCqvp9zeM22J6dUHmwSYlfRIOu9t0KFr0+fsOTk8jh Jd+XBal3jaB47yGtcKPziLXF9zVoqIdSbPEksqT0MxKol+2sPVguIn83vLL0iHGoY7Xb VvBQ== X-Forwarded-Encrypted: i=1; AJvYcCWUyh9/cmsHSvArfSospAb+XFPbfleBEP2su1ALCIYOnmZ8U109LlkSMbe77MjP4DJRqr+JzMWUpkdHGjqlOVXI2M3Y+A==@freebsd.org X-Gm-Message-State: AOJu0YwYo65CYxNty28T+P6PEy71sEha2BGJFYHk8/XkGv0X5Wu50Q41 ueRIxKWgWbDnInWXmk0kSjSZu3pBBHylqD39BuKdsu828s2nV7xLlIufsrIZUQyrYwVE6F+7l49 TFhR4VZ6hNVbnA+9k+G4/DBrRVzh7z0bjnvnyKl8vLA== X-Gm-Gg: ASbGncsbnQUUjmwukE9HagCD2uc0wP17tRXkWNWiXZxsL012JzliEu9KkS0vJhFvsmk tjSf+A359w7PQOo+rzx5z+Nm4Dmksi8F1MNFG5y9epquuEXR9+4m1VMDYbKfBPYQ7SBT5mR6Sw0 az8p4o2pG1w6sjpUoXh+NI+/PcBtACZflAgvTa7zlJi9ebg/laxo38DipKd1ydZNWJPOzro5Gnb XvCrqV5trstTlZJxpg38W7vp1dFiff0XDQLqc6b4tMyqTsxGA== X-Google-Smtp-Source: AGHT+IHNx99PjzcxXU9uKhBql9L6z59loBgKW6kmNKMPwxXc1JWKCPfg+lgJEMwNjntPl3+93ZLfkqvIo00W1nR1X4E= X-Received: by 2002:a17:902:c410:b0:234:c8ec:51b5 with SMTP id d9443c01a7336-24944b1f82emr155603715ad.53.1756827706842; Tue, 02 Sep 2025 08:41:46 -0700 (PDT) List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 References: <202509012201.581M18tv010659@gitrepo.freebsd.org> In-Reply-To: From: Warner Losh Date: Tue, 2 Sep 2025 09:41:35 -0600 X-Gm-Features: Ac12FXzdvjtUig8VDAae2pCH_-uV1f-JlSigDSWljbAqC-a4LTE5i_1KRB28ROY Message-ID: Subject: Re: git: dfafdbdfc3e9 - main - stand: Use calloc instead of malloc for initialization of filesystem devsw To: Zhenlei Huang Cc: Warner Losh , "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Content-Type: multipart/alternative; boundary="00000000000065f309063dd3535f" X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Queue-Id: 4cGVNK1mQ5z3wFV --00000000000065f309063dd3535f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Sep 2, 2025 at 12:38=E2=80=AFAM Zhenlei Huang wr= ote: > > > > On Sep 2, 2025, at 6:01 AM, Warner Losh wrote: > > > > The branch main has been updated by imp: > > > > URL: > https://cgit.FreeBSD.org/src/commit/?id=3Ddfafdbdfc3e9db8b878283bcbef35f5= d8d37dae8 > > > > commit dfafdbdfc3e9db8b878283bcbef35f5d8d37dae8 > > Author: null > > Hi Warner, > > The Author is missing. Probably by mistake of Phabricator ? > Doh! Yes. I've reverted. I'll redo. The args are backwards. It's part of another change I was going to look into next... Warner > Best regards, > Zhenlei > > > AuthorDate: 2025-09-01 21:57:06 +0000 > > Commit: Warner Losh > > CommitDate: 2025-09-01 21:57:14 +0000 > > > > stand: Use calloc instead of malloc for initialization of filesystem > devsw > > > > This change is required for https://reviews.freebsd.org/D49355, so > that > > we can check if d_dev is uninitialized by checking if it's NULL. > > > > Reviewed by: imp > > Differential Revision: https://reviews.freebsd.org/D49705 > > --- > > stand/common/disk.c | 2 +- > > stand/kboot/kboot/hostdisk.c | 2 +- > > stand/libofw/devicename.c | 2 +- > > stand/libsa/dev.c | 2 +- > > stand/libsa/zfs/zfs.c | 2 +- > > stand/uboot/devicename.c | 2 +- > > 6 files changed, 6 insertions(+), 6 deletions(-) > > > > diff --git a/stand/common/disk.c b/stand/common/disk.c > > index c1650f0fa1ec..1baf91efaa49 100644 > > --- a/stand/common/disk.c > > +++ b/stand/common/disk.c > > @@ -468,7 +468,7 @@ disk_parsedev(struct devdesc **idev, const char > *devspec, const char **path) > > > > if (*cp !=3D '\0' && *cp !=3D ':') > > return (EINVAL); > > - dev =3D malloc(sizeof(*dev)); > > + dev =3D calloc(sizeof(*dev), 1); > > if (dev =3D=3D NULL) > > return (ENOMEM); > > dev->dd.d_unit =3D unit; > > diff --git a/stand/kboot/kboot/hostdisk.c b/stand/kboot/kboot/hostdisk.= c > > index a9117d4c1c9d..fc98bf534519 100644 > > --- a/stand/kboot/kboot/hostdisk.c > > +++ b/stand/kboot/kboot/hostdisk.c > > @@ -465,7 +465,7 @@ hostdisk_parsedev(struct devdesc **idev, const char > *devspec, const char **path) > > return (EINVAL); > > } > > free(fn); > > - dev =3D malloc(sizeof(*dev)); > > + dev =3D calloc(sizeof(*dev), 1); > > if (dev =3D=3D NULL) > > return (ENOMEM); > > dev->d_unit =3D 0; > > diff --git a/stand/libofw/devicename.c b/stand/libofw/devicename.c > > index f6419632c6bc..46a9717fdda5 100644 > > --- a/stand/libofw/devicename.c > > +++ b/stand/libofw/devicename.c > > @@ -98,7 +98,7 @@ ofw_common_parsedev(struct devdesc **dev, const char > *devspec, const char **path > > > > if (ofw_path_to_handle(devspec, ofwtype, &rem_path) =3D=3D -1) > > return (ENOENT); > > - idev =3D malloc(sizeof(struct ofw_devdesc)); > > + idev =3D calloc(sizeof(struct ofw_devdesc), 1); > > if (idev =3D=3D NULL) { > > printf("ofw_parsedev: malloc failed\n"); > > return (ENOMEM); > > diff --git a/stand/libsa/dev.c b/stand/libsa/dev.c > > index 1edc843d508c..4f6932e96c48 100644 > > --- a/stand/libsa/dev.c > > +++ b/stand/libsa/dev.c > > @@ -72,7 +72,7 @@ default_parsedev(struct devdesc **dev, const char > *devspec, > > int unit, err; > > char *cp; > > > > - idev =3D malloc(sizeof(struct devdesc)); > > + idev =3D calloc(sizeof(struct devdesc), 1); > > if (idev =3D=3D NULL) > > return (ENOMEM); > > > > diff --git a/stand/libsa/zfs/zfs.c b/stand/libsa/zfs/zfs.c > > index 70a102f6425d..2f7c1caaa4b5 100644 > > --- a/stand/libsa/zfs/zfs.c > > +++ b/stand/libsa/zfs/zfs.c > > @@ -1643,7 +1643,7 @@ zfs_parsedev(struct devdesc **idev, const char > *devspec, const char **path) > > spa =3D spa_find_by_name(poolname); > > if (!spa) > > return (ENXIO); > > - dev =3D malloc(sizeof(*dev)); > > + dev =3D calloc(sizeof(*dev), 1); > > if (dev =3D=3D NULL) > > return (ENOMEM); > > dev->pool_guid =3D spa->spa_guid; > > diff --git a/stand/uboot/devicename.c b/stand/uboot/devicename.c > > index 4ee9c7fd72c4..23670d7593a2 100644 > > --- a/stand/uboot/devicename.c > > +++ b/stand/uboot/devicename.c > > @@ -102,7 +102,7 @@ uboot_parsedev(struct uboot_devdesc **dev, const > char *devspec, > > } > > if (dv =3D=3D NULL) > > return(ENOENT); > > - idev =3D malloc(sizeof(struct uboot_devdesc)); > > + idev =3D calloc(sizeof(struct uboot_devdesc), 1); > > err =3D 0; > > np =3D (devspec + strlen(dv->dv_name)); > > > > > > --00000000000065f309063dd3535f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Tue, Sep 2, = 2025 at 12:38=E2=80=AFAM Zhenlei Huang <zlei@freebsd.org> wrote:


> On Sep 2, 2025, at 6:01 AM, Warner Losh <imp@freebsd.org> wrote:
>
> The branch main has been updated by imp:
>
> URL: https://= cgit.FreeBSD.org/src/commit/?id=3Ddfafdbdfc3e9db8b878283bcbef35f5d8d37dae8<= /a>
>
> commit dfafdbdfc3e9db8b878283bcbef35f5d8d37dae8
> Author:=C2=A0 =C2=A0 =C2=A0null <null>

Hi Warner,

The Author is missing. Probably by mistake of Phabricator ?

Doh! Yes. I've reverted. I'll redo. The args a= re backwards. It's part of another change I was going to look into next= ...

Warner

=C2=A0
Best regards,
Zhenlei

> AuthorDate: 2025-09-01 21:57:06 +0000
> Commit:=C2=A0 =C2=A0 =C2=A0Warner Losh <imp@FreeBSD.org>
> CommitDate: 2025-09-01 21:57:14 +0000
>
>=C2=A0 =C2=A0 stand: Use calloc instead of malloc for initialization of= filesystem devsw
>
>=C2=A0 =C2=A0 This change is required for
https://reviews.free= bsd.org/D49355, so that
>=C2=A0 =C2=A0 we can check if d_dev is uninitialized by checking if it&= #39;s NULL.
>
>=C2=A0 =C2=A0 Reviewed by:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 imp=
>=C2=A0 =C2=A0 Differential Revision:=C2=A0 https://reviews.fre= ebsd.org/D49705
> ---
> stand/common/disk.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 2 +-
> stand/kboot/kboot/hostdisk.c | 2 +-
> stand/libofw/devicename.c=C2=A0 =C2=A0 | 2 +-
> stand/libsa/dev.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 2 +-
> stand/libsa/zfs/zfs.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 | 2 +-
> stand/uboot/devicename.c=C2=A0 =C2=A0 =C2=A0| 2 +-
> 6 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/stand/common/disk.c b/stand/common/disk.c
> index c1650f0fa1ec..1baf91efaa49 100644
> --- a/stand/common/disk.c
> +++ b/stand/common/disk.c
> @@ -468,7 +468,7 @@ disk_parsedev(struct devdesc **idev, const char *d= evspec, const char **path)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0if (*cp !=3D '\0' && *cp != =3D ':')
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return (EINVAL);=
> -=C2=A0 =C2=A0 =C2=A0dev =3D malloc(sizeof(*dev));
> +=C2=A0 =C2=A0 =C2=A0dev =3D calloc(sizeof(*dev), 1);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0if (dev =3D=3D NULL)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return (ENOMEM);=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0dev->dd.d_unit =3D unit;
> diff --git a/stand/kboot/kboot/hostdisk.c b/stand/kboot/kboot/hostdisk= .c
> index a9117d4c1c9d..fc98bf534519 100644
> --- a/stand/kboot/kboot/hostdisk.c
> +++ b/stand/kboot/kboot/hostdisk.c
> @@ -465,7 +465,7 @@ hostdisk_parsedev(struct devdesc **idev, const cha= r *devspec, const char **path)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return (EINVAL);=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0}
>=C2=A0 =C2=A0 =C2=A0 =C2=A0free(fn);
> -=C2=A0 =C2=A0 =C2=A0dev =3D malloc(sizeof(*dev));
> +=C2=A0 =C2=A0 =C2=A0dev =3D calloc(sizeof(*dev), 1);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0if (dev =3D=3D NULL)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return (ENOMEM);=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0dev->d_unit =3D 0;
> diff --git a/stand/libofw/devicename.c b/stand/libofw/devicename.c
> index f6419632c6bc..46a9717fdda5 100644
> --- a/stand/libofw/devicename.c
> +++ b/stand/libofw/devicename.c
> @@ -98,7 +98,7 @@ ofw_common_parsedev(struct devdesc **dev, const char= *devspec, const char **path
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0if (ofw_path_to_handle(devspec, ofwtype, &am= p;rem_path) =3D=3D -1)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return (ENOENT);=
> -=C2=A0 =C2=A0 =C2=A0idev =3D malloc(sizeof(struct ofw_devdesc));
> +=C2=A0 =C2=A0 =C2=A0idev =3D calloc(sizeof(struct ofw_devdesc), 1); >=C2=A0 =C2=A0 =C2=A0 =C2=A0if (idev =3D=3D NULL) {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0printf("ofw= _parsedev: malloc failed\n");
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return (ENOMEM);=
> diff --git a/stand/libsa/dev.c b/stand/libsa/dev.c
> index 1edc843d508c..4f6932e96c48 100644
> --- a/stand/libsa/dev.c
> +++ b/stand/libsa/dev.c
> @@ -72,7 +72,7 @@ default_parsedev(struct devdesc **dev, const char *d= evspec,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0int unit, err;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0char *cp;
>
> -=C2=A0 =C2=A0 =C2=A0idev =3D malloc(sizeof(struct devdesc));
> +=C2=A0 =C2=A0 =C2=A0idev =3D calloc(sizeof(struct devdesc), 1);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0if (idev =3D=3D NULL)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return (ENOMEM);=
>
> diff --git a/stand/libsa/zfs/zfs.c b/stand/libsa/zfs/zfs.c
> index 70a102f6425d..2f7c1caaa4b5 100644
> --- a/stand/libsa/zfs/zfs.c
> +++ b/stand/libsa/zfs/zfs.c
> @@ -1643,7 +1643,7 @@ zfs_parsedev(struct devdesc **idev, const char *= devspec, const char **path)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0spa =3D spa_find_by_name(poolname);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0if (!spa)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return (ENXIO);<= br> > -=C2=A0 =C2=A0 =C2=A0dev =3D malloc(sizeof(*dev));
> +=C2=A0 =C2=A0 =C2=A0dev =3D calloc(sizeof(*dev), 1);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0if (dev =3D=3D NULL)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return (ENOMEM);=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0dev->pool_guid =3D spa->spa_guid;
> diff --git a/stand/uboot/devicename.c b/stand/uboot/devicename.c
> index 4ee9c7fd72c4..23670d7593a2 100644
> --- a/stand/uboot/devicename.c
> +++ b/stand/uboot/devicename.c
> @@ -102,7 +102,7 @@ uboot_parsedev(struct uboot_devdesc **dev, const c= har *devspec,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0}
>=C2=A0 =C2=A0 =C2=A0 =C2=A0if (dv =3D=3D NULL)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return(ENOENT);<= br> > -=C2=A0 =C2=A0 =C2=A0idev =3D malloc(sizeof(struct uboot_devdesc)); > +=C2=A0 =C2=A0 =C2=A0idev =3D calloc(sizeof(struct uboot_devdesc), 1);=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0err =3D 0;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0np =3D (devspec + strlen(dv->dv_name)); >



--00000000000065f309063dd3535f--