Index: uspace/app/netecho/netecho.c
===================================================================
--- uspace/app/netecho/netecho.c	(revision 5d0f1bc98f63dba53e1c3f9b28ec5a020e3bbe81)
+++ uspace/app/netecho/netecho.c	(revision a8e5051a633bec02a8deec21772f6cadc0da9f98)
@@ -41,4 +41,5 @@
 #include <task.h>
 #include <arg_parse.h>
+#include <err.h>
 
 #include <net/in.h>
@@ -90,4 +91,6 @@
 int main(int argc, char *argv[])
 {
+	ERROR_DECLARE;
+
 	size_t size = 1024;
 	int verbose = 0;
@@ -114,5 +117,4 @@
 	size_t reply_length;
 	int value;
-	int rc;
 
 	// parse the command line arguments
@@ -121,17 +123,11 @@
 			switch (argv[index][1]) {
 			case 'b':
-				rc = arg_parse_int(argc, argv, &index, &backlog, 0);
-				if (rc != EOK)
-					return rc;
+				ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &backlog, 0));
 				break;
 			case 'c':
-				rc = arg_parse_int(argc, argv, &index, &count, 0);
-				if (rc != EOK)
-					return rc;
+				ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &count, 0));
 				break;
 			case 'f':
-				rc = arg_parse_name_int(argc, argv, &index, &family, 0, socket_parse_protocol_family);
-				if (rc != EOK)
-					return rc;
+				ERROR_PROPAGATE(arg_parse_name_int(argc, argv, &index, &family, 0, socket_parse_protocol_family));
 				break;
 			case 'h':
@@ -140,24 +136,16 @@
 				break;
 			case 'p':
-				rc = arg_parse_int(argc, argv, &index, &value, 0);
-				if (rc != EOK)
-					return rc;
+				ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &value, 0));
 				port = (uint16_t) value;
 				break;
 			case 'r':
-				rc = arg_parse_string(argc, argv, &index, &reply, 0);
-				if (rc != EOK)
-					return rc;
+				ERROR_PROPAGATE(arg_parse_string(argc, argv, &index, &reply, 0));
 				break;
 			case 's':
-				rc = arg_parse_int(argc, argv, &index, &value, 0);
-				if (rc != EOK)
-					return rc;
+				ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &value, 0));
 				size = (value >= 0) ? (size_t) value : 0;
 				break;
 			case 't':
-				rc = arg_parse_name_int(argc, argv, &index, &value, 0, socket_parse_socket_type);
-				if (rc != EOK)
-					return rc;
+				ERROR_PROPAGATE(arg_parse_name_int(argc, argv, &index, &value, 0, socket_parse_socket_type));
 				type = (sock_type_t) value;
 				break;
@@ -168,34 +156,22 @@
 			case '-':
 				if (str_lcmp(argv[index] + 2, "backlog=", 6) == 0) {
-					rc = arg_parse_int(argc, argv, &index, &backlog, 8);
-					if (rc != EOK)
-						return rc;
+					ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &backlog, 8));
 				} else if (str_lcmp(argv[index] + 2, "count=", 6) == 0) {
-					rc = arg_parse_int(argc, argv, &index, &count, 8);
+					ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &count, 8));
 				} else if (str_lcmp(argv[index] + 2, "family=", 7) == 0) {
-					rc = arg_parse_name_int(argc, argv, &index, &family, 9, socket_parse_protocol_family);
-					if (rc != EOK)
-						return rc;
+						ERROR_PROPAGATE(arg_parse_name_int(argc, argv, &index, &family, 9, socket_parse_protocol_family));
 				} else if (str_lcmp(argv[index] + 2, "help", 5) == 0) {
 					echo_print_help();
 					return EOK;
 				} else if (str_lcmp(argv[index] + 2, "port=", 5) == 0) {
-					rc = arg_parse_int(argc, argv, &index, &value, 7);
-					if (rc != EOK)
-						return rc;
+					ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &value, 7));
 					port = (uint16_t) value;
 				} else if (str_lcmp(argv[index] + 2, "reply=", 6) == 0) {
-					rc = arg_parse_string(argc, argv, &index, &reply, 8);
-					if (rc != EOK)
-						return rc;
+					ERROR_PROPAGATE(arg_parse_string(argc, argv, &index, &reply, 8));
 				} else if (str_lcmp(argv[index] + 2, "size=", 5) == 0) {
-					rc = arg_parse_int(argc, argv, &index, &value, 7);
-					if (rc != EOK)
-						return rc;
+					ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &value, 7));
 					size = (value >= 0) ? (size_t) value : 0;
 				} else if (str_lcmp(argv[index] + 2, "type=", 5) == 0) {
-					rc = arg_parse_name_int(argc, argv, &index, &value, 7, socket_parse_socket_type);
-					if (rc != EOK)
-						return rc;
+					ERROR_PROPAGATE(arg_parse_name_int(argc, argv, &index, &value, 7, socket_parse_socket_type));
 					type = (sock_type_t) value;
 				} else if (str_lcmp(argv[index] + 2, "verbose", 8) == 0) {
@@ -264,16 +240,14 @@
 		}
 		// set the backlog
