diff mbox

cifs: initialize nbytes at the beginning of CIFSSMBWrite()

Message ID 1269955441-20729-1-git-send-email-sjayaraman@suse.de
State New
Headers show

Commit Message

Suresh Jayaraman March 30, 2010, 1:24 p.m. UTC
By doing this we always overwrite nbytes value that is being passed on to
CIFSSMBWrite() and need not rely on the callers to initialize. CIFSSMBWrite2 is
doing this already.

Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
---
 fs/cifs/cifssmb.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Comments

Jeff Layton March 30, 2010, 1:33 p.m. UTC | #1
On Tue, 30 Mar 2010 18:54:01 +0530
Suresh Jayaraman <sjayaraman@suse.de> wrote:

> By doing this we always overwrite nbytes value that is being passed on to
> CIFSSMBWrite() and need not rely on the callers to initialize. CIFSSMBWrite2 is
> doing this already.
> 
> Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
> ---
>  fs/cifs/cifssmb.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
> index 7cc7f83..e1f90a3 100644
> --- a/fs/cifs/cifssmb.c
> +++ b/fs/cifs/cifssmb.c
> @@ -1430,6 +1430,8 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
>  	__u32 bytes_sent;
>  	__u16 byte_count;
>  
> +	*nbytes = 0;
> +
>  	/* cFYI(1, ("write at %lld %d bytes", offset, count));*/
>  	if (tcon->ses == NULL)
>  		return -ECONNABORTED;
> @@ -1512,7 +1514,6 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
>  	cifs_stats_inc(&tcon->num_writes);
>  	if (rc) {
>  		cFYI(1, ("Send error in write = %d", rc));
> -		*nbytes = 0;
>  	} else {
>  		*nbytes = le16_to_cpu(pSMBr->CountHigh);
>  		*nbytes = (*nbytes) << 16;
> _______________________________________________
> linux-cifs-client mailing list
> linux-cifs-client@lists.samba.org
> https://lists.samba.org/mailman/listinfo/linux-cifs-client
> 

Reviewed-by: Jeff Layton <jlayton@samba.org>
Steve French March 30, 2010, 2:25 p.m. UTC | #2
This looks like we want to push it upstream ASAP - any objections?

On Tue, Mar 30, 2010 at 8:33 AM, Jeff Layton <jlayton@samba.org> wrote:
> On Tue, 30 Mar 2010 18:54:01 +0530
> Suresh Jayaraman <sjayaraman@suse.de> wrote:
>
>> By doing this we always overwrite nbytes value that is being passed on to
>> CIFSSMBWrite() and need not rely on the callers to initialize. CIFSSMBWrite2 is
>> doing this already.
>>
>> Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
>> ---
>>  fs/cifs/cifssmb.c |    3 ++-
>>  1 files changed, 2 insertions(+), 1 deletions(-)
>>
>> diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
>> index 7cc7f83..e1f90a3 100644
>> --- a/fs/cifs/cifssmb.c
>> +++ b/fs/cifs/cifssmb.c
>> @@ -1430,6 +1430,8 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
>>       __u32 bytes_sent;
>>       __u16 byte_count;
>>
>> +     *nbytes = 0;
>> +
>>       /* cFYI(1, ("write at %lld %d bytes", offset, count));*/
>>       if (tcon->ses == NULL)
>>               return -ECONNABORTED;
>> @@ -1512,7 +1514,6 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
>>       cifs_stats_inc(&tcon->num_writes);
>>       if (rc) {
>>               cFYI(1, ("Send error in write = %d", rc));
>> -             *nbytes = 0;
>>       } else {
>>               *nbytes = le16_to_cpu(pSMBr->CountHigh);
>>               *nbytes = (*nbytes) << 16;
>> _______________________________________________
>> linux-cifs-client mailing list
>> linux-cifs-client@lists.samba.org
>> https://lists.samba.org/mailman/listinfo/linux-cifs-client
>>
>
> Reviewed-by: Jeff Layton <jlayton@samba.org>
>
Jeff Layton March 30, 2010, 2:34 p.m. UTC | #3
On Tue, 30 Mar 2010 09:25:39 -0500
Steve French <smfrench@gmail.com> wrote:

> This looks like we want to push it upstream ASAP - any objections?
> 

No objections. It's a straightforward bugfix. Maybe even reasonable for
stable.

> On Tue, Mar 30, 2010 at 8:33 AM, Jeff Layton <jlayton@samba.org> wrote:
> > On Tue, 30 Mar 2010 18:54:01 +0530
> > Suresh Jayaraman <sjayaraman@suse.de> wrote:
> >
> >> By doing this we always overwrite nbytes value that is being passed on to
> >> CIFSSMBWrite() and need not rely on the callers to initialize. CIFSSMBWrite2 is
> >> doing this already.
> >>
> >> Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
> >> ---
> >>  fs/cifs/cifssmb.c |    3 ++-
> >>  1 files changed, 2 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
> >> index 7cc7f83..e1f90a3 100644
> >> --- a/fs/cifs/cifssmb.c
> >> +++ b/fs/cifs/cifssmb.c
> >> @@ -1430,6 +1430,8 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
> >>       __u32 bytes_sent;
> >>       __u16 byte_count;
> >>
> >> +     *nbytes = 0;
> >> +
> >>       /* cFYI(1, ("write at %lld %d bytes", offset, count));*/
> >>       if (tcon->ses == NULL)
> >>               return -ECONNABORTED;
> >> @@ -1512,7 +1514,6 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
> >>       cifs_stats_inc(&tcon->num_writes);
> >>       if (rc) {
> >>               cFYI(1, ("Send error in write = %d", rc));
> >> -             *nbytes = 0;
> >>       } else {
> >>               *nbytes = le16_to_cpu(pSMBr->CountHigh);
> >>               *nbytes = (*nbytes) << 16;
> >> _______________________________________________
> >> linux-cifs-client mailing list
> >> linux-cifs-client@lists.samba.org
> >> https://lists.samba.org/mailman/listinfo/linux-cifs-client
> >>
> >
> > Reviewed-by: Jeff Layton <jlayton@samba.org>
> >
> 
> 
>
Shirish Pargaonkar March 30, 2010, 3:28 p.m. UTC | #4
nitpicking, we probably do not need braces around if check then.

On Tue, Mar 30, 2010 at 9:34 AM, Jeff Layton <jlayton@samba.org> wrote:
> On Tue, 30 Mar 2010 09:25:39 -0500
> Steve French <smfrench@gmail.com> wrote:
>
>> This looks like we want to push it upstream ASAP - any objections?
>>
>
> No objections. It's a straightforward bugfix. Maybe even reasonable for
> stable.
>
>> On Tue, Mar 30, 2010 at 8:33 AM, Jeff Layton <jlayton@samba.org> wrote:
>> > On Tue, 30 Mar 2010 18:54:01 +0530
>> > Suresh Jayaraman <sjayaraman@suse.de> wrote:
>> >
>> >> By doing this we always overwrite nbytes value that is being passed on to
>> >> CIFSSMBWrite() and need not rely on the callers to initialize. CIFSSMBWrite2 is
>> >> doing this already.
>> >>
>> >> Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
>> >> ---
>> >>  fs/cifs/cifssmb.c |    3 ++-
>> >>  1 files changed, 2 insertions(+), 1 deletions(-)
>> >>
>> >> diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
>> >> index 7cc7f83..e1f90a3 100644
>> >> --- a/fs/cifs/cifssmb.c
>> >> +++ b/fs/cifs/cifssmb.c
>> >> @@ -1430,6 +1430,8 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
>> >>       __u32 bytes_sent;
>> >>       __u16 byte_count;
>> >>
>> >> +     *nbytes = 0;
>> >> +
>> >>       /* cFYI(1, ("write at %lld %d bytes", offset, count));*/
>> >>       if (tcon->ses == NULL)
>> >>               return -ECONNABORTED;
>> >> @@ -1512,7 +1514,6 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
>> >>       cifs_stats_inc(&tcon->num_writes);
>> >>       if (rc) {
>> >>               cFYI(1, ("Send error in write = %d", rc));
>> >> -             *nbytes = 0;
>> >>       } else {
>> >>               *nbytes = le16_to_cpu(pSMBr->CountHigh);
>> >>               *nbytes = (*nbytes) << 16;
>> >> _______________________________________________
>> >> linux-cifs-client mailing list
>> >> linux-cifs-client@lists.samba.org
>> >> https://lists.samba.org/mailman/listinfo/linux-cifs-client
>> >>
>> >
>> > Reviewed-by: Jeff Layton <jlayton@samba.org>
>> >
>>
>>
>>
>
>
> --
> Jeff Layton <jlayton@samba.org>
> _______________________________________________
> linux-cifs-client mailing list
> linux-cifs-client@lists.samba.org
> https://lists.samba.org/mailman/listinfo/linux-cifs-client
>
Suresh Jayaraman March 30, 2010, 5:34 p.m. UTC | #5
On 03/30/2010 08:58 PM, Shirish Pargaonkar wrote:
> nitpicking, we probably do not need braces around if check then.

Good catch, removed the unnecessary brace. Not sure why checkpatch.pl didn't
catch this.


> On Tue, Mar 30, 2010 at 9:34 AM, Jeff Layton <jlayton@samba.org> wrote:
>> On Tue, 30 Mar 2010 09:25:39 -0500
>> Steve French <smfrench@gmail.com> wrote:
>>
>>> This looks like we want to push it upstream ASAP - any objections?
>>>
>>
>> No objections. It's a straightforward bugfix. Maybe even reasonable for
>> stable.
>>
>>> On Tue, Mar 30, 2010 at 8:33 AM, Jeff Layton <jlayton@samba.org> wrote:
>>>> On Tue, 30 Mar 2010 18:54:01 +0530
>>>> Suresh Jayaraman <sjayaraman@suse.de> wrote:
>>>>
>>>>> By doing this we always overwrite nbytes value that is being passed on to
>>>>> CIFSSMBWrite() and need not rely on the callers to initialize. CIFSSMBWrite2 is
>>>>> doing this already.
>>>>>
>>>>> Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
>>>>> ---
>>>>> �fs/cifs/cifssmb.c | � �3 ++-
>>>>> �1 files changed, 2 insertions(+), 1 deletions(-)
>>>>>
>>>>> diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
>>>>> index 7cc7f83..e1f90a3 100644
>>>>> --- a/fs/cifs/cifssmb.c
>>>>> +++ b/fs/cifs/cifssmb.c
>>>>> @@ -1430,6 +1430,8 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
>>>>> � � � __u32 bytes_sent;
>>>>> � � � __u16 byte_count;
>>>>>
>>>>> + � � *nbytes = 0;
>>>>> +
>>>>> � � � /* cFYI(1, ("write at %lld %d bytes", offset, count));*/
>>>>> � � � if (tcon->ses == NULL)
>>>>> � � � � � � � return -ECONNABORTED;
>>>>> @@ -1512,7 +1514,6 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
>>>>> � � � cifs_stats_inc(&tcon->num_writes);
>>>>> � � � if (rc) {
>>>>> � � � � � � � cFYI(1, ("Send error in write = %d", rc));
>>>>> - � � � � � � *nbytes = 0;
>>>>> � � � } else {
>>>>> � � � � � � � *nbytes = le16_to_cpu(pSMBr->CountHigh);
>>>>> � � � � � � � *nbytes = (*nbytes) << 16;
>>>>> _______________________________________________
>>>>> linux-cifs-client mailing list
>>>>> linux-cifs-client@lists.samba.org
>>>>> https://lists.samba.org/mailman/listinfo/linux-cifs-client
>>>>>
>>>>
>>>> Reviewed-by: Jeff Layton <jlayton@samba.org>
>>>>
>>>
>>>
>>>
>>
>>
>> --
>> Jeff Layton <jlayton@samba.org>
>> _______________________________________________
>> linux-cifs-client mailing list
>> linux-cifs-client@lists.samba.org
>> https://lists.samba.org/mailman/listinfo/linux-cifs-client
>>
> _______________________________________________
> linux-cifs-client mailing list
> linux-cifs-client@lists.samba.org
> https://lists.samba.org/mailman/listinfo/linux-cifs-client
diff mbox

Patch

diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 7cc7f83..e1f90a3 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -1430,6 +1430,8 @@  CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
 	__u32 bytes_sent;
 	__u16 byte_count;
 
+	*nbytes = 0;
+
 	/* cFYI(1, ("write at %lld %d bytes", offset, count));*/
 	if (tcon->ses == NULL)
 		return -ECONNABORTED;
@@ -1512,7 +1514,6 @@  CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
 	cifs_stats_inc(&tcon->num_writes);
 	if (rc) {
 		cFYI(1, ("Send error in write = %d", rc));
-		*nbytes = 0;
 	} else {
 		*nbytes = le16_to_cpu(pSMBr->CountHigh);
 		*nbytes = (*nbytes) << 16;