From patchwork Thu Dec 7 17:38:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 121034 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8648306qgn; Thu, 7 Dec 2017 09:38:07 -0800 (PST) X-Google-Smtp-Source: AGs4zMZzgy/CwWjx7Yo6gEsgswtB4Ifsug4duajQ+82GGWYJh3iljxsuJXPU0Zy0Kqm8gwbMmJxO X-Received: by 10.84.218.193 with SMTP id g1mr26853109plm.63.1512668287068; Thu, 07 Dec 2017 09:38:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512668287; cv=none; d=google.com; s=arc-20160816; b=Xiek74IPpF7XekJFi1X6xlnp/NcGLfsfL30N4U0PTBa2Zt5qR3FeQB6/sL5w+4xfBG 1yP3RwYYIMchgW4RrFEvPeX1tSU8d4leeU3gvCoO5Mo5e06fLG92RkT6G6Cw8VYDGbxz f4jQHZFgImyXn/9X66epgxQis1FRjSzkM8Qky91S+1sOXRlN8AKYOkKKk9b1VDsjsIHH d12hCpUCsta8ssyBKbh17aN5YrvJtKfWz8zYzh34WlNF8/YRj8YV6k+tb6rY7jjqfnbl LqBaR1rlweCh5lBi6ucj7hvxSdr/KFxAA+Bf0l0ImTn6z5hI1e5Ml1jM0Ve52aINgPq1 yEJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=X3utXHzdeA70D3s5YMdaK4J/Vxd69mc9zfbyxpeA/g0=; b=Tcj73AdqwOhZ7kVsjBtrmIOiS86MClch4NDPIw9qRKxLv9NhcXqJvclfwy4GHDS6dF JOlzb8qtE35tKSzmtSkccvcbVPhuSfvJcTkiv54hOjCb/M9lhfVx2Ej7PDtpyDUZFWS+ x3B6VG9rkDQKigWHU+stdCXom1s0mXb/GfkAS6inXbg/7z2lgkOFj2qbHrtpvt5yKSZV Yf28w6oOOuhBq5N/NR3eZZMkgvH9qGC77DZbbwdWQ5PBf0QLSWvhVRyKnZ12uPFctGyd Fr87CPb9s9VpyR0ZbyOulyR0TmmRTn4TEtrd9GRZHRnHlJnQFmYQwTJ+7If/JonLCD9Z kMeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=VBlMMv2g; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id k124si4037706pgc.672.2017.12.07.09.38.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 09:38:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=VBlMMv2g; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 321B1221EA0C9; Thu, 7 Dec 2017 09:33:33 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::244; helo=mail-wr0-x244.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x244.google.com (mail-wr0-x244.google.com [IPv6:2a00:1450:400c:c0c::244]) (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 7A938221EA0A4 for ; Thu, 7 Dec 2017 09:33:31 -0800 (PST) Received: by mail-wr0-x244.google.com with SMTP id q9so8328599wre.7 for ; Thu, 07 Dec 2017 09:38:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=9Bl92/SYwnmb48bQWQSk3udal/hDXiqoOQZZD5xUbZk=; b=VBlMMv2g8WRt5UwQkaxs2GvD1KGuOWbWPvgX2pJQVpDtGFtNoOoEV+Hw3S/bWDSlu2 hudU971IqfYxfRMbSY49VRdWnkBebWX7/RllI/otsTVn39steA54clnq8Y0i9S5iVPeD fVjs5POHfqkdocHksh18joe7scIk4CdF1JuL0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=9Bl92/SYwnmb48bQWQSk3udal/hDXiqoOQZZD5xUbZk=; b=Jcih2Qjcr4bx+NFmWEWuzKNvA7t+yAQi5vfrDAtAEfhk1Qb1vA3NkA6yBTwWnC/TVK P0e042TXtAkQNtXaPmFzKIbAdOjz7bWrfwdfuCkuYmvemlLGFyxvZQkZPs0JzciG2/3G Ew7xsRGZtTXaH6ECZZYedGI4AnystjzfBKDdDRUvk1LXC1Mr4cICi+ca945DWuRBBUEa M6RvAs/wRDOylW3E0Gbn424BECBhYGxUA40eBcx9Ara310nzc7BRzrLF3dp8RisqzCZx gIPEfpKAa7hJHIyq3fwrkgDHBdk7GlXsG1HlhW2O17oOVH55FnTOLoQcoGytazuBZxoF tw1w== X-Gm-Message-State: AJaThX43ngWeEgdx1ENSrWCfTJVlFZ3HqHP4IoogV2m8If/ZKGgXWtbo O61/s8fyGhsoOU91LbcaXKDmRnwhhQM= X-Received: by 10.223.171.13 with SMTP id q13mr24527081wrc.120.1512668283002; Thu, 07 Dec 2017 09:38:03 -0800 (PST) Received: from vanye.hemma.eciton.net (cpc92316-cmbg19-2-0-cust118.5-4.cable.virginm.net. [82.12.0.119]) by smtp.gmail.com with ESMTPSA id i8sm5951939wrb.29.2017.12.07.09.38.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 09:38:01 -0800 (PST) From: Leif Lindholm To: edk2-devel@lists.01.org Date: Thu, 7 Dec 2017 17:38:00 +0000 Message-Id: <20171207173800.26730-1-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 Subject: [edk2] [PATCH v2] BaseTools: align ERROR/WARNING/RETURN macros with MdePkg versions X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liming Gao MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" BaseTools' BaseTypes.h defined the ENCODE_ERROR macro as #define ENCODE_ERROR(a) ((RETURN_STATUS)(MAX_BIT | (a))) whereas MdePkg defines it as #define ENCODE_ERROR(StatusCode) ((RETURN_STATUS)(MAX_BIT | (StatusCode))) When building with GCC 6.3 (at least) the former triggers "error: overflow in implicit constant conversion [-Werror=overflow]" Resolve this by aligning it with the latter one. This also requires aligning the BaseTools typedef of RETURN_STATUS with the MdePkg one: INTN -> UINTN. While at it, update adjacent ENCODE_WARNING and RETURN_ERROR as well. Add an explicit initialization of *Alignment to 0 in GenFfs.c GetAlignmentFromFile to get rid of a warning occuring with GCC after this change (-Werror=maybe-uninitialized). Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Leif Lindholm --- v2 updated for ENCODE_WARNING and RETURN_ERROR, as requested by Liming. BaseTools/Source/C/GenFfs/GenFfs.c | 1 + BaseTools/Source/C/Include/Common/BaseTypes.h | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Liming Gao diff --git a/BaseTools/Source/C/GenFfs/GenFfs.c b/BaseTools/Source/C/GenFfs/GenFfs.c index e2fb3e0d1e..3b4a9b7761 100644 --- a/BaseTools/Source/C/GenFfs/GenFfs.c +++ b/BaseTools/Source/C/GenFfs/GenFfs.c @@ -529,6 +529,7 @@ GetAlignmentFromFile(char *InFile, UINT32 *Alignment) InFileHandle = NULL; PeFileBuffer = NULL; + *Alignment = 0; memset (&ImageContext, 0, sizeof (ImageContext)); diff --git a/BaseTools/Source/C/Include/Common/BaseTypes.h b/BaseTools/Source/C/Include/Common/BaseTypes.h index 198647ab95..08b60bae11 100644 --- a/BaseTools/Source/C/Include/Common/BaseTypes.h +++ b/BaseTools/Source/C/Include/Common/BaseTypes.h @@ -170,15 +170,15 @@ // EFI Error Codes common to all execution phases // -typedef INTN RETURN_STATUS; +typedef UINTN RETURN_STATUS; /// /// Set the upper bit to indicate EFI Error. /// -#define ENCODE_ERROR(a) (MAX_BIT | (a)) +#define ENCODE_ERROR(a) ((RETURN_STATUS)(MAX_BIT | (a))) -#define ENCODE_WARNING(a) (a) -#define RETURN_ERROR(a) ((a) < 0) +#define ENCODE_WARNING(a) ((RETURN_STATUS)(a)) +#define RETURN_ERROR(a) (((INTN)(RETURN_STATUS)(a)) < 0) #define RETURN_SUCCESS 0 #define RETURN_LOAD_ERROR ENCODE_ERROR (1)