syscalls: <interface> printer correctly handles lack of sockaddr.

Reported by Danny Milosavljevic <dannym@scratchpost.org>
in <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22612#16>.

* guix/build/syscalls.scm (write-interface): Check whether ADDRESS is
true.
This commit is contained in:
Ludovic Courtès 2016-03-25 17:24:47 +01:00
parent a2da8c173a
commit 001dae0d74
1 changed files with 8 additions and 4 deletions

View File

@ -767,10 +767,14 @@ the same type as that returned by 'make-socket-address'."
(format port "#<interface ~s " name)
(unless (zero? (logand IFF_UP flags))
(display "up " port))
(if (member (sockaddr:fam address) (list AF_INET AF_INET6))
(format port "~a " (inet-ntop (sockaddr:fam address)
(sockaddr:addr address)))
(format port "family:~a " (sockaddr:fam address)))
;; Check whether ADDRESS really is a sockaddr.
(when address
(if (member (sockaddr:fam address) (list AF_INET AF_INET6))
(format port "~a " (inet-ntop (sockaddr:fam address)
(sockaddr:addr address)))
(format port "family:~a " (sockaddr:fam address))))
(format port "~a>" (number->string (object-address interface) 16)))))
(set-record-type-printer! <interface> write-interface)