git » nmdb » commit 158e4a9

Tidy some (library internal) definitions

author Alberto Bertogli
2008-06-04 22:00:09 UTC
committer Alberto Bertogli
2008-06-04 22:04:42 UTC
parent e264b2e25d8fad903ca00ab6e496e80e0c5ec9cf

Tidy some (library internal) definitions

Sparse (correctly, as usual) complained about some inconsistencies in the
definitions, this patch fixes them.

It makes the code not only more correct, but also clearer and easier to
read.

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

libnmdb/libnmdb.c +2 -2
libnmdb/sctp.c +4 -4
libnmdb/sctp.h +1 -2
libnmdb/tcp.c +4 -4
libnmdb/tcp.h +1 -2
libnmdb/tipc.c +2 -0
libnmdb/udp.c +4 -4
libnmdb/udp.h +1 -2

diff --git a/libnmdb/libnmdb.c b/libnmdb/libnmdb.c
index b6aa331..4306e16 100644
--- a/libnmdb/libnmdb.c
+++ b/libnmdb/libnmdb.c
@@ -119,7 +119,7 @@ ssize_t ssend(int fd, const unsigned char *buf, size_t count, int flags)
 
 /* Create a nmdb_t and set the first server to port. If port is < 0, the
  * standard port is used. */
-nmdb_t *nmdb_init()
+nmdb_t *nmdb_init(void)
 {
 	nmdb_t *db;
 
@@ -150,7 +150,7 @@ int nmdb_free(nmdb_t *db)
 /* Used internally to send a buffer to the given server. Calls the appropriate
  * sender according to the server protocol. */
 static int srv_send(struct nmdb_srv *srv,
-		const unsigned char *buf, size_t bsize)
+		unsigned char *buf, size_t bsize)
 {
 	if (srv == NULL)
 		return 0;
diff --git a/libnmdb/sctp.c b/libnmdb/sctp.c
index 1f1c1ab..427c03b 100644
--- a/libnmdb/sctp.c
+++ b/libnmdb/sctp.c
@@ -15,6 +15,7 @@
 #include "nmdb.h"
 #include "net-const.h"
 #include "internal.h"
+#include "sctp.h"
 
 
 /* Used internally to really add the server once we have an IP address. */
@@ -85,8 +86,7 @@ int nmdb_add_sctp_server(nmdb_t *db, const char *addr, int port)
 	return add_sctp_server_addr(db, &(ia.s_addr), port);
 }
 
-int sctp_srv_send(struct nmdb_srv *srv,
-		const unsigned char *buf, size_t bsize)
+int sctp_srv_send(struct nmdb_srv *srv, unsigned char *buf, size_t bsize)
 {
 	ssize_t rv;
 	rv = sendto(srv->fd, buf, bsize, 0,
@@ -131,14 +131,14 @@ uint32_t sctp_get_rep(struct nmdb_srv *srv,
 
 #include <stdint.h>
 #include "nmdb.h"
+#include "sctp.h"
 
 int nmdb_add_sctp_server(nmdb_t *db, const char *addr, int port)
 {
 	return 0;
 }
 
-int sctp_srv_send(struct nmdb_srv *srv,
-		const unsigned char *buf, size_t bsize)
+int sctp_srv_send(struct nmdb_srv *srv, unsigned char *buf, size_t bsize)
 {
 	return 0;
 }
diff --git a/libnmdb/sctp.h b/libnmdb/sctp.h
index 56b0add..21eb074 100644
--- a/libnmdb/sctp.h
+++ b/libnmdb/sctp.h
@@ -2,8 +2,7 @@
 #ifndef _SCTP_H
 #define _SCTP_H
 
-int sctp_srv_send(struct nmdb_srv *srv,
-		const unsigned char *buf, size_t bsize);
+int sctp_srv_send(struct nmdb_srv *srv, unsigned char *buf, size_t bsize);
 uint32_t sctp_get_rep(struct nmdb_srv *srv,
 		unsigned char *buf, size_t bsize,
 		unsigned char **payload, size_t *psize);
diff --git a/libnmdb/tcp.c b/libnmdb/tcp.c
index 0bee671..22d5d83 100644
--- a/libnmdb/tcp.c
+++ b/libnmdb/tcp.c
@@ -15,6 +15,7 @@
 #include "nmdb.h"
 #include "net-const.h"
 #include "internal.h"
+#include "tcp.h"
 
 
 /* Used internally to really add the server once we have an IP address. */
@@ -102,8 +103,7 @@ int nmdb_add_tcp_server(nmdb_t *db, const char *addr, int port)
 	return add_tcp_server_addr(db, &(ia.s_addr), port);
 }
 
-int tcp_srv_send(struct nmdb_srv *srv,
-		unsigned char *buf, size_t bsize)
+int tcp_srv_send(struct nmdb_srv *srv, unsigned char *buf, size_t bsize)
 {
 	ssize_t rv;
 	uint32_t len;
@@ -187,14 +187,14 @@ uint32_t tcp_get_rep(struct nmdb_srv *srv,
 
 #include <stdint.h>
 #include "nmdb.h"
+#include "tcp.h"
 
 int nmdb_add_tcp_server(nmdb_t *db, const char *addr, int port)
 {
 	return 0;
 }
 
-int tcp_srv_send(struct nmdb_srv *srv,
-		const unsigned char *buf, size_t bsize)
+int tcp_srv_send(struct nmdb_srv *srv, unsigned char *buf, size_t bsize)
 {
 	return 0;
 }
diff --git a/libnmdb/tcp.h b/libnmdb/tcp.h
index 4252353..1459d42 100644
--- a/libnmdb/tcp.h
+++ b/libnmdb/tcp.h
@@ -2,8 +2,7 @@
 #ifndef _TCP_H
 #define _TCP_H
 
-int tcp_srv_send(struct nmdb_srv *srv,
-		const unsigned char *buf, size_t bsize);
+int tcp_srv_send(struct nmdb_srv *srv, unsigned char *buf, size_t bsize);
 uint32_t tcp_get_rep(struct nmdb_srv *srv,
 		unsigned char *buf, size_t bsize,
 		unsigned char **payload, size_t *psize);
diff --git a/libnmdb/tipc.c b/libnmdb/tipc.c
index 6482352..21b6eb2 100644
--- a/libnmdb/tipc.c
+++ b/libnmdb/tipc.c
@@ -14,6 +14,7 @@
 #include "nmdb.h"
 #include "net-const.h"
 #include "internal.h"
+#include "tipc.h"
 
 
 /* Add a TIPC server to the db connection. Requests will select which server
@@ -107,6 +108,7 @@ uint32_t tipc_get_rep(struct nmdb_srv *srv,
 
 #include <stdint.h>
 #include "nmdb.h"
+#include "tipc.h"
 
 int nmdb_add_tipc_server(nmdb_t *db, int port)
 {
diff --git a/libnmdb/udp.c b/libnmdb/udp.c
index 55902d2..7e690fe 100644
--- a/libnmdb/udp.c
+++ b/libnmdb/udp.c
@@ -15,6 +15,7 @@
 #include "nmdb.h"
 #include "net-const.h"
 #include "internal.h"
+#include "udp.h"
 
 
 /* Used internally to really add the server once we have an IP address. */
@@ -77,8 +78,7 @@ int nmdb_add_udp_server(nmdb_t *db, const char *addr, int port)
 	return add_udp_server_addr(db, &(ia.s_addr), port);
 }
 
-int udp_srv_send(struct nmdb_srv *srv,
-		const unsigned char *buf, size_t bsize)
+int udp_srv_send(struct nmdb_srv *srv, unsigned char *buf, size_t bsize)
 {
 	ssize_t rv;
 	rv = sendto(srv->fd, buf, bsize, 0,
@@ -123,14 +123,14 @@ uint32_t udp_get_rep(struct nmdb_srv *srv,
 
 #include <stdint.h>
 #include "nmdb.h"
+#include "udp.h"
 
 int nmdb_add_udp_server(nmdb_t *db, const char *addr, int port)
 {
 	return 0;
 }
 
-int udp_srv_send(struct nmdb_srv *srv,
-		const unsigned char *buf, size_t bsize)
+int udp_srv_send(struct nmdb_srv *srv, unsigned char *buf, size_t bsize)
 {
 	return 0;
 }
diff --git a/libnmdb/udp.h b/libnmdb/udp.h
index 7515941..c989a83 100644
--- a/libnmdb/udp.h
+++ b/libnmdb/udp.h
@@ -2,8 +2,7 @@
 #ifndef _UDP_H
 #define _UDP_H
 
-int udp_srv_send(struct nmdb_srv *srv,
-		const unsigned char *buf, size_t bsize);
+int udp_srv_send(struct nmdb_srv *srv, unsigned char *buf, size_t bsize);
 uint32_t udp_get_rep(struct nmdb_srv *srv,
 		unsigned char *buf, size_t bsize,
 		unsigned char **payload, size_t *psize);