-		rc = listen(listening_id, backlog);
-		if (rc != EOK) {
-			socket_print_error(stderr, rc, "Socket listen: ", "\n");
-			return rc;
+		if (ERROR_OCCURRED(listen(listening_id, backlog))) {
+			socket_print_error(stderr, ERROR_CODE, "Socket listen: ", "\n");
+			return ERROR_CODE;
 		}
 	}
 
 	// bind the listenning socket
-	rc = bind(listening_id, address, addrlen);
-	if (rc != EOK) {
-		socket_print_error(stderr, rc, "Socket bind: ", "\n");
-		return rc;
+	if (ERROR_OCCURRED(bind(listening_id, address, addrlen))) {
+		socket_print_error(stderr, ERROR_CODE, "Socket bind: ", "\n");
+		return ERROR_CODE;
 	}
 
@@ -327,7 +301,6 @@
 					// parse the source address
 					if (address_start) {
-						rc = inet_ntop(address->sa_family, address_start, address_string, sizeof(address_string));
-						if (rc != EOK) {
-							fprintf(stderr, "Received address error %d\n", rc);
+						if (ERROR_OCCURRED(inet_ntop(address->sa_family, address_start, address_string, sizeof(address_string)))) {
+							fprintf(stderr, "Received address error %d\n", ERROR_CODE);
 						} else {
 							data[length] = '\0';
@@ -338,14 +311,12 @@
 
 				// answer the request either with the static reply or the original data
-				rc = sendto(socket_id, reply ? reply : data, reply ? reply_length : length, 0, address, addrlen);
-				if (rc != EOK)
-					socket_print_error(stderr, rc, "Socket send: ", "\n");
+				if (ERROR_OCCURRED(sendto(socket_id, reply ? reply : data, reply ? reply_length : length, 0, address, addrlen)))
+					socket_print_error(stderr, ERROR_CODE, "Socket send: ", "\n");
 			}
 
 			// close the accepted stream socket
 			if (type == SOCK_STREAM) {
-				rc = closesocket(socket_id);
-				if (rc != EOK)
-					socket_print_error(stderr, rc, "Close socket: ", "\n");
+				if (ERROR_OCCURRED(closesocket(socket_id)))
+					socket_print_error(stderr, ERROR_CODE, "Close socket: ", "\n");
 			}
 
@@ -364,8 +335,7 @@
 
 	// close the listenning socket
-	rc = closesocket(listening_id);
-	if (rc != EOK) {
-		socket_print_error(stderr, rc, "Close socket: ", "\n");
-		return rc;
+	if (ERROR_OCCURRED(closesocket(listening_id))) {
+		socket_print_error(stderr, ERROR_CODE, "Close socket: ", "\n");
+		return ERROR_CODE;
 	}
 
