diff options
author | David Fabro <netfilter@meta-dynamic.com> | 2010-06-10 14:54:41 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2010-06-10 14:54:41 +0200 |
commit | 6e204c91b6c7ece751331de2fa3fb460bc5edd59 (patch) | |
tree | 5a44f4c4ef7110ec67528aaee469349a8831c6e9 /src | |
parent | 6b4e0a01259a80d91d0eaea01281372b594f05b1 (diff) |
non-modified payload arguments are pointer-to-const
The payload parameters to nfq_set_verdict(), nfq_set_verdict2(), and
nfq_set_verdict_mark() are not modified by those functions, and
therefore should have datatype pointer-to-const. This both causes the
source-code to more effectively represent what is the purpose of the
parameter, and eliminates the need to cast away const-ness when calling
the functions with compilers that enforce strict casting. All existing
calling code should not need modification as pointer-to-X automatically
converts to pointer-to-const-X.
Signed-off-by: David Favro <netfilter@meta-dynamic.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/libnetfilter_queue.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/libnetfilter_queue.c b/src/libnetfilter_queue.c index cc19e6a..4cc4925 100644 --- a/src/libnetfilter_queue.c +++ b/src/libnetfilter_queue.c @@ -610,7 +610,7 @@ int nfq_set_queue_maxlen(struct nfq_q_handle *qh, static int __set_verdict(struct nfq_q_handle *qh, u_int32_t id, u_int32_t verdict, u_int32_t mark, int set_mark, - u_int32_t data_len, unsigned char *data) + u_int32_t data_len, const unsigned char *data) { struct nfqnl_msg_verdict_hdr vh; union { @@ -646,8 +646,9 @@ static int __set_verdict(struct nfq_q_handle *qh, u_int32_t id, nvecs = 1; if (data_len) { + /* The typecast here is to cast away data's const-ness: */ nfnl_build_nfa_iovec(&iov[1], &data_attr, NFQA_PAYLOAD, - data_len, data); + data_len, (unsigned char *) data); nvecs += 2; /* Add the length of the appended data to the message * header. The size of the attribute is given in the @@ -688,7 +689,7 @@ static int __set_verdict(struct nfq_q_handle *qh, u_int32_t id, */ int nfq_set_verdict(struct nfq_q_handle *qh, u_int32_t id, u_int32_t verdict, u_int32_t data_len, - unsigned char *buf) + const unsigned char *buf) { return __set_verdict(qh, id, verdict, 0, 0, data_len, buf); } @@ -704,7 +705,7 @@ int nfq_set_verdict(struct nfq_q_handle *qh, u_int32_t id, */ int nfq_set_verdict2(struct nfq_q_handle *qh, u_int32_t id, u_int32_t verdict, u_int32_t mark, - u_int32_t data_len, unsigned char *buf) + u_int32_t data_len, const unsigned char *buf) { return __set_verdict(qh, id, verdict, htonl(mark), 1, data_len, buf); } @@ -725,7 +726,7 @@ int nfq_set_verdict2(struct nfq_q_handle *qh, u_int32_t id, */ int nfq_set_verdict_mark(struct nfq_q_handle *qh, u_int32_t id, u_int32_t verdict, u_int32_t mark, - u_int32_t data_len, unsigned char *buf) + u_int32_t data_len, const unsigned char *buf) { return __set_verdict(qh, id, verdict, mark, 1, data_len, buf); } |