aboutsummaryrefslogtreecommitdiffstats
path: root/net/llc/af_llc.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@mandriva.com>2005-09-22 02:59:22 -0400
committerArnaldo Carvalho de Melo <acme@mandriva.com>2005-09-22 02:59:22 -0400
commitaf426d327c38bcb8cbb87c60134d42d2e93b20cc (patch)
tree913af84609a80231cf38d1f64e5775fb66121c95 /net/llc/af_llc.c
parent0eb8017242cb7e8b18af4751b03646436b8f90e3 (diff)
[LLC]: Help the compiler with likely/unlikely, saving some more bytes
Signed-off-by: Jochen Friedrich <jochen@scram.de> Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Diffstat (limited to 'net/llc/af_llc.c')
-rw-r--r--net/llc/af_llc.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index 81a53791ed9c..aed61e6376ed 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -155,7 +155,7 @@ static int llc_ui_create(struct socket *sock, int protocol)
155 struct sock *sk; 155 struct sock *sk;
156 int rc = -ESOCKTNOSUPPORT; 156 int rc = -ESOCKTNOSUPPORT;
157 157
158 if (sock->type == SOCK_DGRAM || sock->type == SOCK_STREAM) { 158 if (likely(sock->type == SOCK_DGRAM || sock->type == SOCK_STREAM)) {
159 rc = -ENOMEM; 159 rc = -ENOMEM;
160 sk = llc_sk_alloc(PF_LLC, GFP_KERNEL, &llc_proto); 160 sk = llc_sk_alloc(PF_LLC, GFP_KERNEL, &llc_proto);
161 if (sk) { 161 if (sk) {
@@ -177,7 +177,7 @@ static int llc_ui_release(struct socket *sock)
177 struct sock *sk = sock->sk; 177 struct sock *sk = sock->sk;
178 struct llc_sock *llc; 178 struct llc_sock *llc;
179 179
180 if (!sk) 180 if (unlikely(sk == NULL))
181 goto out; 181 goto out;
182 sock_hold(sk); 182 sock_hold(sk);
183 lock_sock(sk); 183 lock_sock(sk);
@@ -294,10 +294,10 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen)
294 int rc = -EINVAL; 294 int rc = -EINVAL;
295 295
296 dprintk("%s: binding %02X\n", __FUNCTION__, addr->sllc_sap); 296 dprintk("%s: binding %02X\n", __FUNCTION__, addr->sllc_sap);
297 if (!sock_flag(sk, SOCK_ZAPPED) || addrlen != sizeof(*addr)) 297 if (unlikely(!sock_flag(sk, SOCK_ZAPPED) || addrlen != sizeof(*addr)))
298 goto out; 298 goto out;
299 rc = -EAFNOSUPPORT; 299 rc = -EAFNOSUPPORT;
300 if (addr->sllc_family != AF_LLC) 300 if (unlikely(addr->sllc_family != AF_LLC))
301 goto out; 301 goto out;
302 if (!addr->sllc_sap) { 302 if (!addr->sllc_sap) {
303 rc = -EUSERS; 303 rc = -EUSERS;
@@ -358,7 +358,7 @@ static int llc_ui_shutdown(struct socket *sock, int how)
358 int rc = -ENOTCONN; 358 int rc = -ENOTCONN;
359 359
360 lock_sock(sk); 360 lock_sock(sk);
361 if (sk->sk_state != TCP_ESTABLISHED) 361 if (unlikely(sk->sk_state != TCP_ESTABLISHED))
362 goto out; 362 goto out;
363 rc = -EINVAL; 363 rc = -EINVAL;
364 if (how != 2) 364 if (how != 2)
@@ -396,10 +396,15 @@ static int llc_ui_connect(struct socket *sock, struct sockaddr *uaddr,
396 int rc = -EINVAL; 396 int rc = -EINVAL;
397 397
398 lock_sock(sk); 398 lock_sock(sk);
399 if (addrlen != sizeof(*addr)) 399 if (unlikely(addrlen != sizeof(*addr)))
400 goto out; 400 goto out;
401 rc = -EAFNOSUPPORT; 401 rc = -EAFNOSUPPORT;
402 if (addr->sllc_family != AF_LLC) 402 if (unlikely(addr->sllc_family != AF_LLC))
403 goto out;
404 if (unlikely(sk->sk_type != SOCK_STREAM))
405 goto out;
406 rc = -EALREADY;
407 if (unlikely(sock->state == SS_CONNECTING))
403 goto out; 408 goto out;
404 /* bind connection to sap if user hasn't done it. */ 409 /* bind connection to sap if user hasn't done it. */
405 if (sock_flag(sk, SOCK_ZAPPED)) { 410 if (sock_flag(sk, SOCK_ZAPPED)) {
@@ -410,11 +415,6 @@ static int llc_ui_connect(struct socket *sock, struct sockaddr *uaddr,
410 llc->daddr.lsap = addr->sllc_sap; 415 llc->daddr.lsap = addr->sllc_sap;
411 memcpy(llc->daddr.mac, addr->sllc_mac, IFHWADDRLEN); 416 memcpy(llc->daddr.mac, addr->sllc_mac, IFHWADDRLEN);
412 } 417 }
413 if (sk->sk_type != SOCK_STREAM)
414 goto out;
415 rc = -EALREADY;
416 if (sock->state == SS_CONNECTING)
417 goto out;
418 sock->state = SS_CONNECTING; 418 sock->state = SS_CONNECTING;
419 sk->sk_state = TCP_SYN_SENT; 419 sk->sk_state = TCP_SYN_SENT;
420 llc->link = llc_ui_next_link_no(llc->sap->laddr.lsap); 420 llc->link = llc_ui_next_link_no(llc->sap->laddr.lsap);
@@ -448,10 +448,10 @@ static int llc_ui_listen(struct socket *sock, int backlog)
448 int rc = -EINVAL; 448 int rc = -EINVAL;
449 449
450 lock_sock(sk); 450 lock_sock(sk);
451 if (sock->state != SS_UNCONNECTED) 451 if (unlikely(sock->state != SS_UNCONNECTED))
452 goto out; 452 goto out;
453 rc = -EOPNOTSUPP; 453 rc = -EOPNOTSUPP;
454 if (sk->sk_type != SOCK_STREAM) 454 if (unlikely(sk->sk_type != SOCK_STREAM))
455 goto out; 455 goto out;
456 rc = -EAGAIN; 456 rc = -EAGAIN;
457 if (sock_flag(sk, SOCK_ZAPPED)) 457 if (sock_flag(sk, SOCK_ZAPPED))
@@ -614,10 +614,11 @@ static int llc_ui_accept(struct socket *sock, struct socket *newsock, int flags)
614 dprintk("%s: accepting on %02X\n", __FUNCTION__, 614 dprintk("%s: accepting on %02X\n", __FUNCTION__,
615 llc_sk(sk)->laddr.lsap); 615 llc_sk(sk)->laddr.lsap);
616 lock_sock(sk); 616 lock_sock(sk);
617 if (sk->sk_type != SOCK_STREAM) 617 if (unlikely(sk->sk_type != SOCK_STREAM))
618 goto out; 618 goto out;
619 rc = -EINVAL; 619 rc = -EINVAL;
620 if (sock->state != SS_UNCONNECTED || sk->sk_state != TCP_LISTEN) 620 if (unlikely(sock->state != SS_UNCONNECTED ||
621 sk->sk_state != TCP_LISTEN))
621 goto out; 622 goto out;
622 /* wait for a connection to arrive. */ 623 /* wait for a connection to arrive. */
623 rc = llc_ui_wait_for_data(sk, sk->sk_rcvtimeo); 624 rc = llc_ui_wait_for_data(sk, sk->sk_rcvtimeo);
@@ -880,7 +881,7 @@ static int llc_ui_setsockopt(struct socket *sock, int level, int optname,
880 int rc = -EINVAL, opt; 881 int rc = -EINVAL, opt;
881 882
882 lock_sock(sk); 883 lock_sock(sk);
883 if (level != SOL_LLC || optlen != sizeof(int)) 884 if (unlikely(level != SOL_LLC || optlen != sizeof(int)))
884 goto out; 885 goto out;
885 rc = get_user(opt, (int __user *)optval); 886 rc = get_user(opt, (int __user *)optval);
886 if (rc) 887 if (rc)
@@ -955,7 +956,7 @@ static int llc_ui_getsockopt(struct socket *sock, int level, int optname,
955 int val = 0, len = 0, rc = -EINVAL; 956 int val = 0, len = 0, rc = -EINVAL;
956 957
957 lock_sock(sk); 958 lock_sock(sk);
958 if (level != SOL_LLC) 959 if (unlikely(level != SOL_LLC))
959 goto out; 960 goto out;
960 rc = get_user(len, optlen); 961 rc = get_user(len, optlen);
961 if (rc) 962 if (rc)