git » nmdb » commit 31201b0

"const"ify struct req_info pointers that are passed around

author Alberto Bertogli
2008-08-23 18:53:54 UTC
committer Alberto Bertogli
2008-08-23 22:19:10 UTC
parent 1259c7bb5bb7a2b87a58ffcb0436baddba6ca612

"const"ify struct req_info pointers that are passed around

They are never modified, so mark them constant to be able to enforce this
fact and make the code more explicit.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

nmdb/parse.c +5 -5
nmdb/req.h +3 -3
nmdb/sctp.c +3 -3
nmdb/tcp.c +6 -6
nmdb/tipc.c +3 -3
nmdb/udp.c +3 -3

diff --git a/nmdb/parse.c b/nmdb/parse.c
index aa91f44..1df7e1d 100644
--- a/nmdb/parse.c
+++ b/nmdb/parse.c
@@ -12,7 +12,7 @@
 #include "netutils.h"
 
 
-static void parse_get(struct req_info *req);
+static void parse_get(const struct req_info *req);
 static void parse_set(struct req_info *req);
 static void parse_del(struct req_info *req);
 static void parse_cas(struct req_info *req);
@@ -23,7 +23,7 @@ static void parse_stats(struct req_info *req);
 /* Create a queue entry structure based on the parameters passed. Memory
  * allocated here will be free()'d in queue_entry_free(). It's not the
  * cleanest way, but the alternatives are even messier. */
-static struct queue_entry *make_queue_long_entry(struct req_info *req,
+static struct queue_entry *make_queue_long_entry(const struct req_info *req,
 		uint32_t operation, const unsigned char *key, size_t ksize,
 		const unsigned char *val, size_t vsize,
 		const unsigned char *newval, size_t nvsize)
@@ -105,7 +105,7 @@ static struct queue_entry *make_queue_long_entry(struct req_info *req,
 
 /* Creates a new queue entry and puts it into the queue. Returns 1 if success,
  * 0 if memory error. */
-static int put_in_queue_long(struct req_info *req,
+static int put_in_queue_long(const struct req_info *req,
 		uint32_t operation, int sync,
 		const unsigned char *key, size_t ksize,
 		const unsigned char *val, size_t vsize,
@@ -136,7 +136,7 @@ static int put_in_queue_long(struct req_info *req,
 
 /* Like put_in_queue_long() but with few parameters because most actions do
  * not need newval. */
-static int put_in_queue(struct req_info *req,
+static int put_in_queue(const struct req_info *req,
 		uint32_t operation, int sync,
 		const unsigned char *key, size_t ksize,
 		const unsigned char *val, size_t vsize)
@@ -232,7 +232,7 @@ int parse_message(struct req_info *req,
 	} while(0)
 
 
-static void parse_get(struct req_info *req)
+static void parse_get(const struct req_info *req)
 {
 	int hit, cache_only, rv;
 	const unsigned char *key;
diff --git a/nmdb/req.h b/nmdb/req.h
index 21ac384..557f44c 100644
--- a/nmdb/req.h
+++ b/nmdb/req.h
@@ -30,9 +30,9 @@ struct req_info {
 	size_t psize;
 
 	/* operations */
-	void (*reply_mini)(struct req_info *req, uint32_t reply);
-	void (*reply_err)(struct req_info *req, uint32_t reply);
-	void (*reply_long)(struct req_info *req, uint32_t reply,
+	void (*reply_mini)(const struct req_info *req, uint32_t reply);
+	void (*reply_err)(const struct req_info *req, uint32_t reply);
+	void (*reply_long)(const struct req_info *req, uint32_t reply,
 			unsigned char *val, size_t vsize);
 };
 
diff --git a/nmdb/sctp.c b/nmdb/sctp.c
index 5ae027f..a0e3adf 100644
--- a/nmdb/sctp.c
+++ b/nmdb/sctp.c
@@ -63,7 +63,7 @@ static int rep_send(const struct req_info *req, const unsigned char *buf,
 
 
 /* Send small replies, consisting in only a value. */
-static void sctp_reply_mini(struct req_info *req, uint32_t reply)
+static void sctp_reply_mini(const struct req_info *req, uint32_t reply)
 {
 	/* We use a mini buffer to speedup the small replies, to avoid the
 	 * malloc() overhead. */
@@ -83,12 +83,12 @@ static void sctp_reply_mini(struct req_info *req, uint32_t reply)
 /* The sctp_reply_* functions are used by the db code to send the network
  * replies. */
 
-static void sctp_reply_err(struct req_info *req, uint32_t reply)
+static void sctp_reply_err(const struct req_info *req, uint32_t reply)
 {
 	rep_send_error(req, reply);
 }
 
-static void sctp_reply_long(struct req_info *req, uint32_t reply,
+static void sctp_reply_long(const struct req_info *req, uint32_t reply,
 			unsigned char *val, size_t vsize)
 {
 	if (val == NULL) {
diff --git a/nmdb/tcp.c b/nmdb/tcp.c
index 5b1c1ed..b435756 100644
--- a/nmdb/tcp.c
+++ b/nmdb/tcp.c
@@ -44,9 +44,9 @@ static void tcp_recv(int fd, short event, void *arg);
 static void process_buf(struct tcp_socket *tcpsock,
 		unsigned char *buf, size_t len);
 
-static void tcp_reply_mini(struct req_info *req, uint32_t reply);
-static void tcp_reply_err(struct req_info *req, uint32_t reply);
-static void tcp_reply_long(struct req_info *req, uint32_t reply,
+static void tcp_reply_mini(const struct req_info *req, uint32_t reply);
+static void tcp_reply_err(const struct req_info *req, uint32_t reply);
+static void tcp_reply_long(const struct req_info *req, uint32_t reply,
 		unsigned char *val, size_t vsize);
 
 
@@ -144,7 +144,7 @@ static int rep_send(const struct req_info *req, const unsigned char *buf,
 
 
 /* Send small replies, consisting in only a value. */
-static void tcp_reply_mini(struct req_info *req, uint32_t reply)
+static void tcp_reply_mini(const struct req_info *req, uint32_t reply)
 {
 	/* We use a mini buffer to speedup the small replies, to avoid the
 	 * malloc() overhead. */
@@ -164,12 +164,12 @@ static void tcp_reply_mini(struct req_info *req, uint32_t reply)
 }
 
 
-static void tcp_reply_err(struct req_info *req, uint32_t reply)
+static void tcp_reply_err(const struct req_info *req, uint32_t reply)
 {
 	rep_send_error(req, reply);
 }
 
-static void tcp_reply_long(struct req_info *req, uint32_t reply,
+static void tcp_reply_long(const struct req_info *req, uint32_t reply,
 			unsigned char *val, size_t vsize)
 {
 	if (val == NULL) {
diff --git a/nmdb/tipc.c b/nmdb/tipc.c
index 281ed46..2a21351 100644
--- a/nmdb/tipc.c
+++ b/nmdb/tipc.c
@@ -62,7 +62,7 @@ static int rep_send(const struct req_info *req, const unsigned char *buf,
 
 
 /* Send small replies, consisting in only a value. */
-static void tipc_reply_mini(struct req_info *req, uint32_t reply)
+static void tipc_reply_mini(const struct req_info *req, uint32_t reply)
 {
 	/* We use a mini buffer to speedup the small replies, to avoid the
 	 * malloc() overhead. */
@@ -82,12 +82,12 @@ static void tipc_reply_mini(struct req_info *req, uint32_t reply)
 /* The tipc_reply_* functions are used by the db code to send the network
  * replies. */
 
-static void tipc_reply_err(struct req_info *req, uint32_t reply)
+static void tipc_reply_err(const struct req_info *req, uint32_t reply)
 {
 	rep_send_error(req, reply);
 }
 
-static void tipc_reply_long(struct req_info *req, uint32_t reply,
+static void tipc_reply_long(const struct req_info *req, uint32_t reply,
 			unsigned char *val, size_t vsize)
 {
 	if (val == NULL) {
diff --git a/nmdb/udp.c b/nmdb/udp.c
index c1040b2..62fcbcb 100644
--- a/nmdb/udp.c
+++ b/nmdb/udp.c
@@ -63,7 +63,7 @@ static int rep_send(const struct req_info *req, const unsigned char *buf,
 
 
 /* Send small replies, consisting in only a value. */
-static void udp_reply_mini(struct req_info *req, uint32_t reply)
+static void udp_reply_mini(const struct req_info *req, uint32_t reply)
 {
 	/* We use a mini buffer to speedup the small replies, to avoid the
 	 * malloc() overhead. */
@@ -83,12 +83,12 @@ static void udp_reply_mini(struct req_info *req, uint32_t reply)
 /* The udp_reply_* functions are used by the db code to send the network
  * replies. */
 
-static void udp_reply_err(struct req_info *req, uint32_t reply)
+static void udp_reply_err(const struct req_info *req, uint32_t reply)
 {
 	rep_send_error(req, reply);
 }
 
-static void udp_reply_long(struct req_info *req, uint32_t reply,
+static void udp_reply_long(const struct req_info *req, uint32_t reply,
 			unsigned char *val, size_t vsize)
 {
 	if (val == NULL) {