[PATCH] Uses size_t for open_memstream size parameter.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



open_memstream expects a size_t pointer instead of an int pointer. In
64-bit platforms, size_t is 64-bit. Using the int pointer will make
other bytes be overriden when the stream is closed and on big-endian
platforms, the size will be updated to 0, which will make tgtadm create
invalid requests for tgtd.

iqn.2010-10.org.example:volume-123
tgtadm: invalid request

The size_t pointer cast hid this problem, which would produce a warning
otherwise.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@xxxxxxxxxxxxxxxxxx>
---
 usr/concat_buf.c |    2 +-
 usr/util.h       |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/usr/concat_buf.c b/usr/concat_buf.c
index 00661d4..d1fe53e 100644
--- a/usr/concat_buf.c
+++ b/usr/concat_buf.c
@@ -29,7 +29,7 @@
 
 void concat_buf_init(struct concat_buf *b)
 {
-	b->streamf = open_memstream(&b->buf, (size_t *)&b->size);
+	b->streamf = open_memstream(&b->buf, &b->size);
 	b->err = b->streamf ? 0 : errno;
 	b->used = 0;
 }
diff --git a/usr/util.h b/usr/util.h
index 93f9c89..d01d58b 100644
--- a/usr/util.h
+++ b/usr/util.h
@@ -195,7 +195,7 @@ struct concat_buf {
 	int err;
 	int used;
 	char *buf;
-	int size;
+	size_t size;
 };
 
 void concat_buf_init(struct concat_buf *b);
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux