public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: Hao Wu <hao.a.wu@intel.com>
Cc: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
	Ruiyu Ni <ruiyu.ni@intel.com>
Subject: Re: [PATCH] SourceLevelDebugPkg/DebugAgentCommon: Use global variable for revision
Date: Tue, 29 Aug 2017 16:01:21 +0100	[thread overview]
Message-ID: <CAKv+Gu-s9TZRY02CvQZgkkJpOAupEOsMiFQf411qLqyrCjWp1g@mail.gmail.com> (raw)
In-Reply-To: <20170829130926.17396-1-hao.a.wu@intel.com>

On 29 August 2017 at 14:09, Hao Wu <hao.a.wu@intel.com> 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 <ruiyu.ni@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Hao Wu <hao.a.wu@intel.com>
> ---
>  .../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.


  parent reply	other threads:[~2017-08-29 14:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-29 13:09 [PATCH] SourceLevelDebugPkg/DebugAgentCommon: Use global variable for revision Hao Wu
2017-08-29 13:22 ` Ni, Ruiyu
2017-08-29 15:01 ` Ard Biesheuvel [this message]
2017-08-29 16:00   ` Kinney, Michael D
2017-08-30 11:12     ` Wu, Hao A
2017-08-30 12:48       ` Ni, Ruiyu

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=CAKv+Gu-s9TZRY02CvQZgkkJpOAupEOsMiFQf411qLqyrCjWp1g@mail.gmail.com \
    --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