Le 26/02/2020 à 03:40, Jason Yan a écrit :


在 2020/2/20 21:48, Christophe Leroy 写道:


Le 06/02/2020 à 03:58, Jason Yan a écrit :
      /*
       * Decide which 64M we want to start
       * Only use the low 8 bits of the random seed
       */
-    index = random & 0xFF;
+    unsigned long index = random & 0xFF;

That's not good in terms of readability, index declaration should remain at the top of the function, should be possible if using IS_ENABLED() instead

I'm wondering how to declare a variable inside a code block such as if (IS_ENABLED(CONFIG_PPC32)) at the top of the function and use the variable in another if (IS_ENABLED(CONFIG_PPC32)). Is there any good idea?

You declare it outside the block as usual:

        unsigned long some_var;

        if (condition) {
                some_var = something;
        }
        do_many_things();
        do_other_things();

        if (condition)
                return some_var;
        else
                return 0;


Christophe

Reply via email to