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]
Message-ID: <45FB3D74.2040907@student.ltu.se>
Date:	Sat, 17 Mar 2007 01:59:32 +0100
From:	Richard Knutsson <ricknu-0@...dent.ltu.se>
To:	Jan Engelhardt <jengelh@...ux01.gwdg.de>
CC:	Arnaldo Carvalho de Melo <acme@...stprotocols.net>,
	Kernel Janitors List <kernel-janitors@...ts.osdl.org>,
	linux-kernel@...r.kernel.org
Subject: Re: [RFC] A need for "yesno"-function? (and "cleanup" of kernel.h)

Jan Engelhardt wrote:
> On Mar 16 2007 16:24, Richard Knutsson wrote:
>   
>>>> char yesno_chr(const bool value)
>>>> {
>>>>        return "ny"[value];
>>>> }
>>>>
>>>> char *yesno_str(const bool value)
>>>> {
>>>>        return &"no\0yes"[3 * value];
>>>> }
>>>>         
>
> static/extern const char *const yesno[] = {"no", "yes"};
> static inline const char *yesno_str(bool value)
>   
Should we use "inline"? Isn't it better to leave that to the compiler?
Why the "const"?
> {
> 	return yesno[value];
> }
>   
That's better :)
But I think a simple

static char *yesno_str(bool value)
{
	return value ? "yes" : "no";
}
is to prefer, don't you? It is simpler and we don't need to deal with an unnecessary array (unless it may be used by itself, that is. Then I would go for your implementation).

> #or
> #define yesno_str(value) yesno[!!(value)]
>   
Why not "(bool)value" instead? We cast all the other times we want a 
something to be of a different kind.

Any thoughts where to put a function like this?

Richard Knutsson


-
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