From 377f22d8ece0078445bfe664ac8b399b55883bc6 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 10 Nov 2001 00:11:33 +0000 Subject: [PATCH] 2001-11-09 Roland McGrath * hurd/privports.c (__get_privileged_ports): Only contact the proc server if necessary for this call. Suggested by Neal H Walfield . Check error return for mach_port_mod_refs. --- hurd/privports.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/hurd/privports.c b/hurd/privports.c index 018b2dd..5d3232b 100644 --- a/hurd/privports.c +++ b/hurd/privports.c @@ -28,7 +28,8 @@ kern_return_t __get_privileged_ports (host_priv_t *host_priv_ptr, device_t *device_master_ptr) { - if (! _hurd_host_priv) + if ((host_priv_ptr && _hurd_host_priv == MACH_PORT_NULL) + || (device_master_ptr && _hurd_device_master == MACH_PORT_NULL)) { error_t err; @@ -47,16 +48,24 @@ __get_privileged_ports (host_priv_t *host_priv_ptr, if (host_priv_ptr) { - __mach_port_mod_refs (mach_task_self (), - _hurd_host_priv, MACH_PORT_RIGHT_SEND, 1); + error_t err = _hurd_host_priv == MACH_PORT_NULL ? 0 + : __mach_port_mod_refs (mach_task_self (), + _hurd_host_priv, MACH_PORT_RIGHT_SEND, +1); + if (err) + return err; *host_priv_ptr = _hurd_host_priv; } + if (device_master_ptr) { - __mach_port_mod_refs (mach_task_self (), - _hurd_device_master, MACH_PORT_RIGHT_SEND, 1); + error_t err = _hurd_device_master == MACH_PORT_NULL ? 0 + : __mach_port_mod_refs (mach_task_self (), + _hurd_device_master, MACH_PORT_RIGHT_SEND, +1); + if (err) + return err; *device_master_ptr = _hurd_device_master; } + return KERN_SUCCESS; } weak_alias (__get_privileged_ports, get_privileged_ports) -- 2.7.4