lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Tue, 23 Dec 2014 12:14:44 +0100
From:	Rasmus Villemoes <linux@...musvillemoes.dk>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Fabian Frederick <fabf@...net.be>, linux-kernel@...r.kernel.org,
	joe@...ches.com, ocfs2-devel@....oracle.com,
	Mark Fasheh <mfasheh@...e.com>
Subject: Re: [Ocfs2-devel] [PATCH 1/1 linux-next] ocfs2: remove unnecessary sizeof(char)

On Mon, Dec 22 2014, Andrew Morton <akpm@...ux-foundation.org> wrote:

> On Mon, 22 Dec 2014 20:05:09 +0100 Fabian Frederick <fabf@...net.be> wrote:
>
>>  
>> -	replay_map = kzalloc(sizeof(struct ocfs2_replay_map) +
>> -			     (osb->max_slots * sizeof(char)), GFP_KERNEL);
>> +	replay_map = kzalloc(sizeof(struct ocfs2_replay_map) + osb->max_slots,
>> +			     GFP_KERNEL);
>>  
>
> I dunno.  The code at present isn't particularly idiomatic, but it has
> some documentation value and says "I know what I'm doing".
>
> It would be better if it was
>
> 	kzalloc(sizeof(struct ocfs2_replay_map) *
> 		sizeof(struct ocfs2_replay_map.rm_replay_slots[0]), ...);
>
> And it would be better if C permitted that ;)
>
> 	kzalloc(sizeof(struct ocfs2_replay_map) *
> 		sizeof((struct ocfs2_replay_map *)0)->rm_replay_slots[0]), ...);
>
> yuk.

Well, the yuckiness could be hidden behind FIELD_SIZEOF. CodingStyle
explicitly mentions that macro. No opinion on whether it's worth it in
this case.

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