Skip to content

Provide a mechanism to avoid using #ifdef everywhere

Detlev Zundel u-boot 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest posting 2/20 of 8 patches 0 repliesNew
  2. v4 posting 1/20 of 8 patches 0 repliesSuperseded

Patches in v4 posting 2/2 No applies recorded yet

None of the 8 patches the cover letter announces are in this archive.

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.

Read the v4 thread

Cover letter [U-Boot] [PATCH v4 0/8] Provide a mechanism to avoid using #ifdef everywhere

Hi Simon,

[...]

Quoted 5 lines
Quoted 3 lines

I think the Linux code has two big advantages - for one, we increase the overlap with Linux kernel proper and secondly we keep the 'grep'ability of the names which I really missed in your proposal.

Yes that seems reasonable.

Ok, I'm glad we are in agreement.

Quoted 41 lines
Quoted 41 lines
Quoted 3 lines

Many of U-Boot's options are not just yes/no, so I'm not sure what will happen with those. Perhaps they just can't be used with this macro? Part of my intent was to allow any option to be used.

In those cases the defines then are a "shortcut" to using a boolean + a value and we can make it work by introducing this boolean? I have no idea of how much work this would be, but it might be worthwhile getting some real numbers to that.

Quoted 31 lines

So for example you can do this:

struct {

Quoted 7 lines

const char *str;
u_int len;
int retry;
const char *conf; /* Configuration value */
}
delaykey [] = {
{ str: getenv("bootdelaykey"), retry: 1,

Quoted 8 lines

conf: autoconf_autoboot_delay_str() },
{ str: getenv("bootdelaykey2"), retry: 1,
conf: autoconf_autoboot_delay_str2() },
{ str: getenv("bootstopkey"), retry: 0,
conf: autoconf_autoboot_stop_str() },
{ str: getenv("bootstopkey2"), retry: 0,
conf: autoconf_autoboot_stop_str2() },
};

or this:

/* don't retry auto boot? */

Quoted 3 lines

if (autoconf_boot_retry_time() &&

    !delaykey[i].retry)

retry_time = -1;

Note that autoconf_boot_retry_time() will return 0 if the CONFIG is not defined, or if its value is 0.

Quoted 8 lines
Quoted 3 lines

I'm having real trouble figuring out what this would do on first sight. Of course you could call me lazy, but by experience I tend to favour solutions that do not need geniuses to understand ;)

Well it is simply that we currently have options which may or may not be defined. If they are not defined, then it is an error to refer to them, so they must be guarded by an #ifdef. By defining them to 0 when not defined, we can avoid that guard.

Ok, I see. But in this way we are actually shutting up the compiler on code paths that we did not have before. This in effect is a "rather be quiet than error" strategy and I'm not sure that I want to use that when doing such changes. Call me old-fashioned, but I'd prefer to throw an error and fix it after thinking it through from todays perspective

(I can say this easily if I'm not the one who has to do the fixes ;)

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

It seems to me we should provide the Linux feature in U-Boot as part of the Kconfig stuff, and see where it takes us. Combined with a bit more rationalisation of things like main.c it might be enough.

Quoted 8 lines
Quoted 3 lines

Why not reimplement your patch set along those lines? I still really would _love_ to see us using the compiler more to check for errors and reduce the number of "potential source code combination" that we have.

Well certainly I could, but I did not want to do this while Kbuild/Kconfig is in progress, and we are not quite clear on what to do. I think Kbuild is done - we will probably get the Linux autoconf stuff for free with Kconfig which I understand is coming very soon.

This makes a lot of sense yes. Actually I'm pretty excited about this excellent and continuous work from Masahiro-san on that topic!

Quoted 2 lines

After that I can certainly take another look at main.c and see how it can be improved.

Sure, its only that I wanted to keep the ball rolling as I really believe the wins to be had from such a change are substantial for our codebase.

Cheers
Detlev

Signature · 6 lines
Golden rule #12:   When the comments do not match the code, they probably are
both wrong. -- Steven Rostedt <[email protected]>
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de