bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC] kern: simple futex for gnumach (version 6)


From: Ivan Shmakov
Subject: Re: [RFC] kern: simple futex for gnumach (version 6)
Date: Fri, 27 Dec 2013 19:59:54 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

>>>>> Richard Braun <rbraun@sceen.net> writes:
>>>>> On Fri, Dec 27, 2013 at 04:28:33PM +0100, Marin Ramesa wrote:

[…]

 >> +static futex_hash_table_t table = NULL; 
 >> +static unsigned int max_hash_val = 0;

 > I strongly recommend using the module namespace for everything
 > global, including static variables and functions.  Otherwise ...

 >> +int futex_init(futex_t futex, int *address)
 >> +{
 >> +   if (table == NULL) {

 > ... you may wonder where things such as table here are from.

        This is actually a simple question in C.  It may be different in
        other languages, even if considered “close” to C, but here,
        ‘table’ suggests a static global variable almost invariably.

        That being said, “namespacing” such identifiers wouldn’t hurt.

[…]

 >> + if ((table->futex_elements =
 >> (futex_t)kalloc((max_hash_val+1)*sizeof(futex_t))) == NULL) {

 > Another bad practice warning, don't put statements with side effects
 > in conditional expressions.

        I tend to disagree on this one, on more or less the same grounds
        I’m recommending the use of some_variable += another_variable
        instead of some_variable = some_variable + another_variable.
        Arguably, the use of the result of an assignment in a test makes
        the intent /clearer,/ and saves one of a silly mistake of
        assigning to one variable, and then using some another (say, one
        with a similar name) in the test just a line or so below.

[…]

-- 
FSF associate member #7257



reply via email to

[Prev in Thread] Current Thread [Next in Thread]