From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io0-x232.google.com (mail-io0-x232.google.com [IPv6:2607:f8b0:4001:c06::232]) (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 174FB21E47D5E for ; Tue, 29 Aug 2017 07:58:42 -0700 (PDT) Received: by mail-io0-x232.google.com with SMTP id d81so21005818ioj.4 for ; Tue, 29 Aug 2017 08:01:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Ho+/dLky64FIJhUltWB6jta2tB153A19smGJcGe6BiA=; b=TqykuH8XrvQxJCXVIOVXCu3urJKdGBhf3sIMGP1OEM3FNJ4XRvpzrnPnQeU03+ZeUJ UJuT7Zjiy2CK5xW1mKtOIGfqmKHxXIIurr4eechmE6dDBfy7K2RxelUix1OJzRZBiEuu OXJFrzev4PoSljZe11AhLCZ59r5Ho32pQ5VuI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Ho+/dLky64FIJhUltWB6jta2tB153A19smGJcGe6BiA=; b=EaSNkXF2U4/vDXG0/mOIhgSGXJqDp0Ip3t09RpupmodJHDoUyNd7lFuraKN83KdXxt M0ZodU86O+Y2JBlTggYOBhUmnKBbk6xzalhUq8ePMkFpm+qJ4/503Dp3VfWd6FMtaPXJ LkL1a0dbp1f6JoB4AoQrHH8iMh8R8NUrK9aoAi+IlraoClmKt8yS1KBoCvfQSGsY88Pq 1jEJ6LgTHARl6r0g05Eo0BCpY/P+lZ2AbDkuBCBNvvt1cAW1GT0fhOq1uvw/XAQOlNRt tgPaCNUTYMYuuxuECza0T+ZHyNrCoZA5yMhxgcbAUUHMU2mWXWnaGgdIpBAu3CO1ihZA cVOQ== X-Gm-Message-State: AHYfb5j2kNEWcU52lmmGFkB2qBa89pyes3QZtiR4JU0+M8iE5HbMVg7g Sku6qkTT/f025sJ9F8YAqm7FacVR5ph4 X-Received: by 10.36.107.145 with SMTP id v139mr4475122itc.41.1504018881636; Tue, 29 Aug 2017 08:01:21 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.162.1 with HTTP; Tue, 29 Aug 2017 08:01:21 -0700 (PDT) In-Reply-To: <20170829130926.17396-1-hao.a.wu@intel.com> References: <20170829130926.17396-1-hao.a.wu@intel.com> From: Ard Biesheuvel Date: Tue, 29 Aug 2017 16:01:21 +0100 Message-ID: To: Hao Wu Cc: "edk2-devel@lists.01.org" , Ruiyu Ni Subject: Re: [PATCH] SourceLevelDebugPkg/DebugAgentCommon: Use global variable for revision 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: , X-List-Received-Date: Tue, 29 Aug 2017 14:58:42 -0000 Content-Type: text/plain; charset="UTF-8" On 29 August 2017 at 14:09, Hao Wu wrote: > Since some static code checkers complain that comparing two macros will > generate a constant result, this commit uses a global variable to > reflect the revision information of the debug agent, rather than using a > macro directly. > > Cc: Ruiyu Ni > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Hao Wu > --- > .../Library/DebugAgent/DebugAgentCommon/DebugAgent.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c > index f156fe24db..93af009f96 100644 > --- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c > +++ b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c > @@ -130,7 +130,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_VECTOR_HANDOFF_INFO mVectorHandoffInfoDebugAge > } > }; > > -GLOBAL_REMOVE_IF_UNREFERENCED UINTN mVectorHandoffInfoCount = sizeof (mVectorHandoffInfoDebugAgent) / sizeof (EFI_VECTOR_HANDOFF_INFO); > +GLOBAL_REMOVE_IF_UNREFERENCED UINTN mVectorHandoffInfoCount = sizeof (mVectorHandoffInfoDebugAgent) / sizeof (EFI_VECTOR_HANDOFF_INFO); > +GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mDebugAgentRevision = DEBUG_AGENT_REVISION; > > /** > Calculate CRC16 for target data. > @@ -1564,7 +1565,7 @@ ReadMemoryAndSendResponsePacket ( > // Compression/decompression support was added since revision 0.4. > // Revision 0.3 shouldn't compress the packet. > // > - if (DEBUG_AGENT_REVISION >= DEBUG_AGENT_REVISION_04) { > + if (mDebugAgentRevision >= DEBUG_AGENT_REVISION_04) { > // > // Get the compressed data size without modifying the packet. > // > @@ -2192,7 +2193,7 @@ CommandCommunication ( > break; > > case DEBUG_COMMAND_GET_REVISION: > - DebugAgentRevision.Revision = DEBUG_AGENT_REVISION; > + DebugAgentRevision.Revision = mDebugAgentRevision; > DebugAgentRevision.Capabilities = DEBUG_AGENT_CAPABILITIES; > Status = SendDataResponsePacket ((UINT8 *) &DebugAgentRevision, (UINT16) sizeof (DEBUG_DATA_RESPONSE_GET_REVISION), DebugHeader); > break; > -- > 2.12.0.windows.1 > Can we *please* fix the tools instead? mDebugAgentRevision has external linkage, and so the compiler is forced to perform this check at runtime instead of at build time. Or at least use a STATIC variable so the compiler can see that mDebugAgentRevision is never modified from its default value.