diff options
author | ru <ru@FreeBSD.org> | 2001-06-07 13:50:24 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2001-06-07 13:50:24 +0000 |
commit | e8be8c503badfdbcc17ce3f321e410e9069188ab (patch) | |
tree | 094413f428de4e93c52ef7e9cd2536f8689e5727 | |
parent | 056e449b05cd8204b5c17c524f98d1d085355385 (diff) | |
download | FreeBSD-src-e8be8c503badfdbcc17ce3f321e410e9069188ab.zip FreeBSD-src-e8be8c503badfdbcc17ce3f321e410e9069188ab.tar.gz |
- Exit 1 if "add", "change", or "delete" operation fails.
PR: bin/12489
- Use inet_ntoa(3) where it should have been used. This
part of code simply wasn't converted to the "new" style
after the routename() function was converted from the
protocol-generic version to protocol-specific version
in CSRG revision 5.6.
MFC after: 1 week
-rw-r--r-- | sbin/route/route.8 | 4 | ||||
-rw-r--r-- | sbin/route/route.c | 18 |
2 files changed, 12 insertions, 10 deletions
diff --git a/sbin/route/route.8 b/sbin/route/route.8 index 7cc617f..5e67f44 100644 --- a/sbin/route/route.8 +++ b/sbin/route/route.8 @@ -363,6 +363,10 @@ An add operation was attempted, but the system was low on resources and was unable to allocate memory to create the new entry. .El +.Pp +The +.Nm +utility exits 0 on success or >0 if an error occurred. .Sh SEE ALSO .Xr netintro 4 , .Xr route 4 , diff --git a/sbin/route/route.c b/sbin/route/route.c index f52481e..77aa720 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -195,7 +195,6 @@ main(argc, argv) case K_ADD: case K_DELETE: newroute(argc, argv); - exit(0); /* NOTREACHED */ case K_MONITOR: @@ -358,13 +357,8 @@ routename(sa) if (cp) { strncpy(line, cp, sizeof(line) - 1); line[sizeof(line) - 1] = '\0'; - } else { - /* XXX - why not inet_ntoa()? */ -#define C(x) (unsigned)((x) & 0xff) - in.s_addr = ntohl(in.s_addr); - (void) sprintf(line, "%u.%u.%u.%u", C(in.s_addr >> 24), - C(in.s_addr >> 16), C(in.s_addr >> 8), C(in.s_addr)); - } + } else + (void) sprintf(line, "%s", inet_ntoa(in)); break; } @@ -454,6 +448,7 @@ netname(sa) if (np) cp = np->n_name; } +#define C(x) (unsigned)((x) & 0xff) if (cp) strncpy(line, cp, sizeof(line)); else if ((in.s_addr & 0xffffff) == 0) @@ -468,6 +463,7 @@ netname(sa) (void) sprintf(line, "%u.%u.%u.%u", C(in.s_addr >> 24), C(in.s_addr >> 16), C(in.s_addr >> 8), C(in.s_addr)); +#undef C break; } @@ -731,9 +727,10 @@ newroute(argc, argv) (void) printf(" (%s)", inet_ntoa(((struct sockaddr_in *)&route.rt_gateway)->sin_addr)); } - if (ret == 0) + if (ret == 0) { (void) printf("\n"); - else { + exit(0); + } else { switch (oerrno) { case ESRCH: err = "not in table"; @@ -749,6 +746,7 @@ newroute(argc, argv) break; } (void) printf(": %s\n", err); + exit(1); } } |