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] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 2 Dec 2021 15:12:13 -0800
From:   Andrew Morton <akpm@...ux-foundation.org>
To:     Xin Hao <xhao@...ux.alibaba.com>
Cc:     sj@...nel.org, linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH RESEND MERGE REQUEST] mm/damon: move damon_rand()
 definition into damon.h

On Thu,  2 Dec 2021 15:58:59 +0800 Xin Hao <xhao@...ux.alibaba.com> wrote:

> damon_rand() is called in three files:damon/core.c, damon/
> paddr.c, damon/vaddr.c, i think there is no need to redefine
> this twice, So move it to damon.h will be a good choice.

Fair enough.

> +/* Get a random number in [l, r) */
> +#define damon_rand(l, r) (l + prandom_u32_max(r - l))

This shouldn't be implemented as a macro, for all the usual reasons
(typechecking, side-effects, ugliness, code-documentation site, etc).

In particular, this expression references `l' twice, so calling

	damon_rand(a++, b);

will increment `a' twice, surprise surprise.

Can someone please send a followup patch to convert this (and any
similar damon macros) into (probably static inlined) C functions?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