public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Wu, Hao A" <hao.a.wu@intel.com>
To: Ranbir Singh <rsingh@ventanamicro.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Ni, Ray" <ray.ni@intel.com>
Subject: Re: [PATCH v2 2/2] MdeModulePkg/Bus/Ata/AtaAtapiPassThru: Fix UNUSED_VALUE Coverity issue
Date: Wed, 12 Jul 2023 04:38:13 +0000	[thread overview]
Message-ID: <DM6PR11MB40257913884BD5E6560A4F90CA36A@DM6PR11MB4025.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20230609123322.191390-3-rsingh@ventanamicro.com>

Really sorry,

After referring to the Information Technology - AT Attachment with Packet Interface (ATA/ATAPI) Specification,
It seems to me that the commands being executed in function SetDriveParameters() are not mandatory during device initialization.

1. INITIALIZE DEVICE PARAMETERS command (ID 0x91h):
This command got obsoleted since ATA/ATAPI-6 spec version.
Also, the return status of SetDriveParameters() is irrelevant with the execution result of this command.

2. SET MULTIPLE MODE command (ID 0xC6h):
My take is that this command is necessary if there is subsequent usage of command READ MULTIPLE, READ MULTIPLE EXT, WRITE MULTIPLE, or WRITE MULTIPLE EXT.
I do not find usage of the above 4 commands within edk2, so I think the successful execution of SET MULTIPLE MODE command is not mandatory for detecting hard disk device.

Based on the above findings, could you help to update the patch to:
      Status = SetDriveParameters (Instance, IdeChannel, IdeDevice, &DriveParameters, NULL);

      if (EFI_ERROR (Status)) {
        DEBUG ((DEBUG_WARN, "Set Drive Parameters Fail, Status = %r\n", Status));
      }

Will doing so still please Coverity?

Best Regards,
Hao Wu

> -----Original Message-----
> From: Ranbir Singh <rsingh@ventanamicro.com>
> Sent: Friday, June 9, 2023 8:33 PM
> To: devel@edk2.groups.io; rsingh@ventanamicro.com
> Cc: Wu, Hao A <hao.a.wu@intel.com>; Ni, Ray <ray.ni@intel.com>
> Subject: [PATCH v2 2/2] MdeModulePkg/Bus/Ata/AtaAtapiPassThru: Fix
> UNUSED_VALUE Coverity issue
> 
> From: Ranbir Singh <Ranbir.Singh3@Dell.com>
> 
> The return value stored in Status after call to SetDriveParameters
> is not made of any use thereafter and hence it remains as UNUSED.
> 
> Add error check as is done after calls to SetDeviceTransferMode.
> 
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4204
> Signed-off-by: Ranbir Singh <Ranbir.Singh3@Dell.com>
> Signed-off-by: Ranbir Singh <rsingh@ventanamicro.com>
> ---
> 
> Notes:
>     Add error check instead of Status storage removal
> 
>  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c
> b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c
> index 75403886e44a..d04b1d95a7f5 100644
> --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c
> +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c
> @@ -2549,13 +2549,18 @@ DetectAndConfigIdeDevice (
>      //
> 
>      if (DeviceType == EfiIdeHarddisk) {
> 
>        //
> 
> -      // Init driver parameters
> 
> +      // Init drive parameters
> 
>        //
> 
>        DriveParameters.Sector         = (UINT8)((ATA5_IDENTIFY_DATA
> *)(&Buffer.AtaData))->sectors_per_track;
> 
>        DriveParameters.Heads          = (UINT8)(((ATA5_IDENTIFY_DATA
> *)(&Buffer.AtaData))->heads - 1);
> 
>        DriveParameters.MultipleSector = (UINT8)((ATA5_IDENTIFY_DATA
> *)(&Buffer.AtaData))->multi_sector_cmd_max_sct_cnt;
> 
> 
> 
>        Status = SetDriveParameters (Instance, IdeChannel, IdeDevice,
> &DriveParameters, NULL);
> 
> +
> 
> +      if (EFI_ERROR (Status)) {
> 
> +        DEBUG ((DEBUG_ERROR, "Set Drive Parameters Fail, Status = %r\n",
> Status));
> 
> +        continue;
> 
> +      }
> 
>      }
> 
> 
> 
>      //
> 
> --
> 2.34.1


  reply	other threads:[~2023-07-12  4:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-09 12:33 [PATCH v2 0/2] MdeModulePkg/Bus/Ata/AtaAtapiPassThru: Fix Ranbir Singh
2023-06-09 12:33 ` [PATCH v2 1/2] MdeModulePkg/Bus/Ata/AtaAtapiPassThru: Fix SIGN_EXTENSION Coverity issue Ranbir Singh
2023-07-12  4:38   ` Wu, Hao A
2023-06-09 12:33 ` [PATCH v2 2/2] MdeModulePkg/Bus/Ata/AtaAtapiPassThru: Fix UNUSED_VALUE " Ranbir Singh
2023-07-12  4:38   ` Wu, Hao A [this message]
2023-07-12  7:00     ` Ranbir Singh
2023-07-12  7:05       ` Wu, Hao A
2023-07-12  7:07         ` Ranbir Singh
2023-07-12  8:28         ` [edk2-devel] " Ard Biesheuvel

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=DM6PR11MB40257913884BD5E6560A4F90CA36A@DM6PR11MB4025.namprd11.prod.outlook.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