summaryrefslogtreecommitdiffstats
path: root/src/conntrack/api.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2008-10-30 13:24:13 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2008-10-30 13:24:13 +0100
commit83ee97498db28cb3e092f26f1a9169fbff1b1c6e (patch)
tree0eaec2083184795dc47437792976be5c6fa09dd2 /src/conntrack/api.c
parent93c459d603cc7a3d9cadeb0844364d5e59aa267c (diff)
API: use of __builtin_expect in error checking paths
This patch introduces likely() and unlikely() that use __builtin_expect to assist the compiler in the branch decisions. I am assuming that we have no clients of libnetfilter_conntrack that use gcc < 2.96. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/conntrack/api.c')
-rw-r--r--src/conntrack/api.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/conntrack/api.c b/src/conntrack/api.c
index 7943082..61d3237 100644
--- a/src/conntrack/api.c
+++ b/src/conntrack/api.c
@@ -103,7 +103,7 @@ int nfct_setobjopt(struct nf_conntrack *ct, unsigned int option)
{
assert(ct != NULL);
- if (option > NFCT_SOPT_MAX) {
+ if (unlikely(option > NFCT_SOPT_MAX)) {
errno = EOPNOTSUPP;
return -1;
}
@@ -123,7 +123,7 @@ int nfct_getobjopt(const struct nf_conntrack *ct, unsigned int option)
{
assert(ct != NULL);
- if (option > NFCT_GOPT_MAX) {
+ if (unlikely(option > NFCT_GOPT_MAX)) {
errno = EOPNOTSUPP;
return -1;
}
@@ -218,7 +218,7 @@ void nfct_set_attr(struct nf_conntrack *ct,
assert(ct != NULL);
assert(value != NULL);
- if (type >= ATTR_MAX)
+ if (unlikely(type >= ATTR_MAX))
return;
if (set_attr_array[type]) {
@@ -279,7 +279,7 @@ const void *nfct_get_attr(const struct nf_conntrack *ct,
{
assert(ct != NULL);
- if (type >= ATTR_MAX) {
+ if (unlikely(type >= ATTR_MAX)) {
errno = EINVAL;
return NULL;
}
@@ -355,7 +355,7 @@ int nfct_attr_is_set(const struct nf_conntrack *ct,
{
assert(ct != NULL);
- if (type >= ATTR_MAX) {
+ if (unlikely(type >= ATTR_MAX)) {
errno = EINVAL;
return -1;
}
@@ -375,7 +375,7 @@ int nfct_attr_unset(struct nf_conntrack *ct,
{
assert(ct != NULL);
- if (type >= ATTR_MAX) {
+ if (unlikely(type >= ATTR_MAX)) {
errno = EINVAL;
return -1;
}
@@ -893,7 +893,7 @@ void nfct_filter_add_attr(struct nfct_filter *filter,
assert(filter != NULL);
assert(value != NULL);
- if (type >= NFCT_FILTER_MAX)
+ if (unlikely(type >= NFCT_FILTER_MAX))
return;
if (filter_attr_array[type]) {
@@ -934,7 +934,7 @@ int nfct_filter_set_logic(struct nfct_filter *filter,
const enum nfct_filter_attr type,
const enum nfct_filter_logic logic)
{
- if (type >= NFCT_FILTER_MAX) {
+ if (unlikely(type >= NFCT_FILTER_MAX)) {
errno = ENOTSUP;
return -1;
}