Skip to contentSkip to conversation

bios-tables-test: delete a assert about block name

PATCH In review [email protected] 2 participants 8 messages Aug 14, 2017 – Aug 15, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bios-tables-test: delete a assert about block name

From: Wei Yang <[email protected]>

The assert would be touched when the version of acpica is greater than or equal to 20160318. its reason is that "Disasembler: Update a couple output items(commit id: 1ecbb3d)" is introduced by Robert, the patch emits the AML filename as a zero-length string, and allows the compiler to create the name later.

CC Michael S. Tsirkin <[email protected]>
CC Igor Mammedov <[email protected]>
---
 tests/bios-tables-test.c | 1 -
 1 file changed, 1 deletion(-)
tests/bios-tables-test.c +0 -1
index 88dbf97853..d2ab073848 100644
@@ -350,7 +350,6 @@ static GString *normalize_asl(gchar *asl_code)
     /* strip def block name (it has file path in it) */
     if (g_str_has_prefix(asl->str, DEF_BLOCK)) {
         block_name = g_strstr_len(asl->str, asl->len, BLOCK_NAME_END);
-        g_assert(block_name);
         asl = g_string_erase(asl, 0,
                              block_name + sizeof(BLOCK_NAME_END) - asl->str);
     }
Signature · 1 line
2.11.0
#1 lore raw
Quoted 7 lines · On Mon, Aug 14, 2017 at 04:48:38PM +0800, [email protected] wrote:

From: Wei Yang <[email protected]>

The assert would be touched when the version of acpica is greater than or equal to 20160318. its reason is that "Disasembler: Update a couple output items(commit id: 1ecbb3d)" is introduced by Robert, the patch emits the AML filename as a zero-length string, and allows the compiler to create the name later.

So how does the output look then? Do you mean there's no comma then?

Quoted 14 lines
CC Michael S. Tsirkin <[email protected]>
CC Igor Mammedov <[email protected]>
---
 tests/bios-tables-test.c | 1 -
 1 file changed, 1 deletion(-)
tests/bios-tables-test.c +0 -0
index 88dbf97853..d2ab073848 100644

tests/bios-tables-test.c static GString *normalize_asl(gchar *asl_code) · line 354

Quoted 6 lines
tests/bios-tables-test.c +0 -1
@@ -350,7 +350,6 @@ static GString *normalize_asl(gchar *asl_code)
     /* strip def block name (it has file path in it) */
     if (g_str_has_prefix(asl->str, DEF_BLOCK)) {
         block_name = g_strstr_len(asl->str, asl->len, BLOCK_NAME_END);
-        g_assert(block_name);
         asl = g_string_erase(asl, 0,
                              block_name + sizeof(BLOCK_NAME_END) - asl->str);

The pointer math here won't do the right thing then, will it?

Quoted 4 lines
tests/bios-tables-test.c +0 -0
     }
Signature · 1 line
2.11.0
#3 lore raw
In reply to wyang
Quoted 11 lines · wyang
Quoted 9 lines · Michael S. Tsirkin
Quoted 7 lines · On Mon, Aug 14, 2017 at 04:48:38PM +0800, [email protected] wrote:

From: Wei Yang <[email protected]>

The assert would be touched when the version of acpica is greater than or equal to 20160318. its reason is that "Disasembler: Update a couple output items(commit id: 1ecbb3d)" is introduced by Robert, the patch emits the AML filename as a zero-length string, and allows the compiler to create the name later.

So how does the output look then? Do you mean there's no comma then?

Quoted 8 lines

sorry for confusion, more clearly, since the AML filename is a zero-length string, so the output of dsl file looks like this after executing iasl command to disassemble AML file to DSL file

DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPCDSDT", 0x00000001)

the block name is NULL string.

It's an empty string, sure, but is it NULL?
I see:
block_name = g_strstr_len(asl->str, asl->len, BLOCK_NAME_END);

which looks for "," and assigns a pointer to it to block_name.

Is it actually NULL in your testing?

Quoted 43 lines

If the version of iasl command is less than 20160318, the output looks like

DefinitionBlock ("/tmp/xxxx.aml", "DSDT", 1, "BOCHS ", "BXPCDSDT", 0x00000001)

Quoted 10 lines
Quoted 10 lines
CC Michael S. Tsirkin <[email protected]>
CC Igor Mammedov <[email protected]>
---
  tests/bios-tables-test.c | 1 -
  1 file changed, 1 deletion(-)
Quoted 12 lines

tests/bios-tables-test.c static GString *normalize_asl(gchar *asl_code) · line 354

Quoted 11 lines
tests/bios-tables-test.c +0 -1
index 88dbf97853..d2ab073848 100644
@@ -350,7 +350,6 @@ static GString *normalize_asl(gchar *asl_code)
      /* strip def block name (it has file path in it) */
      if (g_str_has_prefix(asl->str, DEF_BLOCK)) {
          block_name = g_strstr_len(asl->str, asl->len, BLOCK_NAME_END);
-        g_assert(block_name);
          asl = g_string_erase(asl, 0,
                               block_name + sizeof(BLOCK_NAME_END) - asl->str);

The pointer math here won't do the right thing then, will it?

Yes, I will fix it.

Thanks
Wei

Quoted 5 lines
Quoted 5 lines
tests/bios-tables-test.c +0 -0
      }
Signature · 1 line
2.11.0
Signature · 3 lines
Wei Yang(杨伟)
Mobile: +86-13436682065
Email: [email protected]
author
#4 lore raw
Quoted 18 lines · Michael S. Tsirkin
Quoted 17 lines · wyang
Quoted 9 lines · Michael S. Tsirkin
Quoted 7 lines · On Mon, Aug 14, 2017 at 04:48:38PM +0800, [email protected] wrote:

From: Wei Yang <[email protected]>

The assert would be touched when the version of acpica is greater than or equal to 20160318. its reason is that "Disasembler: Update a couple output items(commit id: 1ecbb3d)" is introduced by Robert, the patch emits the AML filename as a zero-length string, and allows the compiler to create the name later.

So how does the output look then? Do you mean there's no comma then?

sorry for confusion, more clearly, since the AML filename is a zero-length string, so the output of dsl file looks like this after executing iasl command to disassemble AML file to DSL file

DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPCDSDT", 0x00000001)

Quoted 8 lines
Quoted 1 line

the block name is NULL string.

It's an empty string, sure, but is it NULL?
I see:
block_name = g_strstr_len(asl->str, asl->len, BLOCK_NAME_END);

which looks for "," and assigns a pointer to it to block_name.

Is it actually NULL in your testing?

Hmm, as I touched the assert, so I thought it is NULL, seems I SHOULD go on deeply digging into it. Thank MST for your review.

Wei

Quoted 39 lines
Quoted 39 lines

If the version of iasl command is less than 20160318, the output looks like

DefinitionBlock ("/tmp/xxxx.aml", "DSDT", 1, "BOCHS ", "BXPCDSDT", 0x00000001)

Quoted 9 lines
Quoted 9 lines
CC Michael S. Tsirkin <[email protected]>
CC Igor Mammedov <[email protected]>
---
   tests/bios-tables-test.c | 1 -
   1 file changed, 1 deletion(-)
Quoted 12 lines

tests/bios-tables-test.c static GString *normalize_asl(gchar *asl_code) · line 354

Quoted 11 lines
tests/bios-tables-test.c +0 -1
index 88dbf97853..d2ab073848 100644
@@ -350,7 +350,6 @@ static GString *normalize_asl(gchar *asl_code)
       /* strip def block name (it has file path in it) */
       if (g_str_has_prefix(asl->str, DEF_BLOCK)) {
           block_name = g_strstr_len(asl->str, asl->len, BLOCK_NAME_END);
-        g_assert(block_name);
           asl = g_string_erase(asl, 0,
                                block_name + sizeof(BLOCK_NAME_END) - asl->str);

The pointer math here won't do the right thing then, will it?

Yes, I will fix it.

Thanks
Wei

Quoted 4 lines
Quoted 4 lines
tests/bios-tables-test.c +0 -0
       }
