[rtems commit] Correct error return mismatches
Gedare Bloom
gedare at rtems.org
Wed Dec 24 03:53:32 UTC 2014
Module: rtems
Branch: master
Commit: 86364e8c6ae55f7f15f426aefe8c260d96a3efc0
Changeset: http://git.rtems.org/rtems/commit/?id=86364e8c6ae55f7f15f426aefe8c260d96a3efc0
Author: Nick Withers <nick.withers at anu.edu.au>
Date: Thu Dec 5 12:52:42 2013 +1100
Correct error return mismatches
Closes #2139
---
cpukit/libfs/src/rfs/rtems-rfs-buffer.h | 4 +-
cpukit/libfs/src/rfs/rtems-rfs-file-system.c | 1 -
cpukit/libfs/src/rfs/rtems-rfs-file-system.h | 4 +-
cpukit/libfs/src/rfs/rtems-rfs-format.c | 61 ++++++++++++++++++++--------
4 files changed, 48 insertions(+), 22 deletions(-)
diff --git a/cpukit/libfs/src/rfs/rtems-rfs-buffer.h b/cpukit/libfs/src/rfs/rtems-rfs-buffer.h
index 66b75f9..f5fe9d4 100644
--- a/cpukit/libfs/src/rfs/rtems-rfs-buffer.h
+++ b/cpukit/libfs/src/rfs/rtems-rfs-buffer.h
@@ -68,8 +68,8 @@ typedef struct _rtems_rfs_buffer
size_t size;
uint32_t references;
} rtems_rfs_buffer;
-#define rtems_rfs_buffer_io_request rtems_rfs_buffer_devceio_request
-#define rtems_rfs_buffer_io_release rtems_rfs_uffer_deviceio_release
+#define rtems_rfs_buffer_io_request rtems_rfs_buffer_deviceio_request
+#define rtems_rfs_buffer_io_release rtems_rfs_buffer_deviceio_release
/**
* Request a buffer from the device I/O.
diff --git a/cpukit/libfs/src/rfs/rtems-rfs-file-system.c b/cpukit/libfs/src/rfs/rtems-rfs-file-system.c
index a3bcf02..cf47f43 100644
--- a/cpukit/libfs/src/rfs/rtems-rfs-file-system.c
+++ b/cpukit/libfs/src/rfs/rtems-rfs-file-system.c
@@ -301,7 +301,6 @@ rtems_rfs_fs_open (const char* name,
return -1;
}
- errno = 0;
return 0;
}
diff --git a/cpukit/libfs/src/rfs/rtems-rfs-file-system.h b/cpukit/libfs/src/rfs/rtems-rfs-file-system.h
index 99e8ebc..e00b142 100644
--- a/cpukit/libfs/src/rfs/rtems-rfs-file-system.h
+++ b/cpukit/libfs/src/rfs/rtems-rfs-file-system.h
@@ -389,7 +389,7 @@ uint64_t rtems_rfs_fs_media_size (rtems_rfs_file_system* fs);
* @param[in] max_held_buffers is the maximum number of buffers the RFS holds.
*
* @retval 0 Successful operation.
- * @retval error_code An error occurred.
+ * @retval -1 Error. See errno
*/
int rtems_rfs_fs_open (const char* name,
void* user,
@@ -403,7 +403,7 @@ int rtems_rfs_fs_open (const char* name,
* @param[in] fs is the file system data.
*
* @retval 0 Successful operation.
- * @retval error_code An error occurred.
+ * @retval -1 Error. See errno
*/
int rtems_rfs_fs_close (rtems_rfs_file_system* fs);
diff --git a/cpukit/libfs/src/rfs/rtems-rfs-format.c b/cpukit/libfs/src/rfs/rtems-rfs-format.c
index abc623e..1a9798e 100644
--- a/cpukit/libfs/src/rfs/rtems-rfs-format.c
+++ b/cpukit/libfs/src/rfs/rtems-rfs-format.c
@@ -467,15 +467,18 @@ rtems_rfs_write_root_dir (const char* name)
rc = rtems_rfs_fs_open (name, NULL,
RTEMS_RFS_FS_FORCE_OPEN | RTEMS_RFS_FS_NO_LOCAL_CACHE,
0, &fs);
- if (rc < 0)
+ if (rc != 0)
{
+ rc = errno;
+
printf ("rtems-rfs: format: file system open failed: %d: %s\n",
- errno, strerror (errno));
- return -1;
+ rc, strerror (rc));
+
+ return rc;
}
rc = rtems_rfs_inode_alloc (fs, RTEMS_RFS_ROOT_INO, &ino);
- if (rc > 0)
+ if (rc != 0)
{
printf ("rtems-rfs: format: inode allocation failed: %d: %s\n",
rc, strerror (rc));
@@ -487,11 +490,11 @@ rtems_rfs_write_root_dir (const char* name)
{
printf ("rtems-rfs: format: allocated inode not root ino: %" PRId32 "\n", ino);
rtems_rfs_fs_close (fs);
- return rc;
+ return EINVAL;
}
rc = rtems_rfs_inode_open (fs, ino, &inode, true);
- if (rc > 0)
+ if (rc != 0)
{
printf ("rtems-rfs: format: inode open failed: %d: %s\n",
rc, strerror (rc));
@@ -504,26 +507,32 @@ rtems_rfs_write_root_dir (const char* name)
(RTEMS_RFS_S_IFDIR | RTEMS_RFS_S_IRWXU |
RTEMS_RFS_S_IXGRP | RTEMS_RFS_S_IXOTH),
0, 0);
- if (rc > 0)
+ if (rc != 0)
printf ("rtems-rfs: format: inode initialise failed: %d: %s\n",
rc, strerror (rc));
rc = rtems_rfs_dir_add_entry (fs, &inode, ".", 1, ino);
- if (rc > 0)
+ if (rc != 0)
printf ("rtems-rfs: format: directory add failed: %d: %s\n",
rc, strerror (rc));
rc = rtems_rfs_inode_close (fs, &inode);
- if (rc > 0)
+ if (rc != 0)
printf ("rtems-rfs: format: inode close failed: %d: %s\n",
rc, strerror (rc));
rc = rtems_rfs_fs_close (fs);
- if (rc < 0)
+ if (rc != 0)
+ {
+ rc = errno;
+
printf ("rtems-rfs: format: file system close failed: %d: %s\n",
- errno, strerror (errno));
+ rc, strerror (rc));
+
+ return rc;
+ }
- return rc;
+ return 0;
}
int
@@ -554,10 +563,12 @@ rtems_rfs_format (const char* name, const rtems_rfs_format_config* config)
* Open the buffer interface.
*/
rc = rtems_rfs_buffer_open (name, &fs);
- if (rc > 0)
+ if (rc != 0)
{
printf ("rtems-rfs: format: buffer open failed: %d: %s\n",
rc, strerror (rc));
+
+ errno = rc;
return -1;
}
@@ -568,6 +579,8 @@ rtems_rfs_format (const char* name, const rtems_rfs_format_config* config)
{
printf ("rtems-rfs: media block is invalid: %" PRIu32 "\n",
rtems_rfs_fs_media_block_size (&fs));
+
+ errno = EINVAL;
return -1;
}
@@ -575,7 +588,10 @@ rtems_rfs_format (const char* name, const rtems_rfs_format_config* config)
* Check the configuration data.
*/
if (!rtems_rfs_check_config (&fs, config))
+ {
+ errno = EINVAL;
return -1;
+ }
if (config->verbose)
{
@@ -604,40 +620,51 @@ rtems_rfs_format (const char* name, const rtems_rfs_format_config* config)
}
rc = rtems_rfs_buffer_setblksize (&fs, rtems_rfs_fs_block_size (&fs));
- if (rc > 0)
+ if (rc != 0)
{
printf ("rtems-rfs: format: setting block size failed: %d: %s\n",
rc, strerror (rc));
+
+ errno = rc;
return -1;
}
if (!rtems_rfs_write_superblock (&fs))
{
printf ("rtems-rfs: format: superblock write failed\n");
+
+ errno = EIO;
return -1;
}
for (group = 0; group < fs.group_count; group++)
if (!rtems_rfs_write_group (&fs, group,
config->initialise_inodes, config->verbose))
- return -1;
+ {
+ errno = EIO;
+ return -1;
+ }
if (config->verbose)
printf ("\n");
rc = rtems_rfs_buffer_close (&fs);
- if (rc > 0)
+ if (rc != 0)
{
printf ("rtems-rfs: format: buffer close failed: %d: %s\n",
rc, strerror (rc));
+
+ errno = rc;
return -1;
}
rc = rtems_rfs_write_root_dir (name);
- if (rc > 0)
+ if (rc != 0)
{
printf ("rtems-rfs: format: writing root dir failed: %d: %s\n",
rc, strerror (rc));
+
+ errno = rc;
return -1;
}
More information about the vc
mailing list