Skip to contentSkip to conversation

CIFS: Fix variable types in cifs_iovec_read/write (try #2)

PATCH In review Pavel Shilovsky 2 participants 5 messages Jan 31, 2011 – Feb 3, 2011 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 CIFS: Fix variable types in cifs_iovec_read/write (try #2)

Variable 'i' should be unsigned long as it's used in circle with num_pages, and bytes_read/total_written should be ssize_t according to return value.

---
 fs/cifs/file.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
fs/cifs/file.c +6 -5
index 74c0a28..e964b1c 100644
@@ -1662,10 +1662,10 @@ static ssize_t
 cifs_iovec_write(struct file *file, const struct iovec *iov,
 		 unsigned long nr_segs, loff_t *poffset)
 {
-	size_t total_written = 0;
-	unsigned int written = 0;
-	unsigned long num_pages, npages;
-	size_t copied, len, cur_len, i;
+	unsigned int written;
+	unsigned long num_pages, npages, i;
+	size_t copied, len, cur_len;
+	ssize_t total_written = 0;
 	struct kvec *to_send;
 	struct page **pages;
 	struct iov_iter it;
@@ -1821,7 +1821,8 @@ cifs_iovec_read(struct file *file, const struct iovec *iov,
 {
 	int rc;
 	int xid;
-	unsigned int total_read, bytes_read = 0;
+	ssize_t total_read;
+	unsigned int bytes_read = 0;
 	size_t len, cur_len;
 	int iov_offset = 0;
 	struct cifs_sb_info *cifs_sb;
Signature · 1 line
1.7.1

A message that is not in the archive (sent off-list or not yet received): 1296478988-22307-1-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org

#2 lore raw

2011/1/31 Pavel Shilovsky <[email protected]>:

Quoted 38 lines

Variable 'i' should be unsigned long as it's used in circle with num_pages, and bytes_read/total_written should be ssize_t according to return value.

---
 fs/cifs/file.c |   11 ++++++-----

 1 files changed, 6 insertions(+), 5 deletions(-)
fs/cifs/file.c +6 -6
index 74c0a28..e964b1c 100644
@@ -1662,10 +1662,10 @@ static ssize_t
  cifs_iovec_write(struct file *file, const struct iovec *iov,
                 unsigned long nr_segs, loff_t *poffset)
  {
-       size_t total_written = 0;
-       unsigned int written = 0;
-       unsigned long num_pages, npages;
-       size_t copied, len, cur_len, i;
+       unsigned int written;
+       unsigned long num_pages, npages, i;
+       size_t copied, len, cur_len;
+       ssize_t total_written = 0;
        struct kvec *to_send;
        struct page **pages;
        struct iov_iter it;
@@ -1821,7 +1821,8 @@ cifs_iovec_read(struct file *file, const struct iovec *iov,
  {
        int rc;
        int xid;
-       unsigned int total_read, bytes_read = 0;
+       ssize_t total_read;
+       unsigned int bytes_read = 0;
        size_t len, cur_len;
        int iov_offset = 0;
        struct cifs_sb_info *cifs_sb;
--
Quoted 3 lines

1.7.1

What's about this?

Signature · 2 lines
Best regards,
Pavel Shilovsky.
#3 lore raw
In reply to a message not in the archive
Quoted 40 lines · Pavel Shilovsky

Variable 'i' should be unsigned long as it's used in circle with num_pages, and bytes_read/total_written should be ssize_t according to return value.

---
 fs/cifs/file.c |   11 ++++++-----

 1 files changed, 6 insertions(+), 5 deletions(-)
fs/cifs/file.c +6 -6
index 74c0a28..e964b1c 100644
@@ -1662,10 +1662,10 @@ static ssize_t
  cifs_iovec_write(struct file *file, const struct iovec *iov,
                 unsigned long nr_segs, loff_t *poffset)
  {
-       size_t total_written = 0;
-       unsigned int written = 0;
-       unsigned long num_pages, npages;
-       size_t copied, len, cur_len, i;
+       unsigned int written;
+       unsigned long num_pages, npages, i;
+       size_t copied, len, cur_len;
+       ssize_t total_written = 0;
        struct kvec *to_send;
        struct page **pages;
        struct iov_iter it;
@@ -1821,7 +1821,8 @@ cifs_iovec_read(struct file *file, const struct iovec *iov,
  {
        int rc;
        int xid;
-       unsigned int total_read, bytes_read = 0;
+       ssize_t total_read;
+       unsigned int bytes_read = 0;
        size_t len, cur_len;
        int iov_offset = 0;
        struct cifs_sb_info *cifs_sb;
--

1.7.1

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at  http://vger.kernel.org/majordomo-info.html

Should written be initialized to 0 at the top of the outer do loop in function cifs_iovec_write() in case CIFSSMBWrite2 returns with an error other than EAGAIN without writing anything?

Other than the above query, other things look correct.

A message that is not in the archive (sent off-list or not yet received): AANLkTingtQ=U9abGN9OBfzRsnqo6ZMctGaiesqAa4MWz-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#5 lore raw

2011/2/3 Shirish Pargaonkar <[email protected]>:

Quoted 41 lines · Pavel Shilovsky
Quoted 40 lines

Variable 'i' should be unsigned long as it's used in circle with num_pages, and bytes_read/total_written should be ssize_t according to return value.

---
 fs/cifs/file.c |   11 ++++++-----

 1 files changed, 6 insertions(+), 5 deletions(-)
fs/cifs/file.c +6 -6
index 74c0a28..e964b1c 100644
@@ -1662,10 +1662,10 @@ static ssize_t
  cifs_iovec_write(struct file *file, const struct iovec *iov,
                 unsigned long nr_segs, loff_t *poffset)
  {
-       size_t total_written = 0;
-       unsigned int written = 0;
-       unsigned long num_pages, npages;
-       size_t copied, len, cur_len, i;
+       unsigned int written;
+       unsigned long num_pages, npages, i;
+       size_t copied, len, cur_len;
+       ssize_t total_written = 0;
        struct kvec *to_send;
        struct page **pages;
        struct iov_iter it;
@@ -1821,7 +1821,8 @@ cifs_iovec_read(struct file *file, const struct iovec *iov,
  {
        int rc;
        int xid;
-       unsigned int total_read, bytes_read = 0;
+       ssize_t total_read;
+       unsigned int bytes_read = 0;
        size_t len, cur_len;
        int iov_offset = 0;
        struct cifs_sb_info *cifs_sb;
--

1.7.1

Quoted 9 lines
Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at  http://vger.kernel.org/majordomo-info.html

Should written be initialized to 0 at the top of the outer do loop in function cifs_iovec_write() in case CIFSSMBWrite2 returns with an error other than EAGAIN without writing anything?

It seems like it assigned to 0 at the start of CIFSSMBWrite2 - so in this case there is no need to initialize it.

Quoted 7 lines

Other than the above query, other things look correct.
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at  http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Best regards,
Pavel Shilovsky.

A message that is not in the archive (sent off-list or not yet received): AANLkTinuU3eL9hPdLmr9MYnpK8OCvg8-1vf-Hzt1dUSV-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

Reviewed-by
#7 lore raw
Quoted 65 lines · Pavel Shilovsky

2011/2/3 Shirish Pargaonkar <[email protected]>:

Quoted 41 lines · Pavel Shilovsky
Quoted 40 lines

Variable 'i' should be unsigned long as it's used in circle with num_pages, and bytes_read/total_written should be ssize_t according to return value.

---
 fs/cifs/file.c |   11 ++++++-----

 1 files changed, 6 insertions(+), 5 deletions(-)
fs/cifs/file.c +6 -6
index 74c0a28..e964b1c 100644
@@ -1662,10 +1662,10 @@ static ssize_t
  cifs_iovec_write(struct file *file, const struct iovec *iov,
                 unsigned long nr_segs, loff_t *poffset)
  {
-       size_t total_written = 0;
-       unsigned int written = 0;
-       unsigned long num_pages, npages;
-       size_t copied, len, cur_len, i;
+       unsigned int written;
+       unsigned long num_pages, npages, i;
+       size_t copied, len, cur_len;
+       ssize_t total_written = 0;
        struct kvec *to_send;
        struct page **pages;
        struct iov_iter it;
@@ -1821,7 +1821,8 @@ cifs_iovec_read(struct file *file, const struct iovec *iov,
  {
        int rc;
        int xid;
-       unsigned int total_read, bytes_read = 0;
+       ssize_t total_read;
+       unsigned int bytes_read = 0;
        size_t len, cur_len;
        int iov_offset = 0;
        struct cifs_sb_info *cifs_sb;
--

1.7.1

Quoted 9 lines
Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at  http://vger.kernel.org/majordomo-info.html

Should written be initialized to 0 at the top of the outer do loop in function cifs_iovec_write() in case CIFSSMBWrite2 returns with an error other than EAGAIN without writing anything?

It seems like it assigned to 0 at the start of CIFSSMBWrite2 - so in this case there is no need to initialize it.

Quoted 7 lines

Other than the above query, other things look correct.
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at  http://vger.kernel.org/majordomo-info.html

Quoted 4 lines

--
Best regards,
Pavel Shilovsky.

yes.