* [PATCH] BaseTools: Parse decimal format INF_VERSION incorrect
@ 2018-07-25 3:40 Yonghong Zhu
2018-07-26 0:41 ` Zhu, Yonghong
0 siblings, 1 reply; 4+ messages in thread
From: Yonghong Zhu @ 2018-07-25 3:40 UTC (permalink / raw)
To: edk2-devel; +Cc: Yunhua Feng, Liming Gao
From: Yunhua Feng <yunhuax.feng@intel.com>
hex number 0x00010019, the major number is 0001, the
minor number is 0019.
the decimal number 1.25, the major number is 1, and the
minor number is 25
Fix https://bugzilla.tianocore.org/show_bug.cgi?id=921
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
---
BaseTools/Source/Python/Workspace/MetaFileParser.py | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index fbfc182c8b..250cbf79a9 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -374,13 +374,16 @@ class MetaFileParser(object):
if Name == 'INF_VERSION':
if hexVersionPattern.match(Value):
self._Version = int(Value, 0)
elif decVersionPattern.match(Value):
ValueList = Value.split('.')
- Major = '%04o' % int(ValueList[0], 0)
- Minor = '%04o' % int(ValueList[1], 0)
- self._Version = int('0x' + Major + Minor, 0)
+ Major = int(ValueList[0], 0)
+ Minor = int(ValueList[1], 0)
+ if Major > 0xffff or Minor > 0xffff:
+ EdkLogger.error('Parser', FORMAT_INVALID, "Invalid version number",
+ ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)
+ self._Version = int('0x' + '{0:04x}{1:04x}'.format(Major, Minor), 0)
else:
EdkLogger.error('Parser', FORMAT_INVALID, "Invalid version number",
ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)
if isinstance(self, InfParser) and self._Version < 0x00010005:
--
2.12.2.windows.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] BaseTools: Parse decimal format INF_VERSION incorrect
2018-07-25 3:40 [PATCH] BaseTools: Parse decimal format INF_VERSION incorrect Yonghong Zhu
@ 2018-07-26 0:41 ` Zhu, Yonghong
2018-07-26 1:23 ` Carsey, Jaben
0 siblings, 1 reply; 4+ messages in thread
From: Zhu, Yonghong @ 2018-07-26 0:41 UTC (permalink / raw)
To: Zhu, Yonghong, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Best Regards,
Zhu Yonghong
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Yonghong Zhu
Sent: Wednesday, July 25, 2018 11:41 AM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>
Subject: [edk2] [PATCH] BaseTools: Parse decimal format INF_VERSION incorrect
From: Yunhua Feng <yunhuax.feng@intel.com>
hex number 0x00010019, the major number is 0001, the minor number is 0019.
the decimal number 1.25, the major number is 1, and the minor number is 25
Fix https://bugzilla.tianocore.org/show_bug.cgi?id=921
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
---
BaseTools/Source/Python/Workspace/MetaFileParser.py | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index fbfc182c8b..250cbf79a9 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -374,13 +374,16 @@ class MetaFileParser(object):
if Name == 'INF_VERSION':
if hexVersionPattern.match(Value):
self._Version = int(Value, 0)
elif decVersionPattern.match(Value):
ValueList = Value.split('.')
- Major = '%04o' % int(ValueList[0], 0)
- Minor = '%04o' % int(ValueList[1], 0)
- self._Version = int('0x' + Major + Minor, 0)
+ Major = int(ValueList[0], 0)
+ Minor = int(ValueList[1], 0)
+ if Major > 0xffff or Minor > 0xffff:
+ EdkLogger.error('Parser', FORMAT_INVALID, "Invalid version number",
+ ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)
+ self._Version = int('0x' +
+ '{0:04x}{1:04x}'.format(Major, Minor), 0)
else:
EdkLogger.error('Parser', FORMAT_INVALID, "Invalid version number",
ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)
if isinstance(self, InfParser) and self._Version < 0x00010005:
--
2.12.2.windows.2
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] BaseTools: Parse decimal format INF_VERSION incorrect
2018-07-26 0:41 ` Zhu, Yonghong
@ 2018-07-26 1:23 ` Carsey, Jaben
2018-07-26 1:41 ` Zhu, Yonghong
0 siblings, 1 reply; 4+ messages in thread
From: Carsey, Jaben @ 2018-07-26 1:23 UTC (permalink / raw)
To: Zhu, Yonghong; +Cc: edk2-devel@lists.01.org, Gao, Liming
Can we change the code to allocate fewer strings?
'0x' + '{0:04x}{1:04x}'.format(...)
Could be just:
'0x{0:04x}{1:04x}'.format(...
Jaben
> On Jul 25, 2018, at 5:41 PM, Zhu, Yonghong <yonghong.zhu@intel.com> wrote:
>
> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
>
> Best Regards,
> Zhu Yonghong
>
>
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Yonghong Zhu
> Sent: Wednesday, July 25, 2018 11:41 AM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>
> Subject: [edk2] [PATCH] BaseTools: Parse decimal format INF_VERSION incorrect
>
> From: Yunhua Feng <yunhuax.feng@intel.com>
>
> hex number 0x00010019, the major number is 0001, the minor number is 0019.
> the decimal number 1.25, the major number is 1, and the minor number is 25
>
> Fix https://bugzilla.tianocore.org/show_bug.cgi?id=921
>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Yonghong Zhu <yonghong.zhu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
> ---
> BaseTools/Source/Python/Workspace/MetaFileParser.py | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py
> index fbfc182c8b..250cbf79a9 100644
> --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
> +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
> @@ -374,13 +374,16 @@ class MetaFileParser(object):
> if Name == 'INF_VERSION':
> if hexVersionPattern.match(Value):
> self._Version = int(Value, 0)
> elif decVersionPattern.match(Value):
> ValueList = Value.split('.')
> - Major = '%04o' % int(ValueList[0], 0)
> - Minor = '%04o' % int(ValueList[1], 0)
> - self._Version = int('0x' + Major + Minor, 0)
> + Major = int(ValueList[0], 0)
> + Minor = int(ValueList[1], 0)
> + if Major > 0xffff or Minor > 0xffff:
> + EdkLogger.error('Parser', FORMAT_INVALID, "Invalid version number",
> + ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)
> + self._Version = int('0x' +
> + '{0:04x}{1:04x}'.format(Major, Minor), 0)
> else:
> EdkLogger.error('Parser', FORMAT_INVALID, "Invalid version number",
> ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)
>
> if isinstance(self, InfParser) and self._Version < 0x00010005:
> --
> 2.12.2.windows.2
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] BaseTools: Parse decimal format INF_VERSION incorrect
2018-07-26 1:23 ` Carsey, Jaben
@ 2018-07-26 1:41 ` Zhu, Yonghong
0 siblings, 0 replies; 4+ messages in thread
From: Zhu, Yonghong @ 2018-07-26 1:41 UTC (permalink / raw)
To: Carsey, Jaben; +Cc: edk2-devel@lists.01.org, Gao, Liming, Zhu, Yonghong
Good, the patch is not push, I can update it.
Best Regards,
Zhu Yonghong
-----Original Message-----
From: Carsey, Jaben
Sent: Thursday, July 26, 2018 9:24 AM
To: Zhu, Yonghong <yonghong.zhu@intel.com>
Cc: edk2-devel@lists.01.org; Gao, Liming <liming.gao@intel.com>
Subject: Re: [edk2] [PATCH] BaseTools: Parse decimal format INF_VERSION incorrect
Can we change the code to allocate fewer strings?
'0x' + '{0:04x}{1:04x}'.format(...)
Could be just:
'0x{0:04x}{1:04x}'.format(...
Jaben
> On Jul 25, 2018, at 5:41 PM, Zhu, Yonghong <yonghong.zhu@intel.com> wrote:
>
> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
>
> Best Regards,
> Zhu Yonghong
>
>
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Yonghong Zhu
> Sent: Wednesday, July 25, 2018 11:41 AM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>
> Subject: [edk2] [PATCH] BaseTools: Parse decimal format INF_VERSION
> incorrect
>
> From: Yunhua Feng <yunhuax.feng@intel.com>
>
> hex number 0x00010019, the major number is 0001, the minor number is 0019.
> the decimal number 1.25, the major number is 1, and the minor number
> is 25
>
> Fix https://bugzilla.tianocore.org/show_bug.cgi?id=921
>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Yonghong Zhu <yonghong.zhu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
> ---
> BaseTools/Source/Python/Workspace/MetaFileParser.py | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py
> b/BaseTools/Source/Python/Workspace/MetaFileParser.py
> index fbfc182c8b..250cbf79a9 100644
> --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
> +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
> @@ -374,13 +374,16 @@ class MetaFileParser(object):
> if Name == 'INF_VERSION':
> if hexVersionPattern.match(Value):
> self._Version = int(Value, 0)
> elif decVersionPattern.match(Value):
> ValueList = Value.split('.')
> - Major = '%04o' % int(ValueList[0], 0)
> - Minor = '%04o' % int(ValueList[1], 0)
> - self._Version = int('0x' + Major + Minor, 0)
> + Major = int(ValueList[0], 0)
> + Minor = int(ValueList[1], 0)
> + if Major > 0xffff or Minor > 0xffff:
> + EdkLogger.error('Parser', FORMAT_INVALID, "Invalid version number",
> + ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)
> + self._Version = int('0x' +
> + '{0:04x}{1:04x}'.format(Major, Minor), 0)
> else:
> EdkLogger.error('Parser', FORMAT_INVALID, "Invalid version number",
> ExtraData=self._CurrentLine,
> File=self.MetaFile, Line=self._LineIndex + 1)
>
> if isinstance(self, InfParser) and self._Version < 0x00010005:
> --
> 2.12.2.windows.2
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-07-26 1:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-25 3:40 [PATCH] BaseTools: Parse decimal format INF_VERSION incorrect Yonghong Zhu
2018-07-26 0:41 ` Zhu, Yonghong
2018-07-26 1:23 ` Carsey, Jaben
2018-07-26 1:41 ` Zhu, Yonghong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox