Re: [edk2] [Patch] BaseTools: Update BaseTools to pass VS2015 compiler
Reviewed-by: Liming Gao <liming@intel.com> -Original Message- From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Yonghong Zhu Sent: Friday, January 29, 2016 10:26 AM To: edk2-devel@lists.01.org Subject: [edk2] [Patch] BaseTools: Update BaseTools to pass VS2015 compiler Fix some errors to pass VS2015 compiler. 1. warning C4456: declaration of xxx hides previous local declaration 2. warning C4005: 'UINT8_MAX': macro redefinition Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong@intel.com> --- BaseTools/Source/C/GenFw/Elf32Convert.c | 4 +-- BaseTools/Source/C/GenVtf/GenVtf.c | 16 ++-- BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c | 2 +- BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c | 33 +++-- BaseTools/Source/C/VfrCompile/VfrSyntax.g | 5 +++- 5 files changed, 29 insertions(+), 31 deletions(-) diff --git a/BaseTools/Source/C/GenFw/Elf32Convert.c b/BaseTools/Source/C/GenFw/Elf32Convert.c index eede645..9bf5855 100644 --- a/BaseTools/Source/C/GenFw/Elf32Convert.c +++ b/BaseTools/Source/C/GenFw/Elf32Convert.c @@ -1,9 +1,9 @@ /** @file Elf32 Convert solution -Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved. +Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved. Portions copyright (c) 2013, ARM Ltd. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -813,11 +813,11 @@ WriteRelocations32 ( if (IsTextShdr(SecShdr) || IsDataShdr(SecShdr)) { UINT32 RelIdx; FoundRelocations = TRUE; for (RelIdx = 0; RelIdx < RelShdr->sh_size; RelIdx += RelShdr->sh_entsize) { - Elf_Rel *Rel = (Elf_Rel *)((UINT8*)mEhdr + RelShdr->sh_offset + RelIdx); + Rel = (Elf_Rel *)((UINT8*)mEhdr + RelShdr->sh_offset + RelIdx); if (mEhdr->e_machine == EM_386) { switch (ELF_R_TYPE(Rel->r_info)) { case R_386_NONE: case R_386_PC32: diff --git a/BaseTools/Source/C/GenVtf/GenVtf.c b/BaseTools/Source/C/GenVtf/GenVtf.c index 6f66ddc..9a3f508 100644 --- a/BaseTools/Source/C/GenVtf/GenVtf.c +++ b/BaseTools/Source/C/GenVtf/GenVtf.c @@ -1,10 +1,10 @@ /** @file This file contains functions required to generate a boot strap file (BSF) also known as the Volume Top File (VTF) -Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved. +Copyright (c) 1999 - 2016, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -2650,24 +2650,24 @@ Returns: OutFileName1 = VTF_OUTPUT_FILE1; } SymFileName = VTF_SYM_FILE; } else { INTN OutFileNameLen = strlen(OutFileName1); -INTN Index; +INTN NewIndex; -for (Index = OutFileNameLen; Index > 0; --Index) { - if (OutFileName1[Index] == '/' || OutFileName1[Index] == '\\') { +for (NewIndex = OutFileNameLen; NewIndex > 0; --NewIndex) { + if (OutFileName1[NewIndex] == '/' || OutFileName1[NewIndex] == '\\') { break; } } -if (Index == 0) { +if (NewIndex == 0) { SymFileName = VTF_SYM_FILE; } else { - INTN SymFileNameLen = Index + 1 + strlen(VTF_SYM_FILE); + INTN SymFileNameLen = NewIndex + 1 + strlen(VTF_SYM_FILE); SymFileName = malloc(SymFileNameLen + 1); - memcpy(SymFileName, OutFileName1, Index + 1); - memcpy(SymFileName + Index + 1, VTF_SYM_FILE, strlen(VTF_SYM_FILE)); + memcpy(SymFileName, OutFileName1, NewIndex + 1); + memcpy(SymFileName + NewIndex + 1, VTF_SYM_FILE, strlen(VTF_SYM_FILE)); SymFileName[SymFileNameLen] = '\0'; } if (DebugMode) { DebugMsg(UTILITY_NAME, 0, DebugLevel, SymFileName, NULL); } diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c index eb52501..87bea86 100644 --- a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c +++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c @@ -264,11 +264,11 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte } state = state < kNumLitStates ? 8 : 11; prob = probs + RepLenCoder; } { -unsigned limit, offset; +unsigned offset; CLzmaProb *probLen = prob + LenChoice; IF_BIT_0(probLen) { UPDATE_0(probLen); probLen = prob + LenLow + (posState << kLenNumLowBits); diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c b/BaseTools/Source/C/LzmaCompre
Re: [edk2] [Patch] BaseTools: Update BaseTools to pass VS2015 compiler
Why keep the code as below: - UInt32 curAndLenPrice; - COptimal *opt; + // UInt32 curAndLenPrice; + // COptimal *opt; I think we should completely remove them instead of just commenting them. Several similar cases in your patch are found. Regards, Ray -Original Message- From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Yonghong Zhu Sent: Wednesday, January 27, 2016 3:36 PM To: edk2-devel@lists.01.org Subject: [edk2] [Patch] BaseTools: Update BaseTools to pass VS2015 compiler Fix some errors to pass VS2015 compiler. 1. warning C4456: declaration of xxx hides previous local declaration 2. warning C4005: 'UINT8_MAX': macro redefinition Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong@intel.com> --- BaseTools/Source/C/GenFw/Elf32Convert.c | 4 +-- BaseTools/Source/C/GenVtf/GenVtf.c | 16 +- BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c | 2 +- BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c | 39 + BaseTools/Source/C/VfrCompile/VfrSyntax.g | 5 +++- 5 files changed, 35 insertions(+), 31 deletions(-) diff --git a/BaseTools/Source/C/GenFw/Elf32Convert.c b/BaseTools/Source/C/GenFw/Elf32Convert.c index eede645..9bf5855 100644 --- a/BaseTools/Source/C/GenFw/Elf32Convert.c +++ b/BaseTools/Source/C/GenFw/Elf32Convert.c @@ -1,9 +1,9 @@ /** @file Elf32 Convert solution -Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved. +Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved. Portions copyright (c) 2013, ARM Ltd. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -813,11 +813,11 @@ WriteRelocations32 ( if (IsTextShdr(SecShdr) || IsDataShdr(SecShdr)) { UINT32 RelIdx; FoundRelocations = TRUE; for (RelIdx = 0; RelIdx < RelShdr->sh_size; RelIdx += RelShdr->sh_entsize) { - Elf_Rel *Rel = (Elf_Rel *)((UINT8*)mEhdr + RelShdr->sh_offset + RelIdx); + Rel = (Elf_Rel *)((UINT8*)mEhdr + RelShdr->sh_offset + RelIdx); if (mEhdr->e_machine == EM_386) { switch (ELF_R_TYPE(Rel->r_info)) { case R_386_NONE: case R_386_PC32: diff --git a/BaseTools/Source/C/GenVtf/GenVtf.c b/BaseTools/Source/C/GenVtf/GenVtf.c index 6f66ddc..9a3f508 100644 --- a/BaseTools/Source/C/GenVtf/GenVtf.c +++ b/BaseTools/Source/C/GenVtf/GenVtf.c @@ -1,10 +1,10 @@ /** @file This file contains functions required to generate a boot strap file (BSF) also known as the Volume Top File (VTF) -Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved. +Copyright (c) 1999 - 2016, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -2650,24 +2650,24 @@ Returns: OutFileName1 = VTF_OUTPUT_FILE1; } SymFileName = VTF_SYM_FILE; } else { INTN OutFileNameLen = strlen(OutFileName1); -INTN Index; +INTN NewIndex; -for (Index = OutFileNameLen; Index > 0; --Index) { - if (OutFileName1[Index] == '/' || OutFileName1[Index] == '\\') { +for (NewIndex = OutFileNameLen; NewIndex > 0; --NewIndex) { + if (OutFileName1[NewIndex] == '/' || OutFileName1[NewIndex] == '\\') { break; } } -if (Index == 0) { +if (NewIndex == 0) { SymFileName = VTF_SYM_FILE; } else { - INTN SymFileNameLen = Index + 1 + strlen(VTF_SYM_FILE); + INTN SymFileNameLen = NewIndex + 1 + strlen(VTF_SYM_FILE); SymFileName = malloc(SymFileNameLen + 1); - memcpy(SymFileName, OutFileName1, Index + 1); - memcpy(SymFileName + Index + 1, VTF_SYM_FILE, strlen(VTF_SYM_FILE)); + memcpy(SymFileName, OutFileName1, NewIndex + 1); + memcpy(SymFileName + NewIndex + 1, VTF_SYM_FILE, strlen(VTF_SYM_FILE)); SymFileName[SymFileNameLen] = '\0'; } if (DebugMode) { DebugMsg(UTILITY_NAME, 0, DebugLevel, SymFileName, NULL); } diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c index eb52501..87bea86 100644 --- a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c +++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c @@ -264,11 +264,11 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte } state = state < kNumLitStates ? 8 : 11; prob = probs + RepLenCoder; } { -unsigned limit, offset; +unsigned offset; CLzmaProb *probLen =
Re: [edk2] [Patch] BaseTools: Update BaseTools to pass VS2015 compiler
Got it, thanks. I will clean these comments. Best Regards, Zhu Yonghong -Original Message- From: Ni, Ruiyu Sent: Thursday, January 28, 2016 9:56 AM To: Zhu, Yonghong; edk2-devel@lists.01.org Subject: RE: [edk2] [Patch] BaseTools: Update BaseTools to pass VS2015 compiler Why keep the code as below: - UInt32 curAndLenPrice; - COptimal *opt; + // UInt32 curAndLenPrice; + // COptimal *opt; I think we should completely remove them instead of just commenting them. Several similar cases in your patch are found. Regards, Ray -Original Message- From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Yonghong Zhu Sent: Wednesday, January 27, 2016 3:36 PM To: edk2-devel@lists.01.org Subject: [edk2] [Patch] BaseTools: Update BaseTools to pass VS2015 compiler Fix some errors to pass VS2015 compiler. 1. warning C4456: declaration of xxx hides previous local declaration 2. warning C4005: 'UINT8_MAX': macro redefinition Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong@intel.com> --- BaseTools/Source/C/GenFw/Elf32Convert.c | 4 +-- BaseTools/Source/C/GenVtf/GenVtf.c | 16 +- BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c | 2 +- BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c | 39 + BaseTools/Source/C/VfrCompile/VfrSyntax.g | 5 +++- 5 files changed, 35 insertions(+), 31 deletions(-) diff --git a/BaseTools/Source/C/GenFw/Elf32Convert.c b/BaseTools/Source/C/GenFw/Elf32Convert.c index eede645..9bf5855 100644 --- a/BaseTools/Source/C/GenFw/Elf32Convert.c +++ b/BaseTools/Source/C/GenFw/Elf32Convert.c @@ -1,9 +1,9 @@ /** @file Elf32 Convert solution -Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved. +Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved. Portions copyright (c) 2013, ARM Ltd. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -813,11 +813,11 @@ WriteRelocations32 ( if (IsTextShdr(SecShdr) || IsDataShdr(SecShdr)) { UINT32 RelIdx; FoundRelocations = TRUE; for (RelIdx = 0; RelIdx < RelShdr->sh_size; RelIdx += RelShdr->sh_entsize) { - Elf_Rel *Rel = (Elf_Rel *)((UINT8*)mEhdr + RelShdr->sh_offset + RelIdx); + Rel = (Elf_Rel *)((UINT8*)mEhdr + RelShdr->sh_offset + + RelIdx); if (mEhdr->e_machine == EM_386) { switch (ELF_R_TYPE(Rel->r_info)) { case R_386_NONE: case R_386_PC32: diff --git a/BaseTools/Source/C/GenVtf/GenVtf.c b/BaseTools/Source/C/GenVtf/GenVtf.c index 6f66ddc..9a3f508 100644 --- a/BaseTools/Source/C/GenVtf/GenVtf.c +++ b/BaseTools/Source/C/GenVtf/GenVtf.c @@ -1,10 +1,10 @@ /** @file This file contains functions required to generate a boot strap file (BSF) also known as the Volume Top File (VTF) -Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved. +Copyright (c) 1999 - 2016, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -2650,24 +2650,24 @@ Returns: OutFileName1 = VTF_OUTPUT_FILE1; } SymFileName = VTF_SYM_FILE; } else { INTN OutFileNameLen = strlen(OutFileName1); -INTN Index; +INTN NewIndex; -for (Index = OutFileNameLen; Index > 0; --Index) { - if (OutFileName1[Index] == '/' || OutFileName1[Index] == '\\') { +for (NewIndex = OutFileNameLen; NewIndex > 0; --NewIndex) { + if (OutFileName1[NewIndex] == '/' || OutFileName1[NewIndex] == + '\\') { break; } } -if (Index == 0) { +if (NewIndex == 0) { SymFileName = VTF_SYM_FILE; } else { - INTN SymFileNameLen = Index + 1 + strlen(VTF_SYM_FILE); + INTN SymFileNameLen = NewIndex + 1 + strlen(VTF_SYM_FILE); SymFileName = malloc(SymFileNameLen + 1); - memcpy(SymFileName, OutFileName1, Index + 1); - memcpy(SymFileName + Index + 1, VTF_SYM_FILE, strlen(VTF_SYM_FILE)); + memcpy(SymFileName, OutFileName1, NewIndex + 1); + memcpy(SymFileName + NewIndex + 1, VTF_SYM_FILE, + strlen(VTF_SYM_FILE)); SymFileName[SymFileNameLen] = '\0'; } if (DebugMode) { DebugMsg(UTILITY_NAME, 0, DebugLevel, SymFileName, NULL); } diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c index eb52501..87bea86 100644 --- a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c +++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c
[edk2] [Patch] BaseTools: Update BaseTools to pass VS2015 compiler
Fix some errors to pass VS2015 compiler. 1. warning C4456: declaration of xxx hides previous local declaration 2. warning C4005: 'UINT8_MAX': macro redefinition Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu--- BaseTools/Source/C/GenFw/Elf32Convert.c | 4 +-- BaseTools/Source/C/GenVtf/GenVtf.c | 16 +- BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c | 2 +- BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c | 39 + BaseTools/Source/C/VfrCompile/VfrSyntax.g | 5 +++- 5 files changed, 35 insertions(+), 31 deletions(-) diff --git a/BaseTools/Source/C/GenFw/Elf32Convert.c b/BaseTools/Source/C/GenFw/Elf32Convert.c index eede645..9bf5855 100644 --- a/BaseTools/Source/C/GenFw/Elf32Convert.c +++ b/BaseTools/Source/C/GenFw/Elf32Convert.c @@ -1,9 +1,9 @@ /** @file Elf32 Convert solution -Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved. +Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved. Portions copyright (c) 2013, ARM Ltd. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -813,11 +813,11 @@ WriteRelocations32 ( if (IsTextShdr(SecShdr) || IsDataShdr(SecShdr)) { UINT32 RelIdx; FoundRelocations = TRUE; for (RelIdx = 0; RelIdx < RelShdr->sh_size; RelIdx += RelShdr->sh_entsize) { - Elf_Rel *Rel = (Elf_Rel *)((UINT8*)mEhdr + RelShdr->sh_offset + RelIdx); + Rel = (Elf_Rel *)((UINT8*)mEhdr + RelShdr->sh_offset + RelIdx); if (mEhdr->e_machine == EM_386) { switch (ELF_R_TYPE(Rel->r_info)) { case R_386_NONE: case R_386_PC32: diff --git a/BaseTools/Source/C/GenVtf/GenVtf.c b/BaseTools/Source/C/GenVtf/GenVtf.c index 6f66ddc..9a3f508 100644 --- a/BaseTools/Source/C/GenVtf/GenVtf.c +++ b/BaseTools/Source/C/GenVtf/GenVtf.c @@ -1,10 +1,10 @@ /** @file This file contains functions required to generate a boot strap file (BSF) also known as the Volume Top File (VTF) -Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved. +Copyright (c) 1999 - 2016, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -2650,24 +2650,24 @@ Returns: OutFileName1 = VTF_OUTPUT_FILE1; } SymFileName = VTF_SYM_FILE; } else { INTN OutFileNameLen = strlen(OutFileName1); -INTN Index; +INTN NewIndex; -for (Index = OutFileNameLen; Index > 0; --Index) { - if (OutFileName1[Index] == '/' || OutFileName1[Index] == '\\') { +for (NewIndex = OutFileNameLen; NewIndex > 0; --NewIndex) { + if (OutFileName1[NewIndex] == '/' || OutFileName1[NewIndex] == '\\') { break; } } -if (Index == 0) { +if (NewIndex == 0) { SymFileName = VTF_SYM_FILE; } else { - INTN SymFileNameLen = Index + 1 + strlen(VTF_SYM_FILE); + INTN SymFileNameLen = NewIndex + 1 + strlen(VTF_SYM_FILE); SymFileName = malloc(SymFileNameLen + 1); - memcpy(SymFileName, OutFileName1, Index + 1); - memcpy(SymFileName + Index + 1, VTF_SYM_FILE, strlen(VTF_SYM_FILE)); + memcpy(SymFileName, OutFileName1, NewIndex + 1); + memcpy(SymFileName + NewIndex + 1, VTF_SYM_FILE, strlen(VTF_SYM_FILE)); SymFileName[SymFileNameLen] = '\0'; } if (DebugMode) { DebugMsg(UTILITY_NAME, 0, DebugLevel, SymFileName, NULL); } diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c index eb52501..87bea86 100644 --- a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c +++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c @@ -264,11 +264,11 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte } state = state < kNumLitStates ? 8 : 11; prob = probs + RepLenCoder; } { -unsigned limit, offset; +unsigned offset; CLzmaProb *probLen = prob + LenChoice; IF_BIT_0(probLen) { UPDATE_0(probLen); probLen = prob + LenLow + (posState << kLenNumLowBits); diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c index 95c3c9f..a8a9fc1 100644 --- a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c +++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c @@ -1,11 +1,11 @@ /** @file Based on LZMA SDK 4.65: LzmaEnc.c -- LZMA Encoder 2009-02-02 : Igor Pavlov : Public domain - Copyright (c) 2011, Intel Corporation. All rights reserved. +