mirror of
https://github.com/Dasharo/zephyr.git
synced 2026-03-06 14:57:20 -08:00
tests/sprintf: Remove tests with NULL FILE pointer
The C language says that use of a NULL FILE pointer with stdio functions is undefined behavior. Let's just remove them instead of expecting the minimal C library to exhibit a specific behavior in this case. This also avoids problems when not using -ffreestanding as in that case, the C compiler may generate warnings, or even cause undefined behavior on its own. Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
committed by
Christopher Friedt
parent
25b2db74e0
commit
1a830e2af6
@@ -791,10 +791,6 @@ ZTEST(sprintf, test_fprintf)
|
||||
ret = fprintf(stdout, "");
|
||||
zassert_equal(ret, 0, "fprintf failed!");
|
||||
|
||||
#if !defined(CONFIG_PICOLIBC) && !defined(CONFIG_ARMCLANG_STD_LIBC) /* this is UB */
|
||||
ret = fprintf(NULL, "%d", i);
|
||||
zassert_equal(ret, EOF, "fprintf failed!");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -823,10 +819,6 @@ ZTEST(sprintf, test_vfprintf)
|
||||
ret = WriteFrmtd_vf(stdout, "11\n");
|
||||
zassert_equal(ret, 3, "vfprintf \"11\" failed");
|
||||
|
||||
#ifndef CONFIG_PICOLIBC /* this is UB */
|
||||
ret = WriteFrmtd_vf(NULL, "This %d", 3);
|
||||
zassert_equal(ret, EOF, "vfprintf \"This 3\" failed");
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -883,30 +875,15 @@ ZTEST(sprintf, test_put)
|
||||
ret = fputs("This 3\n", stderr);
|
||||
zassert_equal(ret, 0, "fputs \"This 3\" failed");
|
||||
|
||||
#if !defined(CONFIG_PICOLIBC) && !defined(CONFIG_ARMCLANG_STD_LIBC) /* this is UB */
|
||||
ret = fputs("This 3", NULL);
|
||||
zassert_equal(ret, EOF, "fputs \"This 3\" failed");
|
||||
#endif
|
||||
|
||||
ret = puts("This 3");
|
||||
zassert_equal(ret, 0, "puts \"This 3\" failed");
|
||||
|
||||
ret = fputc('T', stdout);
|
||||
zassert_equal(ret, 84, "fputc \'T\' failed");
|
||||
|
||||
#if !defined(CONFIG_PICOLIBC) && !defined(CONFIG_ARMCLANG_STD_LIBC) /* this is UB */
|
||||
ret = fputc('T', NULL);
|
||||
zassert_equal(ret, EOF, "fputc \'T\' failed");
|
||||
#endif
|
||||
|
||||
ret = putc('T', stdout);
|
||||
zassert_equal(ret, 84, "putc \'T\' failed");
|
||||
|
||||
#if !defined(CONFIG_PICOLIBC) && !defined(CONFIG_ARMCLANG_STD_LIBC) /* this is UB */
|
||||
ret = putc('T', NULL);
|
||||
zassert_equal(ret, EOF, "putc \'T\' failed");
|
||||
#endif
|
||||
|
||||
ret = fputc('T', stderr);
|
||||
zassert_equal(ret, 84, "fputc \'T\' failed");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user