From 60e8cd430ecab7773106233473cc5ffadcbb2e39 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 13 Dec 2012 09:58:33 +0100 Subject: dosfs: Fix error status handling --- cpukit/libfs/src/dosfs/msdos_format.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/cpukit/libfs/src/dosfs/msdos_format.c b/cpukit/libfs/src/dosfs/msdos_format.c index 9e9d234270..0bf3f398ef 100644 --- a/cpukit/libfs/src/dosfs/msdos_format.c +++ b/cpukit/libfs/src/dosfs/msdos_format.c @@ -384,14 +384,14 @@ static int msdos_format_eval_sectors_per_cluster } } while (!finished); - if (ret_val != 0) { - rtems_set_errno_and_return_minus_one(ret_val); - } - *sectors_per_cluster_adj = sectors_per_cluster; *sectors_per_fat_ptr = fat_sectors_cnt / fat_num; - return 0; + if (ret_val != 0) { + errno = EINVAL; + } + + return ret_val; } static uint8_t @@ -445,6 +445,11 @@ msdos_set_sectors_per_cluster_from_request( } } } + + if (ret_val != 0) { + errno = EINVAL; + } + return ret_val; } @@ -529,7 +534,8 @@ static int msdos_format_determine_fmt_params fmt_params->fat_num = rqdata->fat_num; } else { - ret_val = EINVAL; + errno = EINVAL; + ret_val = -1; } } @@ -715,7 +721,10 @@ static int msdos_format_determine_fmt_params } } if ( fmt_params->totl_sector_cnt == 0 ) - ret_val = EINVAL; + { + errno = EINVAL; + ret_val = -1; + } if (0 == ret_val) { @@ -843,12 +852,7 @@ static int msdos_format_determine_fmt_params /* * Phuuu.... That's it. */ - if (ret_val != 0) { - rtems_set_errno_and_return_minus_one(ret_val); - } - else { - return 0; - } + return ret_val; } /*=========================================================================*\ @@ -1029,7 +1033,6 @@ int msdos_format \*=========================================================================*/ { char tmp_sec[FAT_TOTAL_MBR_SIZE]; - int rc; struct stat stat_buf; int ret_val = 0; int fd = -1; @@ -1051,8 +1054,7 @@ int msdos_format msdos_format_printf (rqdata, MSDOS_FMT_INFO_LEVEL_DETAIL, "stat check: %s\n", devname); if (ret_val == 0) { - rc = fstat(fd, &stat_buf); - ret_val = rc; + ret_val = fstat(fd, &stat_buf); } msdos_format_printf (rqdata, MSDOS_FMT_INFO_LEVEL_INFO, -- cgit v1.2.3