git » libjio » commit 234f105

write(), pwrite() and writev() have the buffer parameter as 'const'; but our wrappers haven't.

author Alberto Bertogli
2004-05-05 01:27:24 UTC
committer Alberto Bertogli
2007-07-15 12:44:26 UTC
parent 60f270d550624ce7867100ee54743866604a08bb

write(), pwrite() and writev() have the buffer parameter as 'const'; but our wrappers haven't.

write(), pwrite() and writev() have the buffer parameter as 'const'; but our
wrappers haven't.

This patch adds the 'const', not only in the function prototypes but also to
the buf member of the transaction structure.

Thanks to Pieter Grimmerink for pointing this out.

doc/libjio.3 +3 -3
libjio.c +4 -4
libjio.h +4 -4

diff --git a/doc/libjio.3 b/doc/libjio.3
index 9584cd6..8c9a5e0 100644
--- a/doc/libjio.3
+++ b/doc/libjio.3
@@ -14,11 +14,11 @@ libjio - A library for Journaled I/O
 
 .BI "ssize_t jreadv(struct jfs *" fs ", struct iovec *" vector ", int " count " );
 
-.BI "ssize_t jwrite(struct jfs *" fs ", void *" buf ", size_t " count " );
+.BI "ssize_t jwrite(struct jfs *" fs ", const void *" buf ", size_t " count " );
 
-.BI "ssize_t jpwrite(struct jfs *" fs ", void *" buf ", size_t " count ", off_t " offset " );
+.BI "ssize_t jpwrite(struct jfs *" fs ", const void *" buf ", size_t " count ", off_t " offset " );
 
-.BI "ssize_t jwritev(struct jfs *" fs ", struct iovec *" vector ", int " count " );
+.BI "ssize_t jwritev(struct jfs *" fs ", const struct iovec *" vector ", int " count " );
 
 .BI "int jtruncate(struct jfs *" fs ", off_t " lenght " );
 
diff --git a/libjio.c b/libjio.c
index f634a01..002af47 100644
--- a/libjio.c
+++ b/libjio.c
@@ -77,7 +77,7 @@ static ssize_t spread(int fd, void *buf, size_t count, off_t offset)
 }
 
 /* like spread() but for pwrite() */
-static ssize_t spwrite(int fd, void *buf, size_t count, off_t offset)
+static ssize_t spwrite(int fd, const void *buf, size_t count, off_t offset)
 {
 	int rv, c;
 
@@ -549,7 +549,7 @@ ssize_t jreadv(struct jfs *fs, struct iovec *vector, int count)
 }
 
 /* write wrapper */
-ssize_t jwrite(struct jfs *fs, void *buf, size_t count)
+ssize_t jwrite(struct jfs *fs, const void *buf, size_t count)
 {
 	int rv;
 	off_t pos;
@@ -581,7 +581,7 @@ ssize_t jwrite(struct jfs *fs, void *buf, size_t count)
 /* write family wrappers */
 
 /* pwrite wrapper */
-ssize_t jpwrite(struct jfs *fs, void *buf, size_t count, off_t offset)
+ssize_t jpwrite(struct jfs *fs, const void *buf, size_t count, off_t offset)
 {
 	int rv;
 	struct jtrans ts;
@@ -600,7 +600,7 @@ ssize_t jpwrite(struct jfs *fs, void *buf, size_t count, off_t offset)
 }
 
 /* writev wrapper */
-ssize_t jwritev(struct jfs *fs, struct iovec *vector, int count)
+ssize_t jwritev(struct jfs *fs, const struct iovec *vector, int count)
 {
 	int rv, i, bufp;
 	ssize_t sum;
diff --git a/libjio.h b/libjio.h
index 8fb6b8b..409370f 100644
--- a/libjio.h
+++ b/libjio.h
@@ -31,7 +31,7 @@ struct jtrans {
 	char *name;		/* name of the transaction file */
 	int id;			/* transaction id */
 	int flags;		/* misc flags */
-	void *buf;		/* buffer */
+	const void *buf;	/* buffer */
 	size_t len;		/* buffer lenght */
 	off_t offset;		/* file offset to operate on */
 	void *udata;		/* user-supplied data */
@@ -73,9 +73,9 @@ int jopen(struct jfs *fs, const char *name, int flags, int mode, int jflags);
 ssize_t jread(struct jfs *fs, void *buf, size_t count);
 ssize_t jpread(struct jfs *fs, void *buf, size_t count, off_t offset);
 ssize_t jreadv(struct jfs *fs, struct iovec *vector, int count);
-ssize_t jwrite(struct jfs *fs, void *buf, size_t count);
-ssize_t jpwrite(struct jfs *fs, void *buf, size_t count, off_t offset);
-ssize_t jwritev(struct jfs *fs, struct iovec *vector, int count);
+ssize_t jwrite(struct jfs *fs, const void *buf, size_t count);
+ssize_t jpwrite(struct jfs *fs, const void *buf, size_t count, off_t offset);
+ssize_t jwritev(struct jfs *fs, const struct iovec *vector, int count);
 int jtruncate(struct jfs *fs, off_t lenght);
 int jclose(struct jfs *fs);