Signature · 1 line
2.11.0
Signature · 3 lines
Wei Yang(杨伟)
Mobile: +86-13436682065
Email: [email protected]
Signature · 3 lines
Wei Yang(杨伟)
Mobile: +86-13436682065
Email: [email protected]
#5 lore raw
Quoted 26 lines · wyang
Quoted 23 lines · Michael S. Tsirkin
Quoted 10 lines · wyang
Quoted 9 lines · Michael S. Tsirkin
Quoted 7 lines · On Mon, Aug 14, 2017 at 04:48:38PM +0800, [email protected] wrote:

From: Wei Yang <[email protected]>

The assert would be touched when the version of acpica is greater than or equal to 20160318. its reason is that "Disasembler: Update a couple output items(commit id: 1ecbb3d)" is introduced by Robert, the patch emits the AML filename as a zero-length string, and allows the compiler to create the name later.

So how does the output look then? Do you mean there's no comma then?

Quoted 8 lines

sorry for confusion, more clearly, since the AML filename is a zero-length string, so the output of dsl file looks like this after executing iasl command to disassemble AML file to DSL file

DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPCDSDT", 0x00000001)

the block name is NULL string.

It's an empty string, sure, but is it NULL?
I see:
block_name = g_strstr_len(asl->str, asl->len, BLOCK_NAME_END);

Quoted 37 lines
Quoted 3 lines

which looks for "," and assigns a pointer to it to block_name.

Is it actually NULL in your testing?

Hmm, as I touched the assert, so I thought it is NULL, seems I SHOULD go on deeply digging into it. Thank MST for your review.

Wei

Quoted 30 lines
Quoted 30 lines

If the version of iasl command is less than 20160318, the output looks like

DefinitionBlock ("/tmp/xxxx.aml", "DSDT", 1, "BOCHS ", "BXPCDSDT", 0x00000001)

Quoted 9 lines
Quoted 9 lines
CC Michael S. Tsirkin <[email protected]>
CC Igor Mammedov <[email protected]>
---
   tests/bios-tables-test.c | 1 -
   1 file changed, 1 deletion(-)
Quoted 12 lines

tests/bios-tables-test.c static GString *normalize_asl(gchar *asl_code) · line 354

Quoted 11 lines
tests/bios-tables-test.c +0 -1
index 88dbf97853..d2ab073848 100644
@@ -350,7 +350,6 @@ static GString *normalize_asl(gchar *asl_code)
       /* strip def block name (it has file path in it) */
       if (g_str_has_prefix(asl->str, DEF_BLOCK)) {
           block_name = g_strstr_len(asl->str, asl->len, BLOCK_NAME_END);
-        g_assert(block_name);
           asl = g_string_erase(asl, 0,
                                block_name + sizeof(BLOCK_NAME_END) - asl->str);

The pointer math here won't do the right thing then, will it?

Yes, I will fix it.

Thanks
Wei

BTW sizeof(BLOCK_NAME_END) is actually 2. I think it works because there's a space after ,. It is better to replace it with strlen so it will work without a space too.

Quoted 15 lines
Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
tests/bios-tables-test.c +0 -0
       }
Signature · 1 line
2.11.0
Signature · 3 lines
Wei Yang(杨伟)
Mobile: +86-13436682065
Email: [email protected]
Signature · 3 lines
Wei Yang(杨伟)
Mobile: +86-13436682065
Email: [email protected]
author
#2 lore raw
In reply to Michael S. Tsirkin
Quoted 9 lines · Michael S. Tsirkin
Quoted 7 lines · On Mon, Aug 14, 2017 at 04:48:38PM +0800, [email protected] wrote:

