Skip to contentSkip to conversation

tools: PCI: Zero-initialize param

PATCH Superseded Shunyong Yang 2 participants 4 messages Jun 27, 2021 – Jul 13, 2021 PCI

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools: PCI: Zero-initialize param

The values in param may be random if they are not initialized, which may cause use_dma flag set even when "-d" option is not provided in command line. Initializing all members to 0 to solve this.

---
 tools/pci/pcitest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/pci/pcitest.c +1 -1
index 0a1344c45213..59bcd6220a58 100644
@@ -40,7 +40,7 @@ struct pci_test {
 
 static int run_test(struct pci_test *test)
 {
-	struct pci_endpoint_test_xfer_param param;
+	struct pci_endpoint_test_xfer_param param = {0};
 	int ret = -EINVAL;
 	int fd;
 
Signature · 1 line
2.17.1
#1 lore raw

Hi, Bjorn and Kishon,

  Gentle ping. Would you please help to review and merge this tiny change?

Thansk.

Shunyong.

Quoted 22 lines · Shunyong Yang

The values in param may be random if they are not initialized, which may cause use_dma flag set even when "-d" option is not provided in command line. Initializing all members to 0 to solve this.

---
  tools/pci/pcitest.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/pci/pcitest.c +1 -1
index 0a1344c45213..59bcd6220a58 100644
@@ -40,7 +40,7 @@ struct pci_test {
 
  static int run_test(struct pci_test *test)
  {
-	struct pci_endpoint_test_xfer_param param;
+	struct pci_endpoint_test_xfer_param param = {0};
  	int ret = -EINVAL;
  	int fd;
 
#2 lore raw
Quoted 18 lines · Shunyong Yang

Hi, Bjorn and Kishon,

  Gentle ping. Would you please help to review and merge this tiny change?

Thansk.

Shunyong.

Quoted 9 lines · Shunyong Yang

The values in param may be random if they are not initialized, which may cause use_dma flag set even when "-d" option is not provided in command line. Initializing all members to 0 to solve this.

---
  tools/pci/pcitest.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 9 lines

tools/pci/pcitest.c struct pci_test { · line 42

Quoted 9 lines
tools/pci/pcitest.c +1 -1
index 0a1344c45213..59bcd6220a58 100644
@@ -40,7 +40,7 @@ struct pci_test {
  static int run_test(struct pci_test *test)
  {
-	struct pci_endpoint_test_xfer_param param;
+	struct pci_endpoint_test_xfer_param param = {0};

You can simply write {} instead of {0} - zero is not needed.

Thanks

Quoted 2 lines
Quoted 2 lines
tools/pci/pcitest.c +0 -0
  	int ret = -EINVAL;
  	int fd;
#3 lore raw

Hi,  Romanovsky,

Quoted 30 lines · Leon Romanovsky
Quoted 18 lines · Shunyong Yang

Hi, Bjorn and Kishon,

  Gentle ping. Would you please help to review and merge this tiny change?

Thansk.

Shunyong.

Quoted 9 lines · Shunyong Yang

The values in param may be random if they are not initialized, which may cause use_dma flag set even when "-d" option is not provided in command line. Initializing all members to 0 to solve this.

---
   tools/pci/pcitest.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 9 lines

tools/pci/pcitest.c struct pci_test { · line 42

Quoted 9 lines
tools/pci/pcitest.c +1 -1
index 0a1344c45213..59bcd6220a58 100644
@@ -40,7 +40,7 @@ struct pci_test {
   static int run_test(struct pci_test *test)
   {
-	struct pci_endpoint_test_xfer_param param;
+	struct pci_endpoint_test_xfer_param param = {0};

You can simply write {} instead of {0} - zero is not needed.

Quoted 1 line

Thanks

   Will change as you said.

Thanks.

Shunyong.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
tools/pci/pcitest.c +0 -0
   	int ret = -EINVAL;
   	int fd;