summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoan Lledó <joanlluislledo@gmail.com>2018-08-11 18:17:08 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2018-08-14 00:35:56 +0200
commit9deab2b025e1aa512d1378753dbe1e1ef43686b8 (patch)
treeacc6f255fe519105420c02a5932edddb46f7c112
parentf511dce3f6598b75505a553ee40036bdb8167042 (diff)
lwip: refactor main demuxer to avoid code duplication
* lwip/main.c (lwip_demuxer): Refactored.
-rw-r--r--lwip/main.c42
1 files changed, 11 insertions, 31 deletions
diff --git a/lwip/main.c b/lwip/main.c
index 9f7eb9b2..4dfbe143 100644
--- a/lwip/main.c
+++ b/lwip/main.c
@@ -99,6 +99,7 @@ int
lwip_demuxer (mach_msg_header_t * inp, mach_msg_header_t * outp)
{
struct port_info *pi;
+ mig_routine_t routine = NULL;
/* Clear errno to prevent raising previous errors again */
errno = 0;
@@ -116,40 +117,19 @@ lwip_demuxer (mach_msg_header_t * inp, mach_msg_header_t * outp)
if (pi)
{
ports_port_deref (pi);
-
- mig_routine_t routine;
- if ((routine = lwip_io_server_routine (inp)) ||
- (routine = lwip_socket_server_routine (inp)) ||
- (routine = lwip_pfinet_server_routine (inp)) ||
- (routine = lwip_iioctl_server_routine (inp)) ||
- (routine = NULL, trivfs_demuxer (inp, outp)) ||
- (routine = lwip_startup_notify_server_routine (inp)))
- {
- if (routine)
- (*routine) (inp, outp);
- return TRUE;
- }
- else
- return FALSE;
+ routine = lwip_io_server_routine (inp);
}
- else
+
+ if (routine || (routine = lwip_socket_server_routine (inp)) ||
+ (routine = lwip_pfinet_server_routine (inp)) ||
+ (routine = lwip_iioctl_server_routine (inp)) ||
+ (routine = lwip_startup_notify_server_routine (inp)))
{
- mig_routine_t routine;
- if ((routine = lwip_socket_server_routine (inp)) ||
- (routine = lwip_pfinet_server_routine (inp)) ||
- (routine = lwip_iioctl_server_routine (inp)) ||
- (routine = NULL, trivfs_demuxer (inp, outp)) ||
- (routine = lwip_startup_notify_server_routine (inp)))
- {
- if (routine)
- (*routine) (inp, outp);
- return TRUE;
- }
- else
- return FALSE;
+ (*routine) (inp, outp);
+ return TRUE;
}
-
- return 0;
+ else
+ return trivfs_demuxer (inp, outp);
}
void