From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web11.11610.1683708361839984755 for ; Wed, 10 May 2023 01:46:02 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R/TlgXHx; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683708361; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JbCK938RhsvSWfA6MBjk/iCuI0dlOY/ZIf/PQULpGB4=; b=R/TlgXHxIyfHlJzCJv+hdF8jrYTDL7CSKJXVjJl2pOQzGH6EhAsg0MgxxcBaa+j1WXf2j1 S4sD5Wbm82QRkjXP0hbxHvWsVANkG85j1B1488O59PNP/Y0DhDqTUatv8gv7FzDpHVj/B+ KvcA4Y2UKy/dScjMm/3RI974HMlsf/k= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-612-n2U9RhhNNlKymTrVuwiP6w-1; Wed, 10 May 2023 04:45:57 -0400 X-MC-Unique: n2U9RhhNNlKymTrVuwiP6w-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E6CF588D013; Wed, 10 May 2023 08:45:56 +0000 (UTC) Received: from [10.39.192.106] (unknown [10.39.192.106]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3289648FB12; Wed, 10 May 2023 08:45:55 +0000 (UTC) Message-ID: Date: Wed, 10 May 2023 10:45:53 +0200 MIME-Version: 1.0 Subject: Re: [PATCH v2 04/12] MdeModulePkg/SataControllerDxe: Fix up ASSERTS (Private != NULL) To: Pedro Falcato , devel@edk2.groups.io Cc: Jian J Wang , Liming Gao , Hao A Wu , Ray Ni , Mike Maslenkin References: <20230509163212.291333-1-pedro.falcato@gmail.com> <20230509163212.291333-5-pedro.falcato@gmail.com> From: "Laszlo Ersek" In-Reply-To: <20230509163212.291333-5-pedro.falcato@gmail.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 5/9/23 18:32, Pedro Falcato wrote: > ASSERT (Private != NULL) (where Private = CR(...)) is ineffective as > CR(Ptr, Type, Member, Sig) either returns Ptr - offsetof(Type, Member), > or ASSERTS on the signature, so it's unlikely to ever return NULL > (must be passed a pointer = member's offset, or in this case, 0x4). > > ASSERT on This != NULL instead. > > Cc: Jian J Wang > Cc: Liming Gao > Cc: Hao A Wu > Cc: Ray Ni > Cc: Laszlo Ersek > Cc: Mike Maslenkin > Signed-off-by: Pedro Falcato > --- > MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c > index f0ffd311d7b9..ea0116071c6a 100644 > --- a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c > +++ b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c > @@ -611,7 +611,6 @@ SataControllerStop ( > } > > Private = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (IdeInit); > - ASSERT (Private != NULL); > > // > // Uninstall the IDE Controller Init Protocol from this instance > @@ -745,8 +744,8 @@ IdeInitGetChannelInfo ( > { > EFI_SATA_CONTROLLER_PRIVATE_DATA *Private; > > + ASSERT (This != NULL); > Private = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This); > - ASSERT (Private != NULL); > > if (Channel < This->ChannelCount) { > *Enabled = TRUE; > @@ -845,8 +844,8 @@ IdeInitSubmitData ( > EFI_SATA_CONTROLLER_PRIVATE_DATA *Private; > UINTN DeviceIndex; > > + ASSERT (This != NULL); > Private = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This); > - ASSERT (Private != NULL); > > if ((Channel >= This->ChannelCount) || (Device >= Private->DeviceCount)) { > return EFI_INVALID_PARAMETER; > @@ -924,8 +923,8 @@ IdeInitDisqualifyMode ( > EFI_SATA_CONTROLLER_PRIVATE_DATA *Private; > UINTN DeviceIndex; > > + ASSERT (This != NULL); > Private = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This); > - ASSERT (Private != NULL); > > if ((Channel >= This->ChannelCount) || (BadModes == NULL) || (Device >= Private->DeviceCount)) { > return EFI_INVALID_PARAMETER; > @@ -1017,8 +1016,8 @@ IdeInitCalculateMode ( > EFI_STATUS Status; > UINTN DeviceIndex; > > + ASSERT (This != NULL); > Private = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This); > - ASSERT (Private != NULL); > > if ((Channel >= This->ChannelCount) || (SupportedModes == NULL) || (Device >= Private->DeviceCount)) { > return EFI_INVALID_PARAMETER; Reviewed-by: Laszlo Ersek