aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2011-11-20 19:08:15 -0500
committerMike Frysinger <vapier@gentoo.org>2011-11-20 19:11:22 -0500
commit6a9347cb91535eb35306eff731d94384c9b7025e (patch)
treef8054f0f73fb9855c7909e0bc73e74cd4ba47e9e
parentget_sname: constify args/return when possible (diff)
downloadnet-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.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/inet.c b/lib/inet.c
index 8080364..073c8a3 100644
--- a/lib/inet.c
+++ b/lib/inet.c
@@ -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);
}