From: Leif Lindholm <leif.lindholm@linaro.org>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: [PATCH edk2-platforms v2 6/7] Platform/NinetySixBoards: add core driver for LS connector and config
Date: Thu, 22 Feb 2018 20:21:05 +0000 [thread overview]
Message-ID: <20180222202105.n7dtjqxpflsaeg3c@bivouac.eciton.net> (raw)
In-Reply-To: <CAKv+Gu8dCpG1ggwKO0KenwCMkUCXPpm9_fEgG+ZFe1ma+HX78Q@mail.gmail.com>
On Thu, Feb 22, 2018 at 07:10:52PM +0000, Ard Biesheuvel wrote:
> >>> +#define MEZZANINE_NONE 0x0
> >>> +#define MEZZANINE_SECURE96 0x1
> >>> +#define MEZZANINE_MAX 0x1
> >>
> >> Would this be simpler as an enum with a permanent final element called
> >> MaxMezzanineType? This seems like the common EDK2 (and even UEFI)
> >> pattern.
> >>
> >
> > Does C guarantee a certain size for enums? Because the struct below is
> > projected onto the EFI variable directly.
>
> OK, so apparently an enum is an int, unless you explicitly tell the
> compiler otherwise.
Not exactly.
Enums are compile-time resolved, so it is entirely within the
compiler's ability to handle this situation safely.
Try the following for yourself:
#include <stdio.h>
typedef enum {
TestFirst = 255,
TestMax
} MYTEST;
typedef struct {
unsigned char test;
} Foo;
int main(void)
{
Foo bar;
bar.test = TestFirst;
bar.test = TestMax;
printf("bar.test: %d\n", bar.test);
}
I'd be astonished if you can find a compiler that won't give you
something similar to:
warning: large integer implicitly truncated to unsigned type [-Woverflow]
bar.test = TestMax;
> That does mean the type field uses up 32 bits rather than 8, so I'd
> prefer to keep a UINT8 here instead.
Does the above change your opinion in any way?...
> I could still use 0x2 rather than 0x1 as the max value if you prefer.
...if not, that would be preferable, yes.
> >> I would prefer if we could get this one in with a
> >> #include <Uefi/UefiMultiPhase.h>
> >> instead.
> >>
> >
> > OK, but please chase this with the other maintainers then.
Done.
/
Leif
next prev parent reply other threads:[~2018-02-22 20:15 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-20 17:49 [PATCH edk2-platforms v2 0/7] Add Secure96 mezzanine support Ard Biesheuvel
2018-02-20 17:49 ` [PATCH edk2-platforms v2 1/7] Silicon/Atmel: add support for AtSha204a RNG Ard Biesheuvel
2018-02-22 13:08 ` Leif Lindholm
2018-02-23 15:33 ` Ard Biesheuvel
2018-02-20 17:49 ` [PATCH edk2-platforms v2 2/7] Platform/NinetySixBoards: introduce package and mezzanine protocol Ard Biesheuvel
2018-02-22 13:15 ` Leif Lindholm
2018-02-22 13:21 ` Ard Biesheuvel
2018-02-22 13:44 ` Leif Lindholm
2018-02-22 15:13 ` Ard Biesheuvel
2018-02-20 17:49 ` [PATCH edk2-platforms v2 3/7] Platform/NinetySixBoards: introduce I2C driver Ard Biesheuvel
2018-02-20 17:49 ` [PATCH edk2-platforms v2 4/7] Platform/NinetySixBoards: introduce LsConnector protocol Ard Biesheuvel
2018-02-22 15:29 ` Leif Lindholm
2018-02-20 17:49 ` [PATCH edk2-platforms v2 5/7] Platform/NinetySixBoards: add a driver for the Secure96 mezzanine board Ard Biesheuvel
2018-02-22 15:38 ` Leif Lindholm
2018-02-20 17:49 ` [PATCH edk2-platforms v2 6/7] Platform/NinetySixBoards: add core driver for LS connector and config Ard Biesheuvel
2018-02-22 15:59 ` Leif Lindholm
2018-02-22 19:00 ` Ard Biesheuvel
2018-02-22 19:10 ` Ard Biesheuvel
2018-02-22 20:21 ` Leif Lindholm [this message]
2018-02-20 17:49 ` [PATCH edk2-platforms v2 7/7] Platform/Socionext/DeveloperBox: add 96boards mezzanine support Ard Biesheuvel
2018-02-22 16:04 ` [PATCH edk2-platforms v2 0/7] Add Secure96 " Leif Lindholm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180222202105.n7dtjqxpflsaeg3c@bivouac.eciton.net \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox