From b938cdcc9bff515f661579c36db9552821e4562f Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Mon, 30 Aug 2010 22:26:42 +0000 Subject: [PATCH] Constify arguments we can constify. MFC after: 2 weeks Obtained from: Wheel Systems Sp. z o.o. http://www.wheelsystems.com --- sbin/hastd/hast_proto.c | 30 ++++++++++++++++-------------- sbin/hastd/hast_proto.h | 10 +++++----- sbin/hastd/proto.c | 4 ++-- sbin/hastd/proto.h | 4 ++-- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/sbin/hastd/hast_proto.c b/sbin/hastd/hast_proto.c index 4e898ca12e09..101a508cc86c 100644 --- a/sbin/hastd/hast_proto.c +++ b/sbin/hastd/hast_proto.c @@ -56,8 +56,10 @@ struct hast_main_header { uint32_t size; } __packed; -typedef int hps_send_t(struct hast_resource *, struct nv *nv, void **, size_t *, bool *); -typedef int hps_recv_t(struct hast_resource *, struct nv *nv, void **, size_t *, bool *); +typedef int hps_send_t(const struct hast_resource *, struct nv *nv, void **, + size_t *, bool *); +typedef int hps_recv_t(const struct hast_resource *, struct nv *nv, void **, + size_t *, bool *); struct hast_pipe_stage { const char *hps_name; @@ -65,14 +67,14 @@ struct hast_pipe_stage { hps_recv_t *hps_recv; }; -static int compression_send(struct hast_resource *res, struct nv *nv, +static int compression_send(const struct hast_resource *res, struct nv *nv, void **datap, size_t *sizep, bool *freedatap); -static int compression_recv(struct hast_resource *res, struct nv *nv, +static int compression_recv(const struct hast_resource *res, struct nv *nv, void **datap, size_t *sizep, bool *freedatap); #ifdef HAVE_CRYPTO -static int checksum_send(struct hast_resource *res, struct nv *nv, +static int checksum_send(const struct hast_resource *res, struct nv *nv, void **datap, size_t *sizep, bool *freedatap); -static int checksum_recv(struct hast_resource *res, struct nv *nv, +static int checksum_recv(const struct hast_resource *res, struct nv *nv, void **datap, size_t *sizep, bool *freedatap); #endif @@ -84,7 +86,7 @@ static struct hast_pipe_stage pipeline[] = { }; static int -compression_send(struct hast_resource *res, struct nv *nv, void **datap, +compression_send(const struct hast_resource *res, struct nv *nv, void **datap, size_t *sizep, bool *freedatap) { unsigned char *newbuf; @@ -132,7 +134,7 @@ compression_send(struct hast_resource *res, struct nv *nv, void **datap, } static int -compression_recv(struct hast_resource *res, struct nv *nv, void **datap, +compression_recv(const struct hast_resource *res, struct nv *nv, void **datap, size_t *sizep, bool *freedatap) { unsigned char *newbuf; @@ -169,7 +171,7 @@ compression_recv(struct hast_resource *res, struct nv *nv, void **datap, #ifdef HAVE_CRYPTO static int -checksum_send(struct hast_resource *res, struct nv *nv, void **datap, +checksum_send(const struct hast_resource *res, struct nv *nv, void **datap, size_t *sizep, bool *freedatap __unused) { unsigned char hash[SHA256_DIGEST_LENGTH]; @@ -188,7 +190,7 @@ checksum_send(struct hast_resource *res, struct nv *nv, void **datap, } static int -checksum_recv(struct hast_resource *res, struct nv *nv, void **datap, +checksum_recv(const struct hast_resource *res, struct nv *nv, void **datap, size_t *sizep, bool *freedatap __unused) { unsigned char chash[SHA256_DIGEST_LENGTH]; @@ -236,7 +238,7 @@ checksum_recv(struct hast_resource *res, struct nv *nv, void **datap, * There can be no data at all (data is NULL then). */ int -hast_proto_send(struct hast_resource *res, struct proto_conn *conn, +hast_proto_send(const struct hast_resource *res, struct proto_conn *conn, struct nv *nv, const void *data, size_t size) { struct hast_main_header hdr; @@ -293,7 +295,7 @@ if (false) { } int -hast_proto_recv_hdr(struct proto_conn *conn, struct nv **nvp) +hast_proto_recv_hdr(const struct proto_conn *conn, struct nv **nvp) { struct hast_main_header hdr; struct nv *nv; @@ -335,7 +337,7 @@ hast_proto_recv_hdr(struct proto_conn *conn, struct nv **nvp) } int -hast_proto_recv_data(struct hast_resource *res, struct proto_conn *conn, +hast_proto_recv_data(const struct hast_resource *res, struct proto_conn *conn, struct nv *nv, void *data, size_t size) { unsigned int ii; @@ -384,7 +386,7 @@ if (ret < 0) printf("%s:%u %s\n", __func__, __LINE__, strerror(errno)); } int -hast_proto_recv(struct hast_resource *res, struct proto_conn *conn, +hast_proto_recv(const struct hast_resource *res, struct proto_conn *conn, struct nv **nvp, void *data, size_t size) { struct nv *nv; diff --git a/sbin/hastd/hast_proto.h b/sbin/hastd/hast_proto.h index 3894e3838089..b48c3ca12146 100644 --- a/sbin/hastd/hast_proto.h +++ b/sbin/hastd/hast_proto.h @@ -37,12 +37,12 @@ #include #include -int hast_proto_send(struct hast_resource *res, struct proto_conn *conn, +int hast_proto_send(const struct hast_resource *res, struct proto_conn *conn, struct nv *nv, const void *data, size_t size); -int hast_proto_recv(struct hast_resource *res, struct proto_conn *conn, +int hast_proto_recv(const struct hast_resource *res, struct proto_conn *conn, struct nv **nvp, void *data, size_t size); -int hast_proto_recv_hdr(struct proto_conn *conn, struct nv **nvp); -int hast_proto_recv_data(struct hast_resource *res, struct proto_conn *conn, - struct nv *nv, void *data, size_t size); +int hast_proto_recv_hdr(const struct proto_conn *conn, struct nv **nvp); +int hast_proto_recv_data(const struct hast_resource *res, + struct proto_conn *conn, struct nv *nv, void *data, size_t size); #endif /* !_HAST_PROTO_H_ */ diff --git a/sbin/hastd/proto.c b/sbin/hastd/proto.c index 8f003de6fdde..db2a2ef4338f 100644 --- a/sbin/hastd/proto.c +++ b/sbin/hastd/proto.c @@ -179,7 +179,7 @@ proto_accept(struct proto_conn *conn, struct proto_conn **newconnp) } int -proto_send(struct proto_conn *conn, const void *data, size_t size) +proto_send(const struct proto_conn *conn, const void *data, size_t size) { int ret; @@ -196,7 +196,7 @@ proto_send(struct proto_conn *conn, const void *data, size_t size) } int -proto_recv(struct proto_conn *conn, void *data, size_t size) +proto_recv(const struct proto_conn *conn, void *data, size_t size) { int ret; diff --git a/sbin/hastd/proto.h b/sbin/hastd/proto.h index 13248bad649f..8d1046caed52 100644 --- a/sbin/hastd/proto.h +++ b/sbin/hastd/proto.h @@ -41,8 +41,8 @@ int proto_client(const char *addr, struct proto_conn **connp); int proto_connect(struct proto_conn *conn); int proto_server(const char *addr, struct proto_conn **connp); int proto_accept(struct proto_conn *conn, struct proto_conn **newconnp); -int proto_send(struct proto_conn *conn, const void *data, size_t size); -int proto_recv(struct proto_conn *conn, void *data, size_t size); +int proto_send(const struct proto_conn *conn, const void *data, size_t size); +int proto_recv(const struct proto_conn *conn, void *data, size_t size); int proto_descriptor(const struct proto_conn *conn); bool proto_address_match(const struct proto_conn *conn, const char *addr); void proto_local_address(const struct proto_conn *conn, char *addr,