From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=B+3kqv3q; spf=pass (domain: linaro.org, ip: 209.85.221.67, mailfrom: leif.lindholm@linaro.org) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by groups.io with SMTP; Mon, 10 Jun 2019 12:01:35 -0700 Received: by mail-wr1-f67.google.com with SMTP id p13so187171wru.10 for ; Mon, 10 Jun 2019 12:01:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=pL58/Qs6HDcJTtkJ8d/atuvDSkfYvw8TuvPpFAkXwfQ=; b=B+3kqv3qvY1sq+nsfu7IcbC54yTw1roDJ/075KM8qbRs0YvzCMjMs1RhmatHs/Tehm 1R7Wx9QzHq7X84Qd9oqh6+R09UdFJX3kdxSGlNJ0awpgkDUcL9XAiQv8i2K7ElkCSK9Q 7GRXRVrdAV0SFFB3pvA46erOWzVYbqFq2w6b6ElUoYgppzXxOBvnvDsf5p4bqRgsSEty 0CEF+RptniPQwwEpZzOUwwlyxL8HNLiLSI29I/DSeQs7EDpPpu3NtnJMlKh/AvlRS5Np 1NqlmDY72nOKfEcCEQUHOtDA9qcv+ueDUzVyQEZX5UjwP3H8JTG57EwYRWvXSsP+RE/U qH7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=pL58/Qs6HDcJTtkJ8d/atuvDSkfYvw8TuvPpFAkXwfQ=; b=OVkp8vD9gO94cWjz5u13jqXe3pwVCSxCpLfVsl/vlAjQmRV2RwUyVhYnU/xgo4z0vH B5wYvbKRZfIPqpnNnFXkqunGBhmWaYgRnbIq2rHS/Lo/9i3tzIPRC2SG/mM6rjh8Kdoy 0AzVw526LwjUqmccNTSjXQVDodm/+lKxgNzpqNPaDo2hB6IO6kE8hIm96FgApCfcE9Hp JefViyXQtgEkjyR+7o3UnlM2ZRxTXBXu+8Ra02/stcXeP0/DKmhp9Kpycqrnixo+NjhZ nZy8ct/7Ezu72IQ6rQdt+xGlpE9TLmjbbPjloNjK5LjHptJqANc2kkEpnD8STiFXSdo2 9eTQ== X-Gm-Message-State: APjAAAVMYPMOw5xuPCrHYuJOgaqwWkMqBrui+vQMiBegGQV7OB8gB3vZ ipNAab3uL13aBA/hif1zCwK/EQ== X-Google-Smtp-Source: APXvYqzT30/milyYqVHYVAi1p97i8plb/CzNXet6V8COpCEtbfsKmFrB5WQLl3OwRoDlUXYg5MTq6Q== X-Received: by 2002:adf:e808:: with SMTP id o8mr14218442wrm.191.1560193293435; Mon, 10 Jun 2019 12:01:33 -0700 (PDT) Return-Path: Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id z14sm20952535wre.96.2019.06.10.12.01.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jun 2019 12:01:32 -0700 (PDT) Date: Mon, 10 Jun 2019 20:01:31 +0100 From: "Leif Lindholm" To: Ard Biesheuvel Cc: edk2-devel-groups-io Subject: Re: [PATCH edk2-platforms 5/5] Platform/RDKQemu: stop using deprecated string conversion routines Message-ID: <20190610190131.7kylqyi2s5tck2ii@bivouac.eciton.net> References: <20190610142006.30007-1-ard.biesheuvel@linaro.org> <20190610142006.30007-6-ard.biesheuvel@linaro.org> <20190610180614.dbyijxbxdxwf3f7t@bivouac.eciton.net> MIME-Version: 1.0 In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Jun 10, 2019 at 08:55:03PM +0200, Ard Biesheuvel wrote: > On Mon, 10 Jun 2019 at 20:06, Leif Lindholm wrote: > > > > On Mon, Jun 10, 2019 at 04:20:06PM +0200, Ard Biesheuvel wrote: > > > Stop using deprecated string conversion routines so we can stop > > > un'#define'ing the DISABLE_NEW_DEPRECATED_INTERFACES macro in this code. > > > > > > Signed-off-by: Ard Biesheuvel > > > --- > > > Platform/Comcast/Library/RdkBootManagerLib/DiskIo.c | 12 +++++++-- > > > Platform/Comcast/Library/RdkBootManagerLib/RdkFile.c | 28 +++++++++++--------- > > > Platform/Comcast/RDKQemu/RDKQemu.dsc | 3 --- > > > 3 files changed, 26 insertions(+), 17 deletions(-) > > > > > > diff --git a/Platform/Comcast/Library/RdkBootManagerLib/DiskIo.c b/Platform/Comcast/Library/RdkBootManagerLib/DiskIo.c > > > index ed893bd5af6a..df16c326cc57 100644 > > > --- a/Platform/Comcast/Library/RdkBootManagerLib/DiskIo.c > > > +++ b/Platform/Comcast/Library/RdkBootManagerLib/DiskIo.c > > > @@ -90,6 +90,7 @@ ListBlockIos ( > > > UINTN NumHandles; > > > UINT16 *DeviceFullPath; > > > DISKIO_PARTITION_LIST *Entry; > > > + RETURN_STATUS RetStatus; > > > > > > InitializeListHead (&mPartitionListHead); > > > > > > @@ -146,11 +147,13 @@ ListBlockIos ( > > > > > > // Copy handle and partition name > > > Entry->PartitionHandle = AllHandles[LoopIndex]; > > > - StrnCpy ( > > > + RetStatus = StrnCpyS ( > > > Entry->PartitionName, > > > + PARTITION_NAME_MAX_LENGTH, > > > PartitionName, > > > PARTITION_NAME_MAX_LENGTH > > > ); > > > + ASSERT_RETURN_ERROR (RetStatus); > > > > Would we not want to return an error here, for non-DEBUG builds? > > > > Actually, I think I should just change the last arg to > PARTITION_NAME_MAX_LENGTH - 1, in which case no input length based > error is ever returned. Thats works for me. With that, and the below style fixes: Reviewed-by: Leif Lindholm > > > InsertTailList (&mPartitionListHead, &Entry->Link); > > > break; > > > } > > > @@ -176,8 +179,13 @@ OpenPartition ( > > > DISKIO_PARTITION_LIST *Entry; > > > SPARSE_HEADER *SparseHeader; > > > UINT16 UnicodePartitionName[100]; > > > + RETURN_STATUS RetStatus; > > > > > > - AsciiStrToUnicodeStr ( PartitionName, UnicodePartitionName); > > > + RetStatus = AsciiStrToUnicodeStrS (PartitionName, UnicodePartitionName, > > > + sizeof (UnicodePartitionName)); > > > + if (RETURN_ERROR (RetStatus)) { > > > + return EFI_OUT_OF_RESOURCES; > > > + } > > > DEBUG((DEBUG_INFO, "Unicode partition name %s\n", UnicodePartitionName)); > > > > > > Status = ListBlockIos (UnicodePartitionName); > > > diff --git a/Platform/Comcast/Library/RdkBootManagerLib/RdkFile.c b/Platform/Comcast/Library/RdkBootManagerLib/RdkFile.c > > > index dd695651026a..6f98562eff84 100644 > > > --- a/Platform/Comcast/Library/RdkBootManagerLib/RdkFile.c > > > +++ b/Platform/Comcast/Library/RdkBootManagerLib/RdkFile.c > > > @@ -8,8 +8,6 @@ > > > > > > #define MAX_VAR 6 > > > > > > -#define ALLOCATE_STRING_MEM(X) AllocateZeroPool((X + 1) * sizeof(CHAR16)) > > > - > > > /** > > > * list_for_each_entry - iterate over list of given type > > > * @pos: the type * to use as a loop cursor. > > > @@ -53,10 +51,13 @@ SaveString ( > > > IN CHAR16 *String2 > > > ) > > > { > > > - *Dest = ALLOCATE_STRING_MEM (StrLen (String1) + StrLen (String2)); > > > + UINTN StringLength; > > > + > > > + StringLength = StrLen (String1) + StrLen (String2) + 1; > > > + *Dest = AllocatePool (StringLength * sizeof(CHAR16)); > > > > Minor, and just part of the shuffle, but - space after sizeof? > > (At least one more below.) > > > > Right, will fix. > > > > ASSERT (Dest != NULL); > > > - StrCat (*Dest, String1); > > > - StrCat (*Dest, String2); > > > + StrCpyS (*Dest, StringLength, String1); > > > + StrCatS (*Dest, StringLength, String2); > > > } > > > > > > STATIC > > > @@ -74,11 +75,13 @@ LsFiles ( > > > BOOLEAN NoFile; > > > CHAR16 *TempPath; > > > DIR_NODE *Node; > > > + UINTN StringLength; > > > > > > NoFile = FALSE; > > > - TempPath = ALLOCATE_STRING_MEM (StrLen(DirPath) + 1); > > > - StrCat (TempPath, DirPath); > > > - StrCat (TempPath, L"/"); > > > + StringLength = StrLen(DirPath) + 2; > > > + TempPath = AllocatePool (StringLength * sizeof(CHAR16)); > > > + StrCpyS (TempPath, StringLength, DirPath); > > > + StrCatS (TempPath, StringLength, L"/"); > > > > > > Status = GetFileHandler (&FileHandle, DirPath, EFI_FILE_MODE_READ); > > > ASSERT_EFI_ERROR (Status); > > > @@ -192,6 +195,7 @@ InitVarList ( > > > UINTN Next; > > > CHAR8 *VarDelimiter[2]; > > > EFI_STATUS Status; > > > + UINTN StringLength; > > > > > > VarDelimiter[0] = "="; > > > VarDelimiter[1] = "\""; > > > @@ -212,10 +216,10 @@ InitVarList ( > > > if (VarResult[OuterLoopIndex][InnerLoopIndex]) { > > > FreePool (VarResult[OuterLoopIndex][InnerLoopIndex]); > > > } > > > - VarResult[OuterLoopIndex][InnerLoopIndex] = \ > > > - ALLOCATE_STRING_MEM (AsciiStrLen (&FileData[Current])); > > > - AsciiStrToUnicodeStr (&FileData[Current], \ > > > - VarResult[OuterLoopIndex][InnerLoopIndex]); > > > + StringLength = AsciiStrLen (&FileData[Current]) + 1; > > > + VarResult[OuterLoopIndex][InnerLoopIndex] = AllocatePool (StringLength); > > > + AsciiStrToUnicodeStrS (&FileData[Current], > > > + VarResult[OuterLoopIndex][InnerLoopIndex], StringLength); > > > //skip new line > > > Next += 2; > > > } > > > diff --git a/Platform/Comcast/RDKQemu/RDKQemu.dsc b/Platform/Comcast/RDKQemu/RDKQemu.dsc > > > index f0ed4f11e81d..440d2ace917c 100644 > > > --- a/Platform/Comcast/RDKQemu/RDKQemu.dsc > > > +++ b/Platform/Comcast/RDKQemu/RDKQemu.dsc > > > @@ -418,6 +418,3 @@ [Components.AARCH64] > > > > > > NULL|ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf > > > } > > > - > > > -[BuildOptions] > > > - GCC:*_*_*_CC_FLAGS = -UDISABLE_NEW_DEPRECATED_INTERFACES > > > -- > > > 2.20.1 > > >