Re: C++ pushback

From: J.A. Magallon
Date: Tue Apr 25 2006 - 16:10:07 EST


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

On Tue, 25 Apr 2006 13:09:47 +0400, Nikita Danilov <nikita@xxxxxxxxxxxxx> w=
rote:

> J.A. Magallon writes:
>=20
> [...]
>=20
> >=20
> > Tell me what is the difference between:
> >=20
> >=20
> > 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;
> >=20
> > and
> >=20
> > SuperBlock() : s_mount_opt(0), s_resuid(EXT3_DEF_RESUID), s_resgid=
(EXT3_DEF_RESGID)
> > {}
> >=20
> > ...
> > sbi =3D new SuperBlock;
> > if (!sbi)
> > return -ENOMEM;
> >=20
> > apart that you don't get members initalized twice and get a shorter co=
de :).
>=20
> The difference is that second fragment doesn't mention GFP_KERNEL, so
> it's most likely wrong. Moreover it's shorter only because it places
> multiple initializations on the same like, hence, contradicting
> CodingStyle.
>=20

Well, you could always have=20

sbi =3D new(GPF_KERNEL) SuperBlock;

And CodingStyle was written for C.

Just to make a thing clear: I'm not advocating to include C++ support in
current kernel. I just say that the only valid argument is that
'KERNEL IS C', and interfacing C with C++ just would add bloat and errors.
There is no technical argument to reject to write an OS kernel in C++.
It would not be slower not more complicated, and it will be probably safer
because it leaves less things (from thost you always _must_ do) to
programmers memories.

--
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_xw6ijRqy1HnfcEBgQSZZ09C
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)

iD8DBQFEToIYRlIHNEGnKMMRArA1AJ0XHp4U69kMNDk/z2Alfa0jOvKmPACgnbKl
qwXJ12zJn/ME+8XgDNGSzl8=
=8d/Q
-----END PGP SIGNATURE-----

--Sig_xw6ijRqy1HnfcEBgQSZZ09C--
-
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/