diff mbox series

tools: PCI: Zero-initialize param

Message ID 20210627003937.6249-1-yang.shunyong@gmail.com (mailing list archive)
State Superseded
Delegated to: Lorenzo Pieralisi
Headers show
Series tools: PCI: Zero-initialize param | expand

Commit Message

Shunyong Yang June 27, 2021, 12:39 a.m. UTC
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.

Signed-off-by: Shunyong Yang <yang.shunyong@gmail.com>
---
 tools/pci/pcitest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Shunyong Yang July 11, 2021, 1:48 a.m. UTC | #1
Hi, Bjorn and Kishon,

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

Thansk.

Shunyong.

On 2021/6/27 8:39, Shunyong Yang wrote:
> 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.
>
> Signed-off-by: Shunyong Yang <yang.shunyong@gmail.com>
> ---
>   tools/pci/pcitest.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/pci/pcitest.c b/tools/pci/pcitest.c
> index 0a1344c45213..59bcd6220a58 100644
> --- a/tools/pci/pcitest.c
> +++ b/tools/pci/pcitest.c
> @@ -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;
>
Leon Romanovsky July 11, 2021, 11:56 a.m. UTC | #2
On Sun, Jul 11, 2021 at 09:48:17AM +0800, Shunyong Yang wrote:
> Hi, Bjorn and Kishon,
> 
>   Gentle ping. Would you please help to review and merge this tiny change?
> 
> Thansk.
> 
> Shunyong.
> 
> On 2021/6/27 8:39, Shunyong Yang wrote:
> > 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.
> > 
> > Signed-off-by: Shunyong Yang <yang.shunyong@gmail.com>
> > ---
> >   tools/pci/pcitest.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/tools/pci/pcitest.c b/tools/pci/pcitest.c
> > index 0a1344c45213..59bcd6220a58 100644
> > --- a/tools/pci/pcitest.c
> > +++ b/tools/pci/pcitest.c
> > @@ -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

> >   	int ret = -EINVAL;
> >   	int fd;
Shunyong Yang July 13, 2021, 1:24 p.m. UTC | #3
Hi,  Romanovsky,

On 2021/7/11 19:56, Leon Romanovsky wrote:
> On Sun, Jul 11, 2021 at 09:48:17AM +0800, Shunyong Yang wrote:
>> Hi, Bjorn and Kishon,
>>
>>    Gentle ping. Would you please help to review and merge this tiny change?
>>
>> Thansk.
>>
>> Shunyong.
>>
>> On 2021/6/27 8:39, Shunyong Yang wrote:
>>> 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.
>>>
>>> Signed-off-by: Shunyong Yang <yang.shunyong@gmail.com>
>>> ---
>>>    tools/pci/pcitest.c | 2 +-
>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/tools/pci/pcitest.c b/tools/pci/pcitest.c
>>> index 0a1344c45213..59bcd6220a58 100644
>>> --- a/tools/pci/pcitest.c
>>> +++ b/tools/pci/pcitest.c
>>> @@ -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

    Will change as you said.

Thanks.

Shunyong.

>>>    	int ret = -EINVAL;
>>>    	int fd;
diff mbox series

Patch

diff --git a/tools/pci/pcitest.c b/tools/pci/pcitest.c
index 0a1344c45213..59bcd6220a58 100644
--- a/tools/pci/pcitest.c
+++ b/tools/pci/pcitest.c
@@ -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;