From: AJ Lewis Subject: Re: tiny patch: avoid an unnecessary test Date: Fri, 16 Mar 2007 09:25:29 -0500 Message-ID: <20070316142528.GD5454@fenrir.local> References: <87fy85bnic.fsf@rho.meyering.net> <20070316134701.GA5454@fenrir.local> Reply-To: device-mapper development Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0608831823==" Return-path: In-Reply-To: <20070316134701.GA5454@fenrir.local> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com To: device-mapper development List-Id: dm-devel.ids --===============0608831823== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="J9fO++IT6debZ01Z" Content-Disposition: inline --J9fO++IT6debZ01Z Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Never mind - looking at the optimistic memory allocation stuff again, you'll just get OOMed. On Fri, Mar 16, 2007 at 08:47:02AM -0500, AJ Lewis wrote: > Actually, there's a chance you'd get a NULL pointer error if you don't ha= ve > that check if I'm reading the context right. Linux doesn't guarantee mal= loc > will return NULL if memory is unavailable, you only get the error when you > attempt to write to memory. So if there is an allocation error, you're o= nly > going to see it in the memset. >=20 > -- > AJ >=20 > On Fri, Mar 16, 2007 at 09:28:43AM +0100, Jim Meyering wrote: > > Not a big deal (barely worth mentioning), but it might save > > someone else a little time wondering "why". > >=20 > > 2007-03-11 Jim Meyering > >=20 > > Remove unnecessary test. > > * dmeventd/dmeventd.c (_alloc_dso_data): Don't test known-non-NULL > > memset return value. > >=20 > > 2007-03-11 Jim Meyering > > Index: dmeventd/dmeventd.c > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > RCS file: /cvs/dm/device-mapper/dmeventd/dmeventd.c,v > > retrieving revision 1.46 > > diff -u -p -r1.46 dmeventd.c > > --- dmeventd/dmeventd.c 2 Feb 2007 17:08:51 -0000 1.46 > > +++ dmeventd/dmeventd.c 12 Mar 2007 14:39:35 -0000 > > @@ -258,8 +258,8 @@ static struct dso_data *_alloc_dso_data( > > if (!ret) > > return NULL; > >=20 > > - if (!memset(ret, 0, sizeof(*ret)) || > > - !(ret->dso_name =3D dm_strdup(data->dso_name))) { > > + memset(ret, 0, sizeof(*ret)); > > + if (!(ret->dso_name =3D dm_strdup(data->dso_name))) { > > dm_free(ret); > > return NULL; > > } > >=20 > > -- > > dm-devel mailing list > > dm-devel@redhat.com > > https://www.redhat.com/mailman/listinfo/dm-devel > -- > dm-devel mailing list > dm-devel@redhat.com > https://www.redhat.com/mailman/listinfo/dm-devel --J9fO++IT6debZ01Z Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Darwin) iD8DBQFF+qjYn95okVnkz6cRAiWcAJ9lC1DDiXtxSxIjFFvtlDSt3tM/wgCeMKGZ /QU14+MnEp+L4ir2qfRNZ9I= =30lF -----END PGP SIGNATURE----- --J9fO++IT6debZ01Z-- --===============0608831823== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============0608831823==--