From: Keith Packard <keithp@keithp.com>
To: newlib@sourceware.org
Subject: [PATCH 6/6] libc/stdio: Conditionally declare vars for _FSEEK_OPTIMIZATION
Date: Thu, 20 Aug 2020 15:14:49 -0700 [thread overview]
Message-ID: <20200820221449.686006-7-keithp@keithp.com> (raw)
In-Reply-To: <20200820221449.686006-1-keithp@keithp.com>
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
prev parent reply other threads:[~2020-08-20 22:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-20 22:14 [PATCH 0/6] Fixes inspired by building with clang Keith Packard
2020-08-20 22:14 ` [PATCH 1/6] libm/stdlib: Recover from realloc failure when shrinking Keith Packard
2020-08-20 22:14 ` [PATCH 2/6] libc/iconv: Check ces handlers table value in euc_from_ucs_init Keith Packard
2020-08-20 22:14 ` [PATCH 3/6] Avoid implicit floating point conversions Keith Packard
2020-08-20 22:43 ` Joseph Myers
[not found] ` <SN5P110MB03830A3D8272D82A089605659A5A0@SN5P110MB0383.NAMP110.PROD.OUTLOOK.COM>
2020-08-20 23:03 ` Fw: " C Howland
2020-08-21 0:01 ` Keith Packard
2020-08-20 22:14 ` [PATCH 4/6] libc/stdlib: Undefined shift negative value in a64l Keith Packard
2020-08-20 22:14 ` [PATCH 5/6] libc/stdlib: Clean up clang warnings Keith Packard
2020-08-20 22:14 ` Keith Packard [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200820221449.686006-7-keithp@keithp.com \
--to=keithp@keithp.com \
--cc=newlib@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).