Re: C++ pushback

From: J.A. Magallon
Date: Mon Apr 24 2006 - 18:16:05 EST


--Sig_kBUjkrZJsttjK2f5DWPa0yz
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

On Mon, 24 Apr 2006 22:52:12 +0100, Alan Cox <alan@xxxxxxxxxxxxxxxxxxx> wro=
te:

> On Llu, 2006-04-24 at 15:36 -0600, Jeff V. Merkey wrote:
> > C++ in the kernel is a BAD IDEA. C++ code can be written in such a=20
> > convoluted manner as to be unmaintainable and unreadable.
>=20
> So can C.=20
>=20
> > All of the hidden memory allocations from constructor/destructor=20
> > operatings can and do KILL OS PERFORMANCE.=20
>=20
> This is one area of concern. Just as big a problem for the OS case is
> that the hidden constructors/destructors may fail.

Tell me what is the difference between:


sbi =3D kmalloc(sizeof(*sbi), GFP_KERNEL);
if (!sbi)
return -ENOMEM;
sb->s_fs_info =3D sbi;
memset(sbi, 0, sizeof(*sbi));
sbi->s_mount_opt =3D 0;
sbi->s_resuid =3D EXT3_DEF_RESUID;
sbi->s_resgid =3D EXT3_DEF_RESGID;

and

SuperBlock() : s_mount_opt(0), s_resuid(EXT3_DEF_RESUID), s_resgid(EXT3=
_DEF_RESGID)
{}

...
sbi =3D new SuperBlock;
if (!sbi)
return -ENOMEM;

apart that you don't get members initalized twice and get a shorter code :).

--
J.A. Magallon <jamagallon()able!es> \ Software is like se=
x:
werewolf!able!es \ It's better when it's fr=
ee
Mandriva Linux release 2006.1 (Cooker) for i586
Linux 2.6.16-jam9 (gcc 4.1.1 20060330 (prerelease)) #1 SMP PREEMPT Tue

--Sig_kBUjkrZJsttjK2f5DWPa0yz
Content-Type: application/pgp-signature; name=signature.asc
Content-Disposition: attachment; filename=signature.asc

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFETU4xRlIHNEGnKMMRAuoMAKCVSsESkrxxAiyYXS2+/GljU/laCwCgnCtD
6Ni1KLZ2WkSCPVghz/K7x/8=
=PgXW
-----END PGP SIGNATURE-----

--Sig_kBUjkrZJsttjK2f5DWPa0yz--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/