[PATCH 6/6] libc/stdio: Conditionally declare vars for _FSEEK_OPTIMIZATION
Keith Packard
keithp@keithp.com
Thu Aug 20 22:14:49 GMT 2020
Both versions of fseek declare locals used only with
_FSEEK_OPTIMIZATION unconditionally which causes clang to emit a
warning. Protect those declarations with an #ifdef
Signed-off-by: Keith Packard <keithp@keithp.com>
---
newlib/libc/stdio/fseeko.c | 6 ++++--
newlib/libc/stdio64/fseeko64.c | 7 +++++--
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/newlib/libc/stdio/fseeko.c b/newlib/libc/stdio/fseeko.c
index 13df28bfc..0394cf183 100644
--- a/newlib/libc/stdio/fseeko.c
+++ b/newlib/libc/stdio/fseeko.c
@@ -99,14 +99,16 @@ _fseeko_r (struct _reent *ptr,
int whence)
{
_fpos_t (*seekfn) (struct _reent *, void *, _fpos_t, int);
+#ifdef _FSEEK_OPTIMIZATION
_fpos_t target;
- _fpos_t curoff = 0;
size_t n;
#ifdef __USE_INTERNAL_STAT64
struct stat64 st;
#else
struct stat st;
#endif
+#endif
+ _fpos_t curoff = 0;
int havepos;
/* Make sure stdio is set up. */
@@ -327,9 +329,9 @@ _fseeko_r (struct _reent *ptr,
* We get here if we cannot optimise the seek ... just
* do it. Allow the seek function to change fp->_bf._base.
*/
+dumb:
#endif
-dumb:
if (_fflush_r (ptr, fp)
|| seekfn (ptr, fp->_cookie, offset, whence) == POS_ERR)
{
diff --git a/newlib/libc/stdio64/fseeko64.c b/newlib/libc/stdio64/fseeko64.c
index 3087bef9e..1ee26750c 100644
--- a/newlib/libc/stdio64/fseeko64.c
+++ b/newlib/libc/stdio64/fseeko64.c
@@ -91,8 +91,11 @@ _fseeko64_r (struct _reent *ptr,
int whence)
{
_fpos64_t (*seekfn) (struct _reent *, void *, _fpos64_t, int);
- _fpos64_t target, curoff;
+ _fpos64_t curoff;
+#if _FSEEK_OPTIMIZATION
+ _fpos64_t target;
size_t n;
+#endif
struct stat64 st;
int havepos;
@@ -318,9 +321,9 @@ _fseeko64_r (struct _reent *ptr,
* We get here if we cannot optimise the seek ... just
* do it. Allow the seek function to change fp->_bf._base.
*/
+dumb:
#endif
-dumb:
if (_fflush_r (ptr, fp)
|| seekfn (ptr, fp->_cookie, offset, whence) == POS_ERR)
{
--
2.28.0
More information about the Newlib
mailing list