* libnetfilter_cttimeout: misc cleanup
@ 2012-02-29 7:15 Jan Engelhardt
2012-02-29 7:15 ` [PATCH 1/6] Add .gitignore Jan Engelhardt
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Jan Engelhardt @ 2012-02-29 7:15 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel
Note that src/*.c reads "GPL-2.0+" while the COPYING file shows
an LGPL-2.1 text. Clarification would be welcome.
===
The following changes since commit eb9385b594bbd463fdc0704c33ca88e4d2e4cbb1:
add README file (2012-02-29 03:33:44 +0100)
are available in the git repository at:
git://dev.medozas.de/libnetfilter_cttimeout master
Jan Engelhardt (6):
Add .gitignore
const-ify static data objects
Add stdint header and type corrections
Properly NUL-terminate name in nfct_timeout_attr_set
const-ify arguments of functions
Add extern "C" guard for C++ compilation mode
.gitignore | 18 +++++++++++
.../libnetfilter_cttimeout.h | 13 ++++++-
src/libnetfilter_cttimeout.c | 33 +++++++++++---------
3 files changed, 47 insertions(+), 17 deletions(-)
create mode 100644 .gitignore
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/6] Add .gitignore
2012-02-29 7:15 libnetfilter_cttimeout: misc cleanup Jan Engelhardt
@ 2012-02-29 7:15 ` Jan Engelhardt
2012-02-29 7:15 ` [PATCH 2/6] const-ify static data objects Jan Engelhardt
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Jan Engelhardt @ 2012-02-29 7:15 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
---
.gitignore | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
create mode 100644 .gitignore
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e6b85bf
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,18 @@
+.deps/
+.libs/
+*.la
+*.lo
+Makefile
+Makefile.in
+
+/aclocal.m4
+/autom4te.cache/
+/build-aux/
+/config.*
+/configure
+/libtool
+/stamp-h1
+
+
+/doxygen.cfg
+/*.pc
--
1.7.7
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/6] const-ify static data objects
2012-02-29 7:15 libnetfilter_cttimeout: misc cleanup Jan Engelhardt
2012-02-29 7:15 ` [PATCH 1/6] Add .gitignore Jan Engelhardt
@ 2012-02-29 7:15 ` Jan Engelhardt
2012-02-29 7:15 ` [PATCH 3/6] Add stdint header and type corrections Jan Engelhardt
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Jan Engelhardt @ 2012-02-29 7:15 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
---
src/libnetfilter_cttimeout.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/libnetfilter_cttimeout.c b/src/libnetfilter_cttimeout.c
index 2f1ba79..6050514 100644
--- a/src/libnetfilter_cttimeout.c
+++ b/src/libnetfilter_cttimeout.c
@@ -21,7 +21,7 @@
#include <libnetfilter_cttimeout/libnetfilter_cttimeout.h>
-static char *tcp_state_to_name[] = {
+static const char *const tcp_state_to_name[] = {
[NFCT_TIMEOUT_ATTR_TCP_SYN_SENT] = "SYN_SENT",
[NFCT_TIMEOUT_ATTR_TCP_SYN_RECV] = "SYN_RECV",
[NFCT_TIMEOUT_ATTR_TCP_ESTABLISHED] = "ESTABLISHED",
@@ -35,16 +35,16 @@ static char *tcp_state_to_name[] = {
[NFCT_TIMEOUT_ATTR_TCP_UNACK] = "UNACKNOWLEDGED",
};
-static char *generic_state_to_name[] = {
+static const char *const generic_state_to_name[] = {
[NFCT_TIMEOUT_ATTR_GENERIC] = "TIMEOUT",
};
-static char *udp_state_to_name[] = {
+static const char *const udp_state_to_name[] = {
[NFCT_TIMEOUT_ATTR_UDP_UNREPLIED] = "UNREPLIED",
[NFCT_TIMEOUT_ATTR_UDP_REPLIED] = "REPLIED",
};
-static char *sctp_state_to_name[] = {
+static const char *const sctp_state_to_name[] = {
[NFCT_TIMEOUT_ATTR_SCTP_CLOSED] = "CLOSED",
[NFCT_TIMEOUT_ATTR_SCTP_COOKIE_WAIT] = "COOKIE_WAIT",
[NFCT_TIMEOUT_ATTR_SCTP_COOKIE_ECHOED] = "COOKIE_ECHOED",
@@ -54,7 +54,7 @@ static char *sctp_state_to_name[] = {
[NFCT_TIMEOUT_ATTR_SCTP_SHUTDOWN_ACK_SENT] = "SHUTDOWN_ACK_SENT",
};
-static char *dccp_state_to_name[] = {
+static const char *const dccp_state_to_name[] = {
[NFCT_TIMEOUT_ATTR_DCCP_REQUEST] = "REQUEST",
[NFCT_TIMEOUT_ATTR_DCCP_RESPOND] = "RESPOND",
[NFCT_TIMEOUT_ATTR_DCCP_PARTOPEN] = "PARTOPEN",
@@ -64,14 +64,14 @@ static char *dccp_state_to_name[] = {
[NFCT_TIMEOUT_ATTR_DCCP_TIMEWAIT] = "TIMEWAIT",
};
-static char *icmp_state_to_name[] = {
+static const char *const icmp_state_to_name[] = {
[NFCT_TIMEOUT_ATTR_ICMP] = "TIMEOUT",
};
static struct {
uint32_t nlattr_max;
uint32_t attr_max;
- char **state_to_name;
+ const char *const *state_to_name;
} timeout_protocol[IPPROTO_MAX] = {
[IPPROTO_ICMP] = {
.nlattr_max = __CTA_TIMEOUT_ICMP_MAX,
--
1.7.7
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/6] Add stdint header and type corrections
2012-02-29 7:15 libnetfilter_cttimeout: misc cleanup Jan Engelhardt
2012-02-29 7:15 ` [PATCH 1/6] Add .gitignore Jan Engelhardt
2012-02-29 7:15 ` [PATCH 2/6] const-ify static data objects Jan Engelhardt
@ 2012-02-29 7:15 ` Jan Engelhardt
2012-02-29 7:15 ` [PATCH 4/6] Properly NUL-terminate name in nfct_timeout_attr_set Jan Engelhardt
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Jan Engelhardt @ 2012-02-29 7:15 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel
1. stdint.h is needed since you use uintXX_t in various places.
2. mnl_attr_get_type yields uint16_t, prefer to use it.
3. Since ->nlattr_max is uint32_t, most dependent uses should be
unsigned too.
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
---
.../libnetfilter_cttimeout.h | 1 +
src/libnetfilter_cttimeout.c | 11 ++++++-----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/include/libnetfilter_cttimeout/libnetfilter_cttimeout.h b/include/libnetfilter_cttimeout/libnetfilter_cttimeout.h
index be37636..89e00b6 100644
--- a/include/libnetfilter_cttimeout/libnetfilter_cttimeout.h
+++ b/include/libnetfilter_cttimeout/libnetfilter_cttimeout.h
@@ -1,6 +1,7 @@
#ifndef _LIBNETFILTER_CTTIMEOUT_H_
#define _LIBNETFILTER_CTTIMEOUT_H_
+#include <stdint.h>
#include <sys/types.h>
#include <linux/netfilter/nfnetlink_conntrack.h>
diff --git a/src/libnetfilter_cttimeout.c b/src/libnetfilter_cttimeout.c
index 6050514..707543a 100644
--- a/src/libnetfilter_cttimeout.c
+++ b/src/libnetfilter_cttimeout.c
@@ -11,6 +11,7 @@
#include <time.h>
#include <endian.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <netinet/in.h>
@@ -432,7 +433,7 @@ static int
timeout_nlmsg_parse_attr_cb(const struct nlattr *attr, void *data)
{
const struct nlattr **tb = data;
- int type = mnl_attr_get_type(attr);
+ uint16_t type = mnl_attr_get_type(attr);
if (mnl_attr_type_valid(attr, CTA_TIMEOUT_MAX) < 0)
return MNL_CB_OK;
@@ -468,7 +469,7 @@ timeout_nlmsg_parse_attr_cb(const struct nlattr *attr, void *data)
}
struct _container_policy_cb {
- int nlattr_max;
+ unsigned int nlattr_max;
void *tb;
};
@@ -477,7 +478,7 @@ parse_timeout_attr_policy_cb(const struct nlattr *attr, void *data)
{
struct _container_policy_cb *data_cb = data;
const struct nlattr **tb = data_cb->tb;
- int type = mnl_attr_get_type(attr);
+ uint16_t type = mnl_attr_get_type(attr);
if (mnl_attr_type_valid(attr, data_cb->nlattr_max) < 0)
return MNL_CB_OK;
@@ -495,13 +496,13 @@ parse_timeout_attr_policy_cb(const struct nlattr *attr, void *data)
static void
timeout_parse_attr_data(struct nfct_timeout *t, const struct nlattr *nest)
{
- int nlattr_max = timeout_protocol[t->l4num].nlattr_max;
+ unsigned int nlattr_max = timeout_protocol[t->l4num].nlattr_max;
struct nlattr *tb[nlattr_max];
struct _container_policy_cb cnt = {
.nlattr_max = nlattr_max,
.tb = tb,
};
- int i;
+ unsigned int i;
memset(tb, 0, sizeof(struct nlattr *) * nlattr_max);
--
1.7.7
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/6] Properly NUL-terminate name in nfct_timeout_attr_set
2012-02-29 7:15 libnetfilter_cttimeout: misc cleanup Jan Engelhardt
` (2 preceding siblings ...)
2012-02-29 7:15 ` [PATCH 3/6] Add stdint header and type corrections Jan Engelhardt
@ 2012-02-29 7:15 ` Jan Engelhardt
2012-02-29 7:15 ` [PATCH 5/6] const-ify arguments of functions Jan Engelhardt
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Jan Engelhardt @ 2012-02-29 7:15 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
---
src/libnetfilter_cttimeout.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/libnetfilter_cttimeout.c b/src/libnetfilter_cttimeout.c
index 707543a..1f7c63e 100644
--- a/src/libnetfilter_cttimeout.c
+++ b/src/libnetfilter_cttimeout.c
@@ -177,7 +177,8 @@ nfct_timeout_attr_set(struct nfct_timeout *t, uint32_t type, const void *data)
{
switch(type) {
case NFCT_TIMEOUT_ATTR_NAME:
- strncpy(t->name, data, 32);
+ strncpy(t->name, data, sizeof(t->name));
+ t->name[sizeof(t->name)-1] = '\0';
break;
case NFCT_TIMEOUT_ATTR_L3PROTO:
t->l3num = *((uint16_t *) data);
--
1.7.7
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/6] const-ify arguments of functions
2012-02-29 7:15 libnetfilter_cttimeout: misc cleanup Jan Engelhardt
` (3 preceding siblings ...)
2012-02-29 7:15 ` [PATCH 4/6] Properly NUL-terminate name in nfct_timeout_attr_set Jan Engelhardt
@ 2012-02-29 7:15 ` Jan Engelhardt
2012-02-29 7:15 ` [PATCH 6/6] Add extern "C" guard for C++ compilation mode Jan Engelhardt
2012-02-29 9:40 ` libnetfilter_cttimeout: misc cleanup Pablo Neira Ayuso
6 siblings, 0 replies; 8+ messages in thread
From: Jan Engelhardt @ 2012-02-29 7:15 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
---
.../libnetfilter_cttimeout.h | 4 ++--
src/libnetfilter_cttimeout.c | 5 +++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/include/libnetfilter_cttimeout/libnetfilter_cttimeout.h b/include/libnetfilter_cttimeout/libnetfilter_cttimeout.h
index 89e00b6..172e7f9 100644
--- a/include/libnetfilter_cttimeout/libnetfilter_cttimeout.h
+++ b/include/libnetfilter_cttimeout/libnetfilter_cttimeout.h
@@ -99,9 +99,9 @@ void nfct_timeout_policy_attr_unset(struct nfct_timeout *t, uint32_t type);
struct nlmsghdr;
struct nlmsghdr *nfct_timeout_nlmsg_build_hdr(char *buf, uint8_t cmd, uint16_t flags, uint32_t seq);
-void nfct_timeout_nlmsg_build_payload(struct nlmsghdr *, struct nfct_timeout *);
+void nfct_timeout_nlmsg_build_payload(struct nlmsghdr *, const struct nfct_timeout *);
int nfct_timeout_nlmsg_parse_payload(const struct nlmsghdr *nlh, struct nfct_timeout *);
-int nfct_timeout_snprintf(char *buf, size_t size, struct nfct_timeout *, unsigned int flags);
+int nfct_timeout_snprintf(char *buf, size_t size, const struct nfct_timeout *, unsigned int flags);
#endif
diff --git a/src/libnetfilter_cttimeout.c b/src/libnetfilter_cttimeout.c
index 1f7c63e..c7060ff 100644
--- a/src/libnetfilter_cttimeout.c
+++ b/src/libnetfilter_cttimeout.c
@@ -292,7 +292,7 @@ EXPORT_SYMBOL(nfct_timeout_policy_attr_unset);
* This function returns -1 in case that some mandatory attributes are
* missing. On sucess, it returns 0.
*/
-int nfct_timeout_snprintf(char *buf, size_t size, struct nfct_timeout *t,
+int nfct_timeout_snprintf(char *buf, size_t size, const struct nfct_timeout *t,
unsigned int flags)
{
int ret = 0;
@@ -401,7 +401,8 @@ EXPORT_SYMBOL(nfct_timeout_nlmsg_build_hdr);
* \param t: pointer to a conntrack timeout object
*/
void
-nfct_timeout_nlmsg_build_payload(struct nlmsghdr *nlh, struct nfct_timeout *t)
+nfct_timeout_nlmsg_build_payload(struct nlmsghdr *nlh,
+ const struct nfct_timeout *t)
{
int i;
struct nlattr *nest;
--
1.7.7
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 6/6] Add extern "C" guard for C++ compilation mode
2012-02-29 7:15 libnetfilter_cttimeout: misc cleanup Jan Engelhardt
` (4 preceding siblings ...)
2012-02-29 7:15 ` [PATCH 5/6] const-ify arguments of functions Jan Engelhardt
@ 2012-02-29 7:15 ` Jan Engelhardt
2012-02-29 9:40 ` libnetfilter_cttimeout: misc cleanup Pablo Neira Ayuso
6 siblings, 0 replies; 8+ messages in thread
From: Jan Engelhardt @ 2012-02-29 7:15 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
---
.../libnetfilter_cttimeout.h | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/include/libnetfilter_cttimeout/libnetfilter_cttimeout.h b/include/libnetfilter_cttimeout/libnetfilter_cttimeout.h
index 172e7f9..5a548fa 100644
--- a/include/libnetfilter_cttimeout/libnetfilter_cttimeout.h
+++ b/include/libnetfilter_cttimeout/libnetfilter_cttimeout.h
@@ -5,6 +5,10 @@
#include <sys/types.h>
#include <linux/netfilter/nfnetlink_conntrack.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct nfct_timeout;
struct nfct_timeout *nfct_timeout_alloc(void);
@@ -104,4 +108,8 @@ int nfct_timeout_nlmsg_parse_payload(const struct nlmsghdr *nlh, struct nfct_tim
int nfct_timeout_snprintf(char *buf, size_t size, const struct nfct_timeout *, unsigned int flags);
+#ifdef __cplusplus
+} /* extern "C" */
#endif
+
+#endif /* _LIBNETFILTER_CTTIMEOUT_H_ */
--
1.7.7
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: libnetfilter_cttimeout: misc cleanup
2012-02-29 7:15 libnetfilter_cttimeout: misc cleanup Jan Engelhardt
` (5 preceding siblings ...)
2012-02-29 7:15 ` [PATCH 6/6] Add extern "C" guard for C++ compilation mode Jan Engelhardt
@ 2012-02-29 9:40 ` Pablo Neira Ayuso
6 siblings, 0 replies; 8+ messages in thread
From: Pablo Neira Ayuso @ 2012-02-29 9:40 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: netfilter-devel
On Wed, Feb 29, 2012 at 08:15:36AM +0100, Jan Engelhardt wrote:
>
>
> Note that src/*.c reads "GPL-2.0+" while the COPYING file shows
> an LGPL-2.1 text. Clarification would be welcome.
This is GPLv2+ stuff. I just pushed a patch to fix this, thanks for
spotting this.
> ===
> The following changes since commit eb9385b594bbd463fdc0704c33ca88e4d2e4cbb1:
>
> add README file (2012-02-29 03:33:44 +0100)
>
> are available in the git repository at:
> git://dev.medozas.de/libnetfilter_cttimeout master
>
> Jan Engelhardt (6):
> Add .gitignore
> const-ify static data objects
> Add stdint header and type corrections
> Properly NUL-terminate name in nfct_timeout_attr_set
> const-ify arguments of functions
> Add extern "C" guard for C++ compilation mode
And this bunch applied, thanks Jan!
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-02-29 9:40 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-29 7:15 libnetfilter_cttimeout: misc cleanup Jan Engelhardt
2012-02-29 7:15 ` [PATCH 1/6] Add .gitignore Jan Engelhardt
2012-02-29 7:15 ` [PATCH 2/6] const-ify static data objects Jan Engelhardt
2012-02-29 7:15 ` [PATCH 3/6] Add stdint header and type corrections Jan Engelhardt
2012-02-29 7:15 ` [PATCH 4/6] Properly NUL-terminate name in nfct_timeout_attr_set Jan Engelhardt
2012-02-29 7:15 ` [PATCH 5/6] const-ify arguments of functions Jan Engelhardt
2012-02-29 7:15 ` [PATCH 6/6] Add extern "C" guard for C++ compilation mode Jan Engelhardt
2012-02-29 9:40 ` libnetfilter_cttimeout: misc cleanup Pablo Neira Ayuso
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.