From: Wei Yang <[email protected]>

The assert would be touched when the version of acpica is greater than or equal to 20160318. its reason is that "Disasembler: Update a couple output items(commit id: 1ecbb3d)" is introduced by Robert, the patch emits the AML filename as a zero-length string, and allows the compiler to create the name later.

So how does the output look then? Do you mean there's no comma then?

sorry for confusion, more clearly, since the AML filename is a zero-length string, so the output of dsl file looks like this after executing iasl command to disassemble AML file to DSL file

DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPCDSDT", 0x00000001)

the block name is NULL string.

If the version of iasl command is less than 20160318, the output looks like

DefinitionBlock ("/tmp/xxxx.aml", "DSDT", 1, "BOCHS ", "BXPCDSDT", 0x00000001)

Quoted 10 lines
Quoted 10 lines
CC Michael S. Tsirkin <[email protected]>
CC Igor Mammedov <[email protected]>
---
  tests/bios-tables-test.c | 1 -
  1 file changed, 1 deletion(-)
Quoted 12 lines

tests/bios-tables-test.c static GString *normalize_asl(gchar *asl_code) · line 354

Quoted 11 lines
tests/bios-tables-test.c +0 -1
index 88dbf97853..d2ab073848 100644
@@ -350,7 +350,6 @@ static GString *normalize_asl(gchar *asl_code)
      /* strip def block name (it has file path in it) */
      if (g_str_has_prefix(asl->str, DEF_BLOCK)) {
          block_name = g_strstr_len(asl->str, asl->len, BLOCK_NAME_END);
-        g_assert(block_name);
          asl = g_string_erase(asl, 0,
                               block_name + sizeof(BLOCK_NAME_END) - asl->str);

The pointer math here won't do the right thing then, will it?

Yes, I will fix it.

Thanks
Wei

Quoted 5 lines
Quoted 5 lines
tests/bios-tables-test.c +0 -0
      }
Signature · 1 line
2.11.0
Signature · 3 lines
Wei Yang(杨伟)
Mobile: +86-13436682065
Email: [email protected]
author Reviewed-by Michael S. Tsirkin
#6 lore raw
In reply to Michael S. Tsirkin
Quoted 3 lines · Michael S. Tsirkin

BTW sizeof(BLOCK_NAME_END) is actually 2. I think it works because there's a space after ,. It is better to replace it with strlen so it will work without a space too.

MST,

I double check the failure of assert, it has already been fixed by the following commit,

commit a3973f551dbee91f1f6f2c78e9942fb113b5d30b

Author: Marcel Apfelbaum <[email protected]>
Date:   Mon Apr 4 20:00:57 2016 +0300

tests/bios-tables-test: fix assert

Newer iasl does not add the aml file name to the Definition Block. See acpica tools commit 1ecbb3d5:
"Emit the AMLFilename as a zero-length string. Allows the
compiler to create
the name later -- making it easier to rename the parent ASL
(DSL) file."

That causes an assert in acpi tests:
tests/bios-tables-test.c:455:normalize_asl: assertion failed:
(block_name)

Fix it by striping the start of the definition block line until the
first comma.
The block name is always the first parameter and
the grammar does not allow comma in between, so it is safe.

I am sorry for my fault, my qemu version does not contain the patch.:-(

Seems the only place, which needs to be fixed, is to replace sizeof with strlen. Just like what you said, it is not fault but just refinement. If you need it, I am glad to send patch to fix it.

Wei

Signature · 3 lines
Wei Yang(杨伟)
Mobile: +86-13436682065
Email: [email protected]
#7 lore raw
Quoted 5 lines · wyang

Seems the only place, which needs to be fixed, is to replace sizeof with strlen. Just like what you said, it is not fault but just refinement. If you need it, I am glad to send patch to fix it.

Wei

Sure.

Quoted 5 lines
Signature · 3 lines
Wei Yang(杨伟)
Mobile: +86-13436682065
Email: [email protected]