[BusyBox-cvs] busybox/networking/libiproute ipaddress.c,1.1,1.2

Glenn McGrath bug1 at busybox.net
Thu Nov 28 10:49:17 UTC 2002


Update of /var/cvs/busybox/networking/libiproute
In directory winder:/tmp/cvs-serv22709/networking/libiproute

Modified Files:
	ipaddress.c 
Log Message:
Use error_msg instead of fprintf(stderr


Index: ipaddress.c
===================================================================
RCS file: /var/cvs/busybox/networking/libiproute/ipaddress.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ipaddress.c	10 Nov 2002 01:33:51 -0000	1.1
+++ ipaddress.c	28 Nov 2002 10:49:14 -0000	1.2
@@ -129,7 +129,7 @@
 	memset(tb, 0, sizeof(tb));
 	parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len);
 	if (tb[IFLA_IFNAME] == NULL) {
-		fprintf(stderr, "BUG: nil ifname\n");
+		error_msg("nil ifname");
 		return -1;
 	}
 	if (filter.label &&
@@ -211,7 +211,7 @@
 		return 0;
 	len -= NLMSG_LENGTH(sizeof(*ifa));
 	if (len < 0) {
-		fprintf(stderr, "BUG: wrong nlmsg len %d\n", len);
+		error_msg("wrong nlmsg len %d", len);
 		return -1;
 	}
 
@@ -436,32 +436,28 @@
 		exit(1);
 
 	if (rtnl_wilddump_request(&rth, preferred_family, RTM_GETLINK) < 0) {
-		perror("Cannot send dump request");
-		exit(1);
+		perror_msg_and_die("Cannot send dump request");
 	}
 
 	if (rtnl_dump_filter(&rth, store_nlmsg, &linfo, NULL, NULL) < 0) {
-		fprintf(stderr, "Dump terminated\n");
-		exit(1);
+		error_msg_and_die("Dump terminated");
 	}
 
 	if (filter_dev) {
 		filter.ifindex = ll_name_to_index(filter_dev);
 		if (filter.ifindex <= 0) {
-			fprintf(stderr, "Device \"%s\" does not exist.\n", filter_dev);
+			error_msg("Device \"%s\" does not exist.", filter_dev);
 			return -1;
 		}
 	}
 
 	if (filter.family != AF_PACKET) {
 		if (rtnl_wilddump_request(&rth, filter.family, RTM_GETADDR) < 0) {
-			perror("Cannot send dump request");
-			exit(1);
+			perror_msg_and_die("Cannot send dump request");
 		}
 
 		if (rtnl_dump_filter(&rth, store_nlmsg, &ainfo, NULL, NULL) < 0) {
-			fprintf(stderr, "Dump terminated\n");
-			exit(1);
+			error_msg_and_die("Dump terminated");
 		}
 	}
 
@@ -654,12 +650,11 @@
 		argc--; argv++;
 	}
 	if (d == NULL) {
-		fprintf(stderr, "Not enough information: \"dev\" argument is required.\n");
+		error_msg("Not enough information: \"dev\" argument is required.");
 		return -1;
 	}
 	if (l && matches(d, l) != 0) {
-		fprintf(stderr, "\"dev\" (%s) must match \"label\" (%s).\n", d, l);
-		exit(1);
+		error_msg_and_die("\"dev\" (%s) must match \"label\" (%s).", d, l);
 	}
 
 	if (peer_len == 0 && local_len && cmd != RTM_DELADDR) {
@@ -673,7 +668,7 @@
 		inet_prefix brd;
 		int i;
 		if (req.ifa.ifa_family != AF_INET) {
-			fprintf(stderr, "Broadcast can be set only for IPv4 addresses\n");
+			error_msg("Broadcast can be set only for IPv4 addresses");
 			return -1;
 		}
 		brd = peer;
@@ -697,7 +692,7 @@
 	ll_init_map(&rth);
 
 	if ((req.ifa.ifa_index = ll_name_to_index(d)) == 0) {
-		fprintf(stderr, "Cannot find device \"%s\"\n", d);
+		error_msg("Cannot find device \"%s\"", d);
 		return -1;
 	}
 
@@ -718,6 +713,6 @@
 	if (matches(*argv, "list") == 0 || matches(*argv, "show") == 0
 	    || matches(*argv, "lst") == 0)
 		return ipaddr_list(argc-1, argv+1);
-	fprintf(stderr, "Command \"%s\" is unknown, try \"ip address help\".\n", *argv);
+	error_msg("Command \"%s\" is unknown, try \"ip address help\".", *argv);
 	exit(-1);
 }




More information about the busybox-cvs mailing list