git: 927aa5fefd4c - main - bhyve: Fix getaddrinfo() error handling
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 08 Feb 2022 18:36:48 UTC
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=927aa5fefd4c69e72d44189a04fadf80e42d0ad8 commit 927aa5fefd4c69e72d44189a04fadf80e42d0ad8 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2022-02-08 17:34:03 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2022-02-08 17:40:41 +0000 bhyve: Fix getaddrinfo() error handling - Use errx() since errno will not be set. - Print the message returned by gai_strerror(). MFC after: 1 week Sponsored by: The FreeBSD Foundation --- usr.sbin/bhyve/gdb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bhyve/gdb.c b/usr.sbin/bhyve/gdb.c index 0cee1c8f9543..3842a1d58dec 100644 --- a/usr.sbin/bhyve/gdb.c +++ b/usr.sbin/bhyve/gdb.c @@ -1858,8 +1858,9 @@ init_gdb(struct vmctx *_ctx) hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_NUMERICSERV | AI_PASSIVE; - if (getaddrinfo(saddr, sport, &hints, &gdbaddr) != 0) - err(1, "gdb address resolve"); + error = getaddrinfo(saddr, sport, &hints, &gdbaddr); + if (error != 0) + errx(1, "gdb address resolution: %s", gai_strerror(error)); ctx = _ctx; s = socket(gdbaddr->ai_family, gdbaddr->ai_socktype, 0);