summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2012-09-11 17:38:17 +0200
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2012-09-11 17:38:17 +0200
commit3578220cf27c3e7017dd8af6b17c08218cf632d0 (patch)
tree3dd0a57f443ba93ee4000c40917f2dfbf5646a6e /lib
parentd95c2f1eb788c4ccb1ce6f4add61943dbb334f07 (diff)
downloadipset-3578220cf27c3e7017dd8af6b17c08218cf632d0.tar.gz
Coding style fixes
Diffstat (limited to 'lib')
-rw-r--r--lib/data.c21
-rw-r--r--lib/debug.c6
-rw-r--r--lib/libipset.map2
-rw-r--r--lib/parse.c13
-rw-r--r--lib/print.c4
-rw-r--r--lib/session.c7
-rw-r--r--lib/types.c22
7 files changed, 43 insertions, 32 deletions
diff --git a/lib/data.c b/lib/data.c
index d6d29c2..1973307 100644
--- a/lib/data.c
+++ b/lib/data.c
@@ -228,12 +228,14 @@ ipset_data_set(struct ipset_data *data, enum ipset_opt opt, const void *value)
break;
/* CADT options */
case IPSET_OPT_IP:
- if (!(data->family == NFPROTO_IPV4 || data->family == NFPROTO_IPV6))
+ if (!(data->family == NFPROTO_IPV4 ||
+ data->family == NFPROTO_IPV6))
return -1;
copy_addr(data->family, &data->ip, value);
break;
case IPSET_OPT_IP_TO:
- if (!(data->family == NFPROTO_IPV4 || data->family == NFPROTO_IPV6))
+ if (!(data->family == NFPROTO_IPV4 ||
+ data->family == NFPROTO_IPV6))
return -1;
copy_addr(data->family, &data->ip_to, value);
break;
@@ -303,12 +305,14 @@ ipset_data_set(struct ipset_data *data, enum ipset_opt opt, const void *value)
ipset_strlcpy(data->adt.nameref, value, IPSET_MAXNAMELEN);
break;
case IPSET_OPT_IP2:
- if (!(data->family == NFPROTO_IPV4 || data->family == NFPROTO_IPV6))
+ if (!(data->family == NFPROTO_IPV4 ||
+ data->family == NFPROTO_IPV6))
return -1;
copy_addr(data->family, &data->adt.ip2, value);
break;
case IPSET_OPT_IP2_TO:
- if (!(data->family == NFPROTO_IPV4 || data->family == NFPROTO_IPV6))
+ if (!(data->family == NFPROTO_IPV4 ||
+ data->family == NFPROTO_IPV6))
return -1;
copy_addr(data->family, &data->adt.ip2_to, value);
break;
@@ -344,11 +348,14 @@ ipset_data_set(struct ipset_data *data, enum ipset_opt opt, const void *value)
case IPSET_OPT_CADT_FLAGS:
data->cadt_flags = *(const uint32_t *)value;
if (data->cadt_flags & IPSET_FLAG_BEFORE)
- ipset_data_flags_set(data, IPSET_FLAG(IPSET_OPT_BEFORE));
+ ipset_data_flags_set(data,
+ IPSET_FLAG(IPSET_OPT_BEFORE));
if (data->cadt_flags & IPSET_FLAG_PHYSDEV)
- ipset_data_flags_set(data, IPSET_FLAG(IPSET_OPT_PHYSDEV));
+ ipset_data_flags_set(data,
+ IPSET_FLAG(IPSET_OPT_PHYSDEV));
if (data->cadt_flags & IPSET_FLAG_NOMATCH)
- ipset_data_flags_set(data, IPSET_FLAG(IPSET_OPT_NOMATCH));
+ ipset_data_flags_set(data,
+ IPSET_FLAG(IPSET_OPT_NOMATCH));
break;
default:
return -1;
diff --git a/lib/debug.c b/lib/debug.c
index 486d910..1350053 100644
--- a/lib/debug.c
+++ b/lib/debug.c
@@ -116,14 +116,16 @@ debug_cadt_attrs(int max, const struct ipset_attr_policy *policy,
d = mnl_attr_get_payload(
ipattr[IPSET_ATTR_IPADDR_IPV4]);
- inet_ntop(NFPROTO_IPV4, d, addr, INET6_ADDRSTRLEN);
+ inet_ntop(NFPROTO_IPV4, d, addr,
+ INET6_ADDRSTRLEN);
fprintf(stderr, "\t\t%s: %s\n",
attr2name[i].name, addr);
} else if (ipattr[IPSET_ATTR_IPADDR_IPV6]) {
d = mnl_attr_get_payload(
ipattr[IPSET_ATTR_IPADDR_IPV6]);
- inet_ntop(NFPROTO_IPV6, d, addr, INET6_ADDRSTRLEN);
+ inet_ntop(NFPROTO_IPV6, d, addr,
+ INET6_ADDRSTRLEN);
fprintf(stderr, "\t\t%s: %s\n",
attr2name[i].name, addr);
}
diff --git a/lib/libipset.map b/lib/libipset.map
index 74370b2..689ccb0 100644
--- a/lib/libipset.map
+++ b/lib/libipset.map
@@ -106,7 +106,7 @@ global:
ipset_match_option;
ipset_match_envopt;
ipset_shift_argv;
-
+
local: *;
};
diff --git a/lib/parse.c b/lib/parse.c
index 8c67c58..65fddd4 100644
--- a/lib/parse.c
+++ b/lib/parse.c
@@ -63,13 +63,13 @@ static char *
escape_range_separator(const char *str)
{
const char *tmp = NULL;
-
+
if (STRNEQ(str, IPSET_ESCAPE_START, 1)) {
tmp = strstr(str, IPSET_ESCAPE_END);
if (tmp == NULL)
return NULL;
}
-
+
return range_separator(tmp == NULL ? str : tmp);
}
@@ -248,7 +248,7 @@ find_range_separator(struct ipset_session *session, char *str)
}
static char *
-strip_escape(struct ipset_session *session, char * str)
+strip_escape(struct ipset_session *session, char *str)
{
if (STRNEQ(str, IPSET_ESCAPE_START, 1)) {
if (!STREQ(str + strlen(str) - 1, IPSET_ESCAPE_END)) {
@@ -279,7 +279,7 @@ parse_portname(struct ipset_session *session, const char *str,
if (tmp == NULL)
goto error;
- service = getservbyname(tmp, proto);
+ service = getservbyname(tmp, proto);
if (service != NULL) {
*port = ntohs((uint16_t) service->s_port);
free(saved);
@@ -748,7 +748,8 @@ get_addrinfo(struct ipset_session *session,
if (found == 0)
return syntax_err("cannot parse %s: "
"%s address could not be resolved",
- str, family == NFPROTO_IPV4 ? "IPv4" : "IPv6");
+ str,
+ family == NFPROTO_IPV4 ? "IPv4" : "IPv6");
return err;
}
@@ -1642,7 +1643,7 @@ ipset_call_parser(struct ipset_session *session,
if (ipset_data_flags_test(data, IPSET_FLAG(arg->opt))
&& !(arg->opt == IPSET_OPT_FAMILY
- && ipset_data_test_ignored(data, IPSET_OPT_FAMILY)))
+ && ipset_data_test_ignored(data, IPSET_OPT_FAMILY)))
return syntax_err("%s already specified", arg->name[0]);
return arg->parse(session, arg->opt, str);
diff --git a/lib/print.c b/lib/print.c
index f2f848b..1bd8392 100644
--- a/lib/print.c
+++ b/lib/print.c
@@ -174,7 +174,7 @@ __getnameinfo4(char *buf, unsigned int len,
memmove(buf + 1, buf, strlen(buf) + 1);
buf[0] = escape[0];
strcat(buf, IPSET_ESCAPE_END);
- }
+ }
return (err == 0 ? (int)strlen(buf) :
(err == EAI_OVERFLOW || err == EAI_SYSTEM) ? (int)len : -1);
}
@@ -210,7 +210,7 @@ __getnameinfo6(char *buf, unsigned int len,
memmove(buf + 1, buf, strlen(buf) + 1);
buf[0] = escape[0];
strcat(buf, IPSET_ESCAPE_END);
- }
+ }
return (err == 0 ? (int)strlen(buf) :
(err == EAI_OVERFLOW || err == EAI_SYSTEM) ? (int)len : -1);
}
diff --git a/lib/session.c b/lib/session.c
index d5f220f..8bb62cc 100644
--- a/lib/session.c
+++ b/lib/session.c
@@ -1507,7 +1507,8 @@ data2attr(struct ipset_session *session, struct nlmsghdr *nlh,
data2attr(session, nlh, data, type, family, attrs)
#define ADDATTR_SETNAME(session, nlh, data) \
- data2attr(session, nlh, data, IPSET_ATTR_SETNAME, NFPROTO_IPV4, cmd_attrs)
+ data2attr(session, nlh, data, IPSET_ATTR_SETNAME, NFPROTO_IPV4, \
+ cmd_attrs)
#define ADDATTR_IF(session, nlh, data, type, family, attrs) \
ipset_data_test(data, attrs[type].opt) ? \
@@ -1673,8 +1674,8 @@ build_msg(struct ipset_session *session, bool aggregate)
ADDATTR_SETNAME(session, nlh, data);
if (flags && session->mode != IPSET_LIST_SAVE) {
ipset_data_set(data, IPSET_OPT_FLAGS, &flags);
- ADDATTR(session, nlh, data, IPSET_ATTR_FLAGS, NFPROTO_IPV4,
- cmd_attrs);
+ ADDATTR(session, nlh, data, IPSET_ATTR_FLAGS,
+ NFPROTO_IPV4, cmd_attrs);
}
break;
}
diff --git a/lib/types.c b/lib/types.c
index 5721705..adaba83 100644
--- a/lib/types.c
+++ b/lib/types.c
@@ -306,7 +306,7 @@ found:
}
#define set_family_and_type(data, match, family) do { \
- if (family == NFPROTO_UNSPEC && match->family != NFPROTO_UNSPEC) \
+ if (family == NFPROTO_UNSPEC && match->family != NFPROTO_UNSPEC) \
family = match->family == NFPROTO_IPSET_IPV46 ? \
NFPROTO_IPV4 : match->family;\
ipset_data_set(data, IPSET_OPT_FAMILY, &family); \
@@ -578,9 +578,9 @@ ipset_cache_fini(void)
*
* Load in (register) all known set types for the system
*/
- void
- ipset_load_types(void)
- {
+void
+ipset_load_types(void)
+{
#ifdef ENABLE_SETTYPE_MODULES
const char *dir = IPSET_MODSDIR;
const char *next = NULL;
@@ -591,8 +591,8 @@ ipset_cache_fini(void)
int len;
#endif
- if (typelist != NULL)
- return;
+ if (typelist != NULL)
+ return;
/* Initialize static types */
ipset_types_init();
@@ -605,7 +605,7 @@ ipset_cache_fini(void)
next = dir + strlen(dir);
len = snprintf(path, sizeof(path), "%.*s",
- (unsigned int)(next - dir), dir);
+ (unsigned int)(next - dir), dir);
if (len >= sizeof(path) || len < 0)
continue;
@@ -618,13 +618,13 @@ ipset_cache_fini(void)
if (strstr(list[n]->d_name, ".so") == NULL)
goto nextf;
- len = snprintf(file, sizeof(file), "%s/%s", path, list[n]->d_name);
+ len = snprintf(file, sizeof(file), "%s/%s",
+ path, list[n]->d_name);
if (len >= sizeof(file) || len < 0)
goto nextf;
- if (dlopen(file, RTLD_NOW) == NULL) {
+ if (dlopen(file, RTLD_NOW) == NULL)
fprintf(stderr, "%s: %s\n", file, dlerror());
- }
nextf:
free(list[n]);
@@ -634,5 +634,5 @@ nextf:
dir = next + 1;
} while (*next != '\0');
-#endif // ENABLE_SETTYPE_MODULES
+#endif /* ENABLE_SETTYPE_MODULES */
}