OSSP CVS Repository

ossp - Check-in [1486]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 1486
Date: 2002-Jan-02 14:52:38 (local)
2002-Jan-02 13:52:38 (UTC)
User:rse
Branch:
Comment: rewrite with a more readable switch() statement
Tickets:
Inspections:
Files:
ossp-pkg/sa/sa.c      1.49 -> 1.50     18 inserted, 17 deleted

ossp-pkg/sa/sa.c 1.49 -> 1.50

--- sa.c 2002/01/02 13:44:48     1.49
+++ sa.c 2002/01/02 13:52:38     1.50
@@ -1209,25 +1209,26 @@
 /* override system call */
 sa_rc_t sa_syscall(sa_t *sa, sa_syscall_t id, void (*fptr)(), void *fctx)
 {
+    sa_rc_t rv;
+
+    /* argument sanity check(s) */
     if (sa == NULL || fptr == NULL)
         return SA_ERR_ARG;
-    if (id == SA_SYSCALL_CONNECT)
-        SA_SC_ASSIGN(sa, connect, fptr, fctx); 
-    else if (id == SA_SYSCALL_ACCEPT)
-        SA_SC_ASSIGN(sa, accept, fptr, fctx); 
-    else if (id == SA_SYSCALL_SELECT)
-        SA_SC_ASSIGN(sa, select, fptr, fctx); 
-    else if (id == SA_SYSCALL_READ)
-        SA_SC_ASSIGN(sa, read, fptr, fctx); 
-    else if (id == SA_SYSCALL_WRITE)
-        SA_SC_ASSIGN(sa, write, fptr, fctx); 
-    else if (id == SA_SYSCALL_RECVFROM)
-        SA_SC_ASSIGN(sa, recvfrom, fptr, fctx); 
-    else if (id == SA_SYSCALL_SENDTO)
-        SA_SC_ASSIGN(sa, sendto, fptr, fctx); 
-    else
-        return SA_ERR_ARG;
-    return SA_OK;
+
+    /* assign system call */
+    rv = SA_OK;
+    switch (id) {
+        case SA_SYSCALL_CONNECT:  SA_SC_ASSIGN(sa, connect,  fptr, fctx); 
+        case SA_SYSCALL_ACCEPT:   SA_SC_ASSIGN(sa, accept,   fptr, fctx); 
+        case SA_SYSCALL_SELECT:   SA_SC_ASSIGN(sa, select,   fptr, fctx); 
+        case SA_SYSCALL_READ:     SA_SC_ASSIGN(sa, read,     fptr, fctx); 
+        case SA_SYSCALL_WRITE:    SA_SC_ASSIGN(sa, write,    fptr, fctx); 
+        case SA_SYSCALL_RECVFROM: SA_SC_ASSIGN(sa, recvfrom, fptr, fctx); 
+        case SA_SYSCALL_SENDTO:   SA_SC_ASSIGN(sa, sendto,   fptr, fctx); 
+        case: rv = SA_ERR_ARG;
+    }
+
+    return rv;
 }
 
 /* bind socket to a local address */

CVSTrac 2.0.1