Index: uspace/lib/c/generic/adt/measured_strings.c
===================================================================
--- uspace/lib/c/generic/adt/measured_strings.c	(revision f4c8a83fcccd1bda6e8735965144672a29bb8336)
+++ uspace/lib/c/generic/adt/measured_strings.c	(revision 254444258962a4784495752977900a9dea514caa)
@@ -52,7 +52,7 @@
  * @param[in] string	The initial character string to be stored.
  * @param[in] length	The length of the given string without the terminating
- *			zero ('\0') character. If the length is zero, the actual
- *			length is computed. The given length is used and
- *			appended with the terminating zero ('\0') character
+ *			zero ('/0') character. If the length is zero (0), the
+ *			actual length is computed. The given length is used and
+ *			appended with the terminating zero ('\\0') character
  *			otherwise.
  * @returns		The new bundled character string with measured length.
@@ -60,5 +60,5 @@
  */
 measured_string_ref
-measured_string_create_bulk(const char *string, size_t length)
+measured_string_create_bulk(const char * string, size_t length)
 {
 	measured_string_ref new;
@@ -66,5 +66,5 @@
 	if (length == 0) {
 		while (string[length])
-			length++;
+			++length;
 	}
 	new = (measured_string_ref) malloc(sizeof(measured_string_t) +
@@ -104,6 +104,7 @@
 			new->value[new->length] = '\0';
 			return new;
+		} else {
+			free(new);
 		}
-		free(new);
 	}
 
@@ -155,6 +156,6 @@
 		return EINVAL;
 	}
-	if (ERROR_OCCURRED(async_data_write_finalize(callid, lengths,
-	    length))) {
+	if(ERROR_OCCURRED(async_data_write_finalize(callid, lengths,
+	    sizeof(size_t) * (count + 1)))) {
 		free(lengths);
 		return ERROR_CODE;
@@ -162,5 +163,5 @@
 
 	*data = malloc(lengths[count]);
-	if (!*data) {
+	if (!(*data)) {
 		free(lengths);
 		return ENOMEM;
@@ -170,5 +171,5 @@
 	*strings = (measured_string_ref) malloc(sizeof(measured_string_t) *
 	    count);
-	if (!*strings) {
+	if (!(*strings)) {
 		free(lengths);
 		free(*data);
@@ -177,8 +178,8 @@
 
 	next = *data;
-	for (index = 0; index < count; index++) {
+	for (index = 0; index < count; ++index) {
 		(*strings)[index].length = lengths[index];
 		if (lengths[index] > 0) {
-			if (!async_data_write_receive(&callid, &length) ||
+			if ((!async_data_write_receive(&callid, &length)) ||
 			    (length != lengths[index])) {
 				free(*data);
@@ -187,14 +188,10 @@
 				return EINVAL;
 			}
-			if (ERROR_OCCURRED(async_data_write_finalize(callid,
-			    next, lengths[index]))) {
-				free(*data);
-				free(*strings);
-				free(lengths);
-				return ERROR_CODE;
-			}
+			ERROR_PROPAGATE(async_data_write_finalize(callid, next,
+			    lengths[index]));
 			(*strings)[index].value = next;
 			next += lengths[index];
-			*next++ = '\0';
+			*next = '\0';
+			++next;
 		} else {
 			(*strings)[index].value = NULL;
@@ -224,5 +221,5 @@
 
 	length = 0;
-	for (index = 0; index < count; index++) {
+	for (index = 0; index < count; ++ index) {
 		lengths[index] = strings[index].length;
 		length += lengths[index] + 1;
@@ -265,10 +262,11 @@
 		return ENOMEM;
 
-	if (!async_data_read_receive(&callid, &length) ||
+	if ((!async_data_read_receive(&callid, &length)) ||
 	    (length != sizeof(size_t) * (count + 1))) {
 		free(lengths);
 		return EINVAL;
 	}
-	if (ERROR_OCCURRED(async_data_read_finalize(callid, lengths, length))) {
+	if (ERROR_OCCURRED(async_data_read_finalize(callid, lengths,
+	    sizeof(size_t) * (count + 1)))) {
 		free(lengths);
 		return ERROR_CODE;
@@ -276,7 +274,7 @@
 	free(lengths);
 
-	for (index = 0; index < count; index++) {
+	for (index = 0; index < count; ++ index) {
 		if (strings[index].length > 0) {
-			if (!async_data_read_receive(&callid, &length) ||
+			if((!async_data_read_receive(&callid, &length))	||
 			    (length != strings[index].length)) {
 				return EINVAL;
@@ -319,5 +317,5 @@
 	char *next;
 
-	if ((phone < 0) || (!strings) || (!data) || (count <= 0))
+	if ((phone <= 0) || (!strings) || (!data) || (count <= 0))
 		return EINVAL;
 
@@ -333,5 +331,5 @@
 
 	*data = malloc(lengths[count]);
-	if (!*data) {
+	if (!(*data)) {
 		free(lengths);
 		return ENOMEM;
@@ -340,5 +338,5 @@
 	*strings = (measured_string_ref) malloc(sizeof(measured_string_t) *
 	    count);
-	if (!*strings) {
+	if (!(*strings)) {
 		free(lengths);
 		free(*data);
@@ -347,17 +345,13 @@
 
 	next = *data;
-	for (index = 0; index < count; index++) {
+	for (index = 0; index < count; ++ index) {
 		(*strings)[index].length = lengths[index];
 		if (lengths[index] > 0) {
-			if (ERROR_OCCURRED(async_data_read_start(phone, next,
-			    lengths[index]))) {
-			    	free(lengths);
-				free(data);
-				free(strings);
-				return ERROR_CODE;
-			}
+			ERROR_PROPAGATE(async_data_read_start(phone, next,
+			    lengths[index]));
 			(*strings)[index].value = next;
 			next += lengths[index];
-			*next++ = '\0';
+			*next = '\0';
+			++ next;
 		} else {
 			(*strings)[index].value = NULL;
@@ -392,5 +386,5 @@
 	size_t index;
 
-	if ((phone < 0) || (!strings) || (count <= 0))
+	if ((phone <= 0) || (!strings) || (count <= 0))
 		return EINVAL;
 
@@ -407,5 +401,5 @@
 	free(lengths);
 
-	for (index = 0; index < count; index++) {
+	for (index = 0; index < count; ++index) {
 		if (strings[index].length > 0) {
 			ERROR_PROPAGATE(async_data_write_start(phone,
