mirror of https://github.com/ARMmbed/mbed-os.git
STORAGE: compiler warning fixes.
parent
860d7f03f2
commit
c877fb6287
|
@ -56,10 +56,6 @@
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
/* FIXME: unistd.h needed for fsfat_basic_test_04 but this error is generated:
|
|
||||||
* [Error] unistd.h@185,10: conflicting declaration of C function 'unsigned int sleep(unsigned int)'
|
|
||||||
* #include <unistd.h> // STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO
|
|
||||||
*/
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -80,8 +76,6 @@ using namespace utest::v1;
|
||||||
* #define FSFAT_SDCARD_INSTALLED
|
* #define FSFAT_SDCARD_INSTALLED
|
||||||
* #define DEVICE_SPI
|
* #define DEVICE_SPI
|
||||||
*/
|
*/
|
||||||
#define FSFAT_SDCARD_INSTALLED
|
|
||||||
#define DEVICE_SPI
|
|
||||||
#if defined(DEVICE_SPI) && defined(FSFAT_SDCARD_INSTALLED)
|
#if defined(DEVICE_SPI) && defined(FSFAT_SDCARD_INSTALLED)
|
||||||
|
|
||||||
#define FSFAT_BASIC_TEST_00 fsfat_basic_test_00
|
#define FSFAT_BASIC_TEST_00 fsfat_basic_test_00
|
||||||
|
@ -420,40 +414,18 @@ static control_t fsfat_basic_test_02()
|
||||||
|
|
||||||
/** @brief temptest.c test ported from glibc project. See the licence at REF_LICENCE_GLIBC.
|
/** @brief temptest.c test ported from glibc project. See the licence at REF_LICENCE_GLIBC.
|
||||||
*
|
*
|
||||||
* WARNING: this test does not currently work. See WARNING comments below.
|
* tmpnam() is currently not implemented
|
||||||
*
|
*
|
||||||
* @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
|
* @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
|
||||||
*/
|
*/
|
||||||
static control_t fsfat_basic_test_03()
|
static control_t fsfat_basic_test_03()
|
||||||
{
|
{
|
||||||
char *fn = NULL;
|
char *fn = NULL;
|
||||||
FILE *fp = NULL;
|
|
||||||
char *files[500];
|
|
||||||
int i;
|
|
||||||
|
|
||||||
FSFAT_FENTRYLOG("%s:entered\n", __func__);
|
FSFAT_FENTRYLOG("%s:entered\n", __func__);
|
||||||
memset(files, 0, 500*sizeof(char*));
|
fn = tmpnam((char *) NULL);
|
||||||
for (i = 0; i < 500; i++) {
|
FSFAT_BASIC_MSG(fsfat_basic_msg_g, FSFAT_BASIC_MSG_BUF_SIZE, "%s: Error: appeared to generate a filename when function is not implemented.\n", __func__);
|
||||||
fn = tmpnam((char *) NULL);
|
TEST_ASSERT_MESSAGE(fn == NULL, fsfat_basic_msg_g);
|
||||||
|
|
||||||
/* FIXME: tmpnam() doesnt currently generate a temporary filename
|
|
||||||
* re-instate the code below when it does.
|
|
||||||
FSFAT_BASIC_MSG(fsfat_basic_msg_g, FSFAT_BASIC_MSG_BUF_SIZE, "%s: Error: failed to generate a temporary filename.\n", __func__);
|
|
||||||
TEST_ASSERT_MESSAGE(fn != NULL, fsfat_basic_msg_g);
|
|
||||||
|
|
||||||
files[i] = strdup(fn);
|
|
||||||
FSFAT_DBGLOG("%s:filename=%s\n", __func__, fn);
|
|
||||||
fp = fopen (fn, "w");
|
|
||||||
fclose(fp);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < 500; i++) {
|
|
||||||
if(files[i] != NULL) {
|
|
||||||
remove(files[i]);
|
|
||||||
free(files[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,6 +448,20 @@ static bool fsfat_basic_fileno_check(const char *name, FILE *stream, int fd)
|
||||||
#endif /* TOOLCHAIN_ARM_STD */
|
#endif /* TOOLCHAIN_ARM_STD */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* defines for next test case */
|
||||||
|
#ifndef STDIN_FILENO
|
||||||
|
#define STDIN_FILENO 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef STDOUT_FILENO
|
||||||
|
#define STDOUT_FILENO 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef STDERR_FILENO
|
||||||
|
#define STDERR_FILENO 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/** @brief tst-fileno.c test ported from glibc project. See the licence at REF_LICENCE_GLIBC.
|
/** @brief tst-fileno.c test ported from glibc project. See the licence at REF_LICENCE_GLIBC.
|
||||||
*
|
*
|
||||||
* WARNING: this test does not currently work. See WARNING comments below.
|
* WARNING: this test does not currently work. See WARNING comments below.
|
||||||
|
@ -485,8 +471,6 @@ static bool fsfat_basic_fileno_check(const char *name, FILE *stream, int fd)
|
||||||
*/
|
*/
|
||||||
static control_t fsfat_basic_test_04()
|
static control_t fsfat_basic_test_04()
|
||||||
{
|
{
|
||||||
/* FIXME: unistd.h needed for STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO but this error is generated:
|
|
||||||
* [Error] unistd.h@185,10: conflicting declaration of C function 'unsigned int sleep(unsigned int)'
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
ret = fsfat_basic_fileno_check("stdin", stdin, STDIN_FILENO);
|
ret = fsfat_basic_fileno_check("stdin", stdin, STDIN_FILENO);
|
||||||
FSFAT_BASIC_MSG(fsfat_basic_msg_g, FSFAT_BASIC_MSG_BUF_SIZE, "%s: Error: stdin does not have expected file number (expected=%d, fileno=%d.\n", __func__, stdin, fileno(stdin));
|
FSFAT_BASIC_MSG(fsfat_basic_msg_g, FSFAT_BASIC_MSG_BUF_SIZE, "%s: Error: stdin does not have expected file number (expected=%d, fileno=%d.\n", __func__, stdin, fileno(stdin));
|
||||||
|
@ -499,7 +483,7 @@ static control_t fsfat_basic_test_04()
|
||||||
ret = fsfat_basic_fileno_check("stderr", stderr, STDERR_FILENO);
|
ret = fsfat_basic_fileno_check("stderr", stderr, STDERR_FILENO);
|
||||||
FSFAT_BASIC_MSG(fsfat_basic_msg_g, FSFAT_BASIC_MSG_BUF_SIZE, "%s: Error: stderr does not have expected file number (expected=%d, fileno=%d.\n", __func__, stderr, fileno(stderr));
|
FSFAT_BASIC_MSG(fsfat_basic_msg_g, FSFAT_BASIC_MSG_BUF_SIZE, "%s: Error: stderr does not have expected file number (expected=%d, fileno=%d.\n", __func__, stderr, fileno(stderr));
|
||||||
TEST_ASSERT_MESSAGE(ret == true, fsfat_basic_msg_g);
|
TEST_ASSERT_MESSAGE(ret == true, fsfat_basic_msg_g);
|
||||||
*/
|
//*/
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,10 +519,10 @@ Case cases[] = {
|
||||||
/* 1234567890123456789012345678901234567890123456789012345678901234567890 */
|
/* 1234567890123456789012345678901234567890123456789012345678901234567890 */
|
||||||
Case("FSFAT_BASIC_TEST_00: fopen()/fgetc()/fprintf()/fclose() test.", FSFAT_BASIC_TEST_00),
|
Case("FSFAT_BASIC_TEST_00: fopen()/fgetc()/fprintf()/fclose() test.", FSFAT_BASIC_TEST_00),
|
||||||
Case("FSFAT_BASIC_TEST_01: fopen()/fseek()/fclose() test.", FSFAT_BASIC_TEST_01),
|
Case("FSFAT_BASIC_TEST_01: fopen()/fseek()/fclose() test.", FSFAT_BASIC_TEST_01),
|
||||||
|
Case("FSFAT_BASIC_TEST_03: tmpnam() test.", FSFAT_BASIC_TEST_03),
|
||||||
|
Case("FSFAT_BASIC_TEST_04: fileno() test.", FSFAT_BASIC_TEST_04),
|
||||||
/* WARNING: Test case not working but currently not required for PAL support
|
/* WARNING: Test case not working but currently not required for PAL support
|
||||||
* Case("FSFAT_BASIC_TEST_02: fopen()/fgets()/fputs()/ftell()/rewind()/remove() test.", FSFAT_BASIC_TEST_02)
|
* Case("FSFAT_BASIC_TEST_02: fopen()/fgets()/fputs()/ftell()/rewind()/remove() test.", FSFAT_BASIC_TEST_02)
|
||||||
* Case("FSFAT_BASIC_TEST_03: tmpnam() test.", FSFAT_BASIC_TEST_03)
|
|
||||||
* Case("FSFAT_BASIC_TEST_04: fileno() test.", FSFAT_BASIC_TEST_04)
|
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -65,8 +65,6 @@ using namespace utest::v1;
|
||||||
* #define FSFAT_SDCARD_INSTALLED
|
* #define FSFAT_SDCARD_INSTALLED
|
||||||
* #define DEVICE_SPI
|
* #define DEVICE_SPI
|
||||||
*/
|
*/
|
||||||
#define FSFAT_SDCARD_INSTALLED
|
|
||||||
#define DEVICE_SPI
|
|
||||||
#if defined(DEVICE_SPI) && defined(FSFAT_SDCARD_INSTALLED)
|
#if defined(DEVICE_SPI) && defined(FSFAT_SDCARD_INSTALLED)
|
||||||
|
|
||||||
static char fsfat_fopen_utest_msg_g[FSFAT_UTEST_MSG_BUF_SIZE];
|
static char fsfat_fopen_utest_msg_g[FSFAT_UTEST_MSG_BUF_SIZE];
|
||||||
|
@ -511,7 +509,7 @@ control_t fsfat_fopen_test_03(const size_t call_count)
|
||||||
|
|
||||||
/* clean-up */
|
/* clean-up */
|
||||||
ret = remove(fsfat_fopen_test_02_data[0].filename);
|
ret = remove(fsfat_fopen_test_02_data[0].filename);
|
||||||
FSFAT_TEST_UTEST_MESSAGE(fsfat_fopen_utest_msg_g, FSFAT_UTEST_MSG_BUF_SIZE, "%s:Error: unable to delete file (filename=%s, ret=%d) .\n", __func__, (int) ret);
|
FSFAT_TEST_UTEST_MESSAGE(fsfat_fopen_utest_msg_g, FSFAT_UTEST_MSG_BUF_SIZE, "%s:Error: unable to delete file (filename=%s, ret=%d) .\n", __func__, fsfat_fopen_test_02_data[0].filename, (int) ret);
|
||||||
TEST_ASSERT_MESSAGE(ret >= 0, fsfat_fopen_utest_msg_g);
|
TEST_ASSERT_MESSAGE(ret >= 0, fsfat_fopen_utest_msg_g);
|
||||||
|
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
|
@ -873,7 +871,6 @@ control_t fsfat_fopen_test_08(const size_t call_count)
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int ret_ferror = -1;
|
int ret_ferror = -1;
|
||||||
char *filename = (char*) "/sd/test.txt";
|
char *filename = (char*) "/sd/test.txt";
|
||||||
int errno_val = 0;
|
|
||||||
|
|
||||||
FSFAT_FENTRYLOG("%s:entered\n", __func__);
|
FSFAT_FENTRYLOG("%s:entered\n", __func__);
|
||||||
(void) call_count;
|
(void) call_count;
|
||||||
|
@ -897,14 +894,11 @@ control_t fsfat_fopen_test_08(const size_t call_count)
|
||||||
/* Perform fwrite() operation that will fail. */
|
/* Perform fwrite() operation that will fail. */
|
||||||
errno = 0;
|
errno = 0;
|
||||||
ret = fwrite("42!", 4, 1, fp);
|
ret = fwrite("42!", 4, 1, fp);
|
||||||
/* Store errno so the current value set is not changed by new function call */
|
|
||||||
errno_val = errno;
|
|
||||||
|
|
||||||
ret_ferror = ferror(fp);
|
ret_ferror = ferror(fp);
|
||||||
FSFAT_TEST_UTEST_MESSAGE(fsfat_fopen_utest_msg_g, FSFAT_UTEST_MSG_BUF_SIZE, "%s:Error: ferror() failed to report error (filename=%s, ret_ferror=%d).\n", __func__, filename, (int) ret_ferror);
|
FSFAT_TEST_UTEST_MESSAGE(fsfat_fopen_utest_msg_g, FSFAT_UTEST_MSG_BUF_SIZE, "%s:Error: ferror() failed to report error (filename=%s, ret_ferror=%d).\n", __func__, filename, (int) ret_ferror);
|
||||||
TEST_ASSERT_MESSAGE(ret_ferror != 0, fsfat_fopen_utest_msg_g);
|
TEST_ASSERT_MESSAGE(ret_ferror != 0, fsfat_fopen_utest_msg_g);
|
||||||
|
|
||||||
FSFAT_DBGLOG("%s:b ret=%d, errno=%d, errno_val=%d, ret_ferror=%d\n", __func__, (int) ret, errno, errno_val, ret_ferror);
|
|
||||||
FSFAT_TEST_UTEST_MESSAGE(fsfat_fopen_utest_msg_g, FSFAT_UTEST_MSG_BUF_SIZE, "%s:Error: fwrite successfully wrote to read-only file (filename=%s, ret=%d).\n", __func__, filename, (int) ret);
|
FSFAT_TEST_UTEST_MESSAGE(fsfat_fopen_utest_msg_g, FSFAT_UTEST_MSG_BUF_SIZE, "%s:Error: fwrite successfully wrote to read-only file (filename=%s, ret=%d).\n", __func__, filename, (int) ret);
|
||||||
/* the fwrite() should fail and return 0. */
|
/* the fwrite() should fail and return 0. */
|
||||||
TEST_ASSERT_MESSAGE(ret == 0, fsfat_fopen_utest_msg_g);
|
TEST_ASSERT_MESSAGE(ret == 0, fsfat_fopen_utest_msg_g);
|
||||||
|
@ -1186,7 +1180,6 @@ static fsfat_kv_data_t fsfat_fopen_test_20_kv_data[] = {
|
||||||
control_t fsfat_fopen_test_20(const size_t call_count)
|
control_t fsfat_fopen_test_20(const size_t call_count)
|
||||||
{
|
{
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
FILE *fp = NULL;
|
|
||||||
|
|
||||||
FSFAT_DBGLOG("%s:entered\n", __func__);
|
FSFAT_DBGLOG("%s:entered\n", __func__);
|
||||||
(void) call_count;
|
(void) call_count;
|
||||||
|
|
Loading…
Reference in New Issue