[PATCH 1/5] fix error return value while loading environment

Luotao Fu l.fu at pengutronix.de
Fri Mar 26 08:52:25 EDT 2010


Signed-off-by: Luotao Fu <l.fu at pengutronix.de>
---
 common/environment.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/common/environment.c b/common/environment.c
index 0c7de84..0eb7e6b 100644
--- a/common/environment.c
+++ b/common/environment.c
@@ -198,6 +198,7 @@ int envfs_load(char *filename, char *dir)
 	if (crc32(0, (unsigned char *)&super, sizeof(struct envfs_super) - 4)
 		   != ENVFS_32(super.sb_crc)) {
 		printf("wrong crc on env superblock\n");
+		ret = -EIO;
 		goto out;
 	}
 
@@ -207,18 +208,20 @@ int envfs_load(char *filename, char *dir)
 	ret = read(envfd, buf, size);
 	if (ret < size) {
 		perror("read");
+		ret = errno;
 		goto out;
 	}
 
 	if (crc32(0, (unsigned char *)buf, size)
 		     != ENVFS_32(super.crc)) {
 		printf("wrong crc on env\n");
+		ret = -EIO;
 		goto out;
 	}
 
 	while (size) {
 		struct envfs_inode *inode;
-        uint32_t inode_size,inode_namelen;
+		uint32_t inode_size, inode_namelen;
 
 		inode = (struct envfs_inode *)buf;
 
@@ -251,6 +254,7 @@ int envfs_load(char *filename, char *dir)
 				inode_size);
 		if (ret < inode_size) {
 			perror("write");
+			ret = errno;
 			close(fd);
 			goto out;
 		}
-- 
1.7.0




More information about the barebox mailing list