From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::230; helo=mail-wr0-x230.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x230.google.com (mail-wr0-x230.google.com [IPv6:2a00:1450:400c:c0c::230]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5743E222630AB for ; Thu, 22 Feb 2018 12:15:09 -0800 (PST) Received: by mail-wr0-x230.google.com with SMTP id u49so11855941wrc.10 for ; Thu, 22 Feb 2018 12:21:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Fn+Oh2OQsC3iP7q0bpG2GRvF9bMSNE9sOMyDq9N2+Lw=; b=RIlffY/+RnBKZyR6O5ksEpV4MFgdS09mL/iwh22GHqNhFBrzypngzXkKtentQ8AK7P +QZH8zEERpkQpwZsjR1KcqxTEPZsMSMQvMLh3ufeaPkQZzzCcQ7QeUA+3FKvm5UBRwVH UFioed1iN9c+y4+PBVZ7XrmjPODESxpwun23g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Fn+Oh2OQsC3iP7q0bpG2GRvF9bMSNE9sOMyDq9N2+Lw=; b=j2pSYT1tbG/oT3PD6HSB7NusKSekiW/RX2kL96MllZ8s9cwNeng1jfZY2FsXfabeiP TYg+SogMdANXaXpFwvvmcGTi0RutgD20249eYYkdjo/eUyUrUXe8Kk+GfT/NkhfVYHtm i+uH2xsXDGgMrqaCjld21+b/JAHkZba+SO55TM1jXWfhaUjw4fNKuMdiyoIE9XxebTtv p+eDq1/H4wYi8Qoe3LlCuYWU9aeV4MQWyxdJt7+M0GYya4usX4nb6OrT2K4KYlZerGHx /3R379ULQp8D9iRexVIi4GwiYWErimvwNvdkJKpvOFKFlwTDypEMz6Czbz9uMEZSA5Ug QTQg== X-Gm-Message-State: APf1xPAbnubffRXEI1Fp19s+2nXO9Ij8tM8SjgUD2LKxM99B+QzJH+Qd yjr6GeWaNIw3juzAljfEHaNTypbLBZg= X-Google-Smtp-Source: AH8x227SzOVZtblvLGzwPPIZgdwFGltQvRnrlGhVgcPmrU6mHVgPJ8I0dG7UELLpehMr+RtLeMpnLA== X-Received: by 10.223.130.76 with SMTP id 70mr7377611wrb.95.1519330868558; Thu, 22 Feb 2018 12:21:08 -0800 (PST) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id m6sm290012wmb.6.2018.02.22.12.21.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Feb 2018 12:21:07 -0800 (PST) Date: Thu, 22 Feb 2018 20:21:05 +0000 From: Leif Lindholm To: Ard Biesheuvel Cc: "edk2-devel@lists.01.org" Message-ID: <20180222202105.n7dtjqxpflsaeg3c@bivouac.eciton.net> References: <20180220174944.525-1-ard.biesheuvel@linaro.org> <20180220174944.525-7-ard.biesheuvel@linaro.org> <20180222155916.4ppzhoggyswdvp3i@bivouac.eciton.net> MIME-Version: 1.0 In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [PATCH edk2-platforms v2 6/7] Platform/NinetySixBoards: add core driver for LS connector and config X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Feb 2018 20:15:10 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 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 > >> instead. > >> > > > > OK, but please chase this with the other maintainers then. Done. / Leif