Skip to contentSkip to conversation

lib/utils.c: should return correct error message

PATCH In review Hangbin Liu 2 participants 2 messages Nov 14, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/utils.c: should return correct error message

---
 lib/utils.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
lib/utils.c +10 -2
index 4e9c719..59221b2 100644
@@ -487,7 +487,11 @@ int get_addr(inet_prefix *dst, const char *arg, int family)
 		exit(1);
 	}
 	if (get_addr_1(dst, arg, family)) {
-		fprintf(stderr, "Error: an inet address is expected rather than \"%s\".\n", arg);
+		// FIXME: Don't know how to handle AF_UNSPEC and AF_DECnet
+		if (family == AF_INET6)
+			fprintf(stderr, "Error: an inet6 address is expected rather than \"%s\".\n", arg);
+		else
+			fprintf(stderr, "Error: an inet address is expected rather than \"%s\".\n", arg);
 		exit(1);
 	}
 	return 0;
@@ -500,7 +504,11 @@ int get_prefix(inet_prefix *dst, char *arg, int family)
 		exit(1);
 	}
 	if (get_prefix_1(dst, arg, family)) {
-		fprintf(stderr, "Error: an inet prefix is expected rather than \"%s\".\n", arg);
+		// FIXME: Don't know how to handle AF_DECnet
+		if (family == AF_INET6)
+			fprintf(stderr, "Error: an inet6 prefix is expected rather than \"%s\".\n", arg);
+		else
+			fprintf(stderr, "Error: an inet prefix is expected rather than \"%s\".\n", arg);
 		exit(1);
 	}
 	return 0;
Signature · 1 line
1.8.1.4
#1 lore raw
Quoted 25 lines · On Thu, 14 Nov 2013 15:00:24 +0800 Hangbin Liu <[email protected]> wrote:
---
 lib/utils.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
lib/utils.c +5 -1
index 4e9c719..59221b2 100644
@@ -487,7 +487,11 @@ int get_addr(inet_prefix *dst, const char *arg, int family)
 		exit(1);
 	}
 	if (get_addr_1(dst, arg, family)) {
-		fprintf(stderr, "Error: an inet address is expected rather than \"%s\".\n", arg);
+		// FIXME: Don't know how to handle AF_UNSPEC and AF_DECnet
+		if (family == AF_INET6)
+			fprintf(stderr, "Error: an inet6 address is expected rather than \"%s\".\n", arg);
+		else
+			fprintf(stderr, "Error: an inet address is expected rather than \"%s\".\n", arg);
 		exit(1);
 	}
 	return 0;
@@ -500,7 +504,11 @@ int get_prefix(inet_prefix *dst, char *arg, int family)
 		exit(1);
 	}

lib/utils.c int get_prefix(inet_prefix *dst, char *arg, int family) · line 514

Quoted 10 lines
lib/utils.c +5 -1
 	if (get_prefix_1(dst, arg, family)) {
-		fprintf(stderr, "Error: an inet prefix is expected rather than \"%s\".\n", arg);
+		// FIXME: Don't know how to handle AF_DECnet
+		if (family == AF_INET6)
+			fprintf(stderr, "Error: an inet6 prefix is expected rather than \"%s\".\n", arg);
+		else
+			fprintf(stderr, "Error: an inet prefix is expected rather than \"%s\".\n", arg);
 		exit(1);
 	}
 	return 0;

Thanks for the patch but
I don't see a lot of improvement with the new error message to warrant making the change.