Index: generic/src/sysinfo/sysinfo.c
===================================================================
--- generic/src/sysinfo/sysinfo.c	(revision e9a9469e993fe8d856602c42a71375b714545c04)
+++ generic/src/sysinfo/sysinfo.c	(revision 68965ec51e19b4e44203b19bb7d52c5e18fb0e21)
@@ -32,117 +32,128 @@
 #include <syscall/copy.h>
 
-sysinfo_item_t *_root=NULL;
-
-
-static sysinfo_item_t* sysinfo_find_item(const char *name,sysinfo_item_t *subtree)
-{
-	if(subtree==NULL) return NULL;
-	while(subtree!=NULL)
-	{
-		int i;
-		char *a,*b;
-		a=(char *)name;
-		b=subtree->name;
-		while((a[i]==b[i])&&(b[i])) i++;
-		if((!a[i]) && (!b[i])) return subtree; /*Last name in path matches*/
-		if((a[i]=='.') && (!b[i])) /*Middle name in path matches*/
-		{
-			if(subtree->subinfo_type==SYSINFO_SUBINFO_TABLE) return sysinfo_find_item(a+i+1,subtree->subinfo.table);
-			//if(subtree->subinfo_type==SYSINFO_SUBINFO_FUNCTION) return NULL; /* Subinfo managed by subsystem*/
-			return NULL; /*No subinfo*/
+sysinfo_item_t *_root = NULL;
+
+
+static sysinfo_item_t *sysinfo_find_item(const char *name, sysinfo_item_t *subtree)
+{
+	if (subtree == NULL)
+		return NULL;
+	
+	while (subtree != NULL)	{
+		int i = 0;
+		char *a = (char *) name;
+		char *b = subtree->name;
+		
+		while ((a[i] == b[i]) && (b[i]))
+			i++;
+		
+		if ((!a[i]) && (!b[i]))  /* Last name in path matches */
+			return subtree;
+		
+		if ((a[i] == '.') && (!b[i])) { /* Middle name in path matches */
+			if (subtree->subinfo_type == SYSINFO_SUBINFO_TABLE)
+				return sysinfo_find_item(a + i + 1, subtree->subinfo.table);
+			
+			//if (subtree->subinfo_type == SYSINFO_SUBINFO_FUNCTION) /* Subinfo managed by subsystem */
+			//	return NULL; 
+			
+			return NULL; /* No subinfo */
 		}
-		/* No matches try next*/
-		subtree=subtree->next;
-		i=0;
+		/* No matches try next */
+		subtree = subtree->next;
+		i = 0;
 	}
 	return NULL;
 }
 
-static sysinfo_item_t* sysinfo_create_path(const char *name,sysinfo_item_t **psubtree)
+static sysinfo_item_t *sysinfo_create_path(const char *name, sysinfo_item_t **psubtree)
 {
 	sysinfo_item_t *subtree;
 	subtree = *psubtree;
 	
-	if(subtree==NULL) 
-	{
-			sysinfo_item_t *item;
-			int i=0,j;
-			
-			item = malloc(sizeof(sysinfo_item_t),0);
+	if (subtree == NULL) {
+			sysinfo_item_t *item = malloc(sizeof(sysinfo_item_t), 0);
+			int i = 0, j;
+			
 			ASSERT(item);
 			*psubtree = item;
-			item -> next = NULL;
-			item -> val_type = SYSINFO_VAL_UNDEFINED;
-			item -> subinfo.table = NULL;
-
-			while(name[i]&&(name[i]!='.')) i++;
-			
-			item -> name = malloc(i,0);
-			ASSERT(item -> name);
-
-			for(j=0;j<i;j++) item->name[j]=name[j];
-			item->name[j]=0;
-			
-			if(name[i]/*=='.'*/)
-			{
-				item -> subinfo_type = SYSINFO_SUBINFO_TABLE;
-				return sysinfo_create_path(name+i+1,&(item->subinfo.table));
+			item->next = NULL;
+			item->val_type = SYSINFO_VAL_UNDEFINED;
+			item->subinfo.table = NULL;
+
+			while (name[i] && (name[i] != '.'))
+				i++;
+			
+			item->name = malloc(i, 0);
+			ASSERT(item->name);
+
+			for (j = 0; j < i; j++)
+				item->name[j] = name[j];
+			item->name[j] = 0;
+			
+			if (name[i]) { /* =='.' */
+				item->subinfo_type = SYSINFO_SUBINFO_TABLE;
+				return sysinfo_create_path(name + i + 1, &(item->subinfo.table));
 			}
-			item -> subinfo_type = SYSINFO_SUBINFO_NONE;
+			item->subinfo_type = SYSINFO_SUBINFO_NONE;
 			return item;
 	}
 
-	while(subtree!=NULL)
-	{
-		int i=0,j;
-		char *a,*b;
-		a=(char *)name;
-		b=subtree->name;
-		while((a[i]==b[i])&&(b[i])) i++;
-		if((!a[i]) && (!b[i])) return subtree; /*Last name in path matches*/
-		if((a[i]=='.') && (!b[i])) /*Middle name in path matches*/
-		{
-			if(subtree->subinfo_type==SYSINFO_SUBINFO_TABLE) return sysinfo_create_path(a+i+1,&(subtree->subinfo.table));
-			if(subtree->subinfo_type==SYSINFO_SUBINFO_NONE) 
-			{
-				subtree->subinfo_type=SYSINFO_SUBINFO_TABLE;
-				return sysinfo_create_path(a+i+1,&(subtree->subinfo.table));
-			}	
-			//if(subtree->subinfo_type==SYSINFO_SUBINFO_FUNCTION) return NULL; /* Subinfo managed by subsystem*/
+	while (subtree != NULL) {
+		int i = 0, j;
+		char *a = (char *) name;
+		char *b = subtree->name;
+		
+		while ((a[i] == b[i]) && (b[i]))
+			i++;
+		
+		if ((!a[i]) && (!b[i])) /* Last name in path matches */
+			return subtree;
+		
+		if ((a[i] == '.') && (!b[i])) { /* Middle name in path matches */
+			if (subtree->subinfo_type == SYSINFO_SUBINFO_TABLE)
+				return sysinfo_create_path(a + i + 1, &(subtree->subinfo.table));
+			
+			if (subtree->subinfo_type == SYSINFO_SUBINFO_NONE) {
+				subtree->subinfo_type = SYSINFO_SUBINFO_TABLE;
+				return sysinfo_create_path(a + i + 1,&(subtree->subinfo.table));
+			}
+			
+			//if (subtree->subinfo_type == SYSINFO_SUBINFO_FUNCTION) /* Subinfo managed by subsystem */
+			//	return NULL; 
+			
 			return NULL;
 		}
 		/* No matches try next or create new*/
-		if(subtree->next==NULL)
-		{
-			sysinfo_item_t *item;
-			
-			item = malloc(sizeof(sysinfo_item_t),0);
+		if (subtree->next == NULL) {
+			sysinfo_item_t *item = malloc(sizeof(sysinfo_item_t), 0);
+			
 			ASSERT(item);
-			subtree -> next = item;
-			item -> next = NULL;
-			item -> val_type = SYSINFO_VAL_UNDEFINED;
-			item -> subinfo.table = NULL;
-
-			i=0;
-			while(name[i]&&(name[i]!='.')) i++;
-
-			item -> name = malloc(i,0);
-			ASSERT(item -> name);
-			for(j=0;j<i;j++) item->name[j]=name[j];
-			item->name[j]=0;
-
-			if(name[i]/*=='.'*/)
-			{
-				item -> subinfo_type = SYSINFO_SUBINFO_TABLE;
-				return sysinfo_create_path(name+i+1,&(item->subinfo.table));
+			subtree->next = item;
+			item->next = NULL;
+			item->val_type = SYSINFO_VAL_UNDEFINED;
+			item->subinfo.table = NULL;
+
+			i = 0;
+			while (name[i] && (name[i] != '.'))
+				i++;
+
+			item->name = malloc(i, 0);
+			ASSERT(item->name);
+			
+			for (j = 0; j < i; j++)
+				item->name[j] = name[j];
+			
+			item->name[j] = 0;
+
+			if(name[i]) { /* =='.' */
+				item->subinfo_type = SYSINFO_SUBINFO_TABLE;
+				return sysinfo_create_path(name + i + 1, &(item->subinfo.table));
 			}
-			item -> subinfo_type = SYSINFO_SUBINFO_NONE;
+			item->subinfo_type = SYSINFO_SUBINFO_NONE;
 			return item;
-
-		}
-		else
-		{
-			subtree=subtree->next;
-			i=0;
+		} else {
+			subtree = subtree->next;
+			i = 0;
 		}	
 	}
@@ -151,127 +162,140 @@
 }
 
-void sysinfo_set_item_val(const char *name,sysinfo_item_t **root,__native val)
-{
-	if(root==NULL) root=&_root;
-	sysinfo_item_t *item;
-	item = sysinfo_create_path(name,root); /* If already created create only returns pointer 
-	                                        If ! , create it */
-	if(item!=NULL) /* If in subsystem, unable to create or return so unable to set */
-	{
+void sysinfo_set_item_val(const char *name, sysinfo_item_t **root, __native val)
+{
+	if (root == NULL)
+		root = &_root;
+	
+	/* If already created create only returns pointer 
+	   If not, create it */
+	sysinfo_item_t *item = sysinfo_create_path(name, root);
+	
+	if (item != NULL) { /* If in subsystem, unable to create or return so unable to set */
 		item->val.val=val;                   
-		item -> val_type = SYSINFO_VAL_VAL;
-	}	
-}
-
-void sysinfo_set_item_function(const char *name,sysinfo_item_t **root,sysinfo_val_fn_t fn)
-{
-	if(root==NULL) root=&_root;
-	sysinfo_item_t *item;
-	item = sysinfo_create_path(name,root); /* If already created create only returns pointer 
-	                                        If ! , create it */
-	if(item!=NULL)  /* If in subsystem, unable to create or return so  unable to set */
-	{
+		item->val_type = SYSINFO_VAL_VAL;
+	}
+}
+
+void sysinfo_set_item_function(const char *name, sysinfo_item_t **root, sysinfo_val_fn_t fn)
+{
+	if (root == NULL)
+		root = &_root;
+	
+	/* If already created create only returns pointer 
+	   If not, create it */
+	sysinfo_item_t *item = sysinfo_create_path(name, root);
+	
+	if (item != NULL) { /* If in subsystem, unable to create or return so  unable to set */
 		item->val.fn=fn;                   
-		item -> val_type = SYSINFO_VAL_FUNCTION;
-	}	
-}
-
-
-void sysinfo_set_item_undefined(const char *name,sysinfo_item_t **root)
-{
-	if(root==NULL) root=&_root;
-	sysinfo_item_t *item;
-	item = sysinfo_find_item(name,*root);  
-	if(item!=NULL) 	item -> val_type = SYSINFO_VAL_UNDEFINED;
-}
-
-
-void sysinfo_dump(sysinfo_item_t **proot,int depth)
+		item->val_type = SYSINFO_VAL_FUNCTION;
+	}
+}
+
+
+void sysinfo_set_item_undefined(const char *name, sysinfo_item_t **root)
+{
+	if (root == NULL)
+		root = &_root;
+	
+	/* If already created create only returns pointer 
+	   If not, create it */
+	sysinfo_item_t *item = sysinfo_create_path(name, root);
+	
+	if (item != NULL)
+		item->val_type = SYSINFO_VAL_UNDEFINED;
+}
+
+
+void sysinfo_dump(sysinfo_item_t **proot, int depth)
 {
 	sysinfo_item_t *root;
-	if(proot==NULL) proot=&_root;
+	if (proot == NULL)
+		proot = &_root;
+	
 	root = *proot;
 	
-	while(root!=NULL)
-	{
-
+	while (root != NULL) {
 		int i;
-		__native val=0;
-		char *vtype=NULL;
-		
-		
-		for(i=0;i<depth;i++) printf("  ");
-		
-		switch (root->val_type)
-		{
-			case (SYSINFO_VAL_UNDEFINED):
-			                             val=0;
-			                             vtype="UND";
-																	 break;
-			case (SYSINFO_VAL_VAL):
-			                             val=root->val.val;
-			                             vtype="VAL";
-																	 break;
-			case (SYSINFO_VAL_FUNCTION):
-			                             val=((sysinfo_val_fn_t)(root->val.fn))(root);
-			                             vtype="FUN";
-																	 break;
-		}		                      
-		printf("%s    %s val:%d(%X) sub:%s\n",root->name,vtype,val,val,
-			(root->subinfo_type==SYSINFO_SUBINFO_NONE)?"NON":((root->subinfo_type==SYSINFO_SUBINFO_TABLE)?"TAB":"FUN"));
-		
-		
-		if(root -> subinfo_type == SYSINFO_SUBINFO_TABLE)
-			sysinfo_dump(&(root->subinfo.table),depth+1);
-		root=root->next;
-	}	
-}
-
-sysinfo_rettype_t sysinfo_get_val(const char *name,sysinfo_item_t **root)
-{
-	/*TODO:
-		Implement Subsystem subinfo (by function implemented subinfo)
-	*/
-
-	sysinfo_rettype_t ret={0,false};
-
-	if(root==NULL) root=&_root;
-	sysinfo_item_t *item;
-	item = sysinfo_find_item(name,*root);  
-	if(item!=NULL) 	
-	{
-		if (item -> val_type == SYSINFO_VAL_UNDEFINED) 
+		__native val = 0;
+		char *vtype = NULL;
+		
+		
+		for (i = 0; i < depth; i++)
+			printf("  ");
+		
+		switch (root->val_type) {
+			case SYSINFO_VAL_UNDEFINED:
+				val = 0;
+				vtype = "UND";
+				break;
+			case SYSINFO_VAL_VAL:
+				val = root->val.val;
+				vtype = "VAL";
+				break;
+			case SYSINFO_VAL_FUNCTION:
+				val = ((sysinfo_val_fn_t) (root->val.fn)) (root);
+				vtype = "FUN";
+				break;
+		}
+		
+		printf("%s    %s val:%d(%X) sub:%s\n", root->name, vtype, val, val, (root->subinfo_type == SYSINFO_SUBINFO_NONE) ? "NON" : ((root->subinfo_type == SYSINFO_SUBINFO_TABLE) ? "TAB" : "FUN"));
+		
+		if (root->subinfo_type == SYSINFO_SUBINFO_TABLE)
+			sysinfo_dump(&(root -> subinfo.table), depth + 1);
+		
+		root = root->next;
+	}
+}
+
+sysinfo_rettype_t sysinfo_get_val(const char *name, sysinfo_item_t **root)
+{
+	// TODO: Implement Subsystem subinfo (by function implemented subinfo)
+
+	sysinfo_rettype_t ret = {0, false};
+
+	if (root == NULL)
+		root = &_root;
+	
+	sysinfo_item_t *item = sysinfo_find_item(name, *root);
+	
+	if (item != NULL) {
+		if (item->val_type == SYSINFO_VAL_UNDEFINED) 
 			return ret;
-		else ret.valid=true;
-		if (item -> val_type == SYSINFO_VAL_VAL)
-			ret.val=item -> val.val;
-		else ret.val=((sysinfo_val_fn_t)(item->val.fn))(item);
+		else
+			ret.valid = true;
+		
+		if (item->val_type == SYSINFO_VAL_VAL)
+			ret.val = item->val.val;
+		else
+			ret.val = ((sysinfo_val_fn_t) (item->val.fn)) (item);
 	}
 	return ret;
 }
 
-__native sys_sysinfo_valid(__native ptr,__native len)
+__native sys_sysinfo_valid(__native ptr, __native len)
 {
 	char *str;
-	sysinfo_rettype_t ret={0,0};
-	str=malloc(len+1,0);
+	sysinfo_rettype_t ret = {0, 0};
+	str = malloc(len + 1, 0);
+	
 	ASSERT(str);
-	if(!((copy_from_uspace(str,(void *)ptr,len+1))||(str[len]))) 
-		ret=sysinfo_get_val(str,NULL);
+	if (!((copy_from_uspace(str, (void *) ptr, len + 1)) || (str[len])))
+		ret = sysinfo_get_val(str, NULL);
+	
 	free(str);
 	return ret.valid;
 }
 
-__native sys_sysinfo_value(__native ptr,__native len)
+__native sys_sysinfo_value(__native ptr, __native len)
 {
 	char *str;
-	sysinfo_rettype_t ret={0,0};
-	str=malloc(len+1,0);
+	sysinfo_rettype_t ret = {0, 0};
+	str = malloc(len + 1, 0);
+	
 	ASSERT(str);
-	if(!((copy_from_uspace(str,(void *)ptr,len+1))||(str[len]))) 
-		ret=sysinfo_get_val(str,NULL);
+	if (!((copy_from_uspace(str, (void *) ptr, len + 1)) || (str[len]))) 
+		ret = sysinfo_get_val(str, NULL);
+	
 	free(str);
 	return ret.val;
 }
-
-
