diff options
author | 2011-11-20 19:08:15 -0500 | |
---|---|---|
committer | 2011-11-20 19:11:22 -0500 | |
commit | 6a9347cb91535eb35306eff731d94384c9b7025e (patch) | |
tree | f8054f0f73fb9855c7909e0bc73e74cd4ba47e9e | |
parent | get_sname: constify args/return when possible (diff) | |
download | net-tools-6a9347cb91535eb35306eff731d94384c9b7025e.tar.gz net-tools-6a9347cb91535eb35306eff731d94384c9b7025e.tar.bz2 net-tools-6a9347cb91535eb35306eff731d94384c9b7025e.zip |
get_sname: unify numeric handling
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rw-r--r-- | lib/inet.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -423,10 +423,9 @@ const char *get_sname(int socknumber, const char *proto, int numeric) if (socknumber == 0) return ("*"); - if (numeric) { - sprintf(buffer, "%d", ntohs(socknumber)); - return (buffer); - } + if (numeric) + goto do_ntohs; + if (!init) { (void) read_services(); init = 1; @@ -443,8 +442,11 @@ const char *get_sname(int socknumber, const char *proto, int numeric) sprintf(buffer, "%s", item->name); } - if (!buffer[0]) + + if (!buffer[0]) { + do_ntohs: sprintf(buffer, "%d", ntohs(socknumber)); + } return (buffer); } |