l4-hurd
[Top][All Lists]
Advanced

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

Re: duplicate flag checks


From: Neal H. Walfield
Subject: Re: duplicate flag checks
Date: Wed, 08 Dec 2004 09:16:57 +0000
User-agent: Wanderlust/2.10.1 (Watching The Wheels) SEMI/1.14.6 (Maruoka) FLIM/1.14.6 (Marutamachi) APEL/10.6 Emacs/21.2 (i386-debian-linux-gnu) MULE/5.0 (SAKAKI)

> I was kinda wondering about some of the laden code, more specifically in 
> the ia32-cmain.c file. In the cmain function I'm seeing this:
> if (!CHECK_FLAG (mbi->flags, 0) && !CHECK_FLAG (mbi->flags, 6))
>      panic ("Bootloader did not provide a memory map");
> 
> But then later on in the find_components and debug_dump functions I see 
> the exact same checks.  So maybe I'm missing something here, but why not 
> just check them once and be done with it?  Or maybe the reasoning is 
> that the compiler will just optimize it all away anyway?

They are not exactly the same checks.  The first check makes sure that
at least one of flag 0 and flag 6 is set.  The code in find_components
does some things if flag 6 is set, if not and flag 0 is set (which it
must be according to the above check) then it does some others..
Arguably, we could just do:


  /* Now add what GRUB tells us.  */
  if (CHECK_FLAG (mbi->flags, 6))
    {
       ...
    }
  else
    {
       assert (CHECK_FLAGS (mbi->flags, 0));
       ...
    }

but the way it is currently written is not wrong.





reply via email to

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