Re: C++ pushback

J.A. Magallon
2006-04-24T22:16:19Z

[-- Attachment #1: Type: text/plain, Size: 1397 bytes --]

On Mon, 24 Apr 2006 22:52:12 +0100, Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:

> 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
> > convoluted manner as to be unmaintainable and unreadable.
>
> So can C.
>
> > All of the hidden memory allocations from constructor/destructor
> > operatings can and do KILL OS PERFORMANCE.
>
> 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 = kmalloc(sizeof(*sbi), GFP_KERNEL);
if (!sbi)
return -ENOMEM;
sb->s_fs_info = sbi;
memset(sbi, 0, sizeof(*sbi));
sbi->s_mount_opt = 0;
sbi->s_resuid = EXT3_DEF_RESUID;
sbi->s_resgid = EXT3_DEF_RESGID;

and

SuperBlock() : s_mount_opt(0), s_resuid(EXT3_DEF_RESUID), s_resgid(EXT3_DEF_RESGID)
{}

...
sbi = 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 sex:
werewolf!able!es \ It's better when it's free
Mandriva Linux release 2006.1 (Cooker) for i586
Linux 2.6.16-jam9 (gcc 4.1.1 20060330 (prerelease)) #1 SMP PREEMPT Tue

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 191 bytes --]