zsh-workers
 help / color / mirror / code / Atom feed
From: Wesley Schwengle <wesleyschwengle@gmail.com>
To: zsh-workers@zsh.org
Cc: Wesley Schwengle <wesley@schwengle.net>
Subject: [PATCH] Change handrolled strftime to strftime in zftp.c
Date: Sat, 23 Mar 2019 11:11:35 +0100	[thread overview]
Message-ID: <20190323101135.14344-2-wesley@mintlab.nl> (raw)
In-Reply-To: <20190323101135.14344-1-wesley@mintlab.nl>

From: Wesley Schwengle <wesley@schwengle.net>

Compiling zsh on Debian testing/unstable with cc (Debian 8.3.0-2) 8.3.0
emits a -Wformat-overflow= warning on line 1265 in zftp.c. Replace the
code with strftime() resolves it.

Signed-off-by: Wesley Schwengle <wesley@schwengle.net>
---
 Src/Modules/zftp.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/Src/Modules/zftp.c b/Src/Modules/zftp.c
index 4aaa1f072..e0789216a 100644
--- a/Src/Modules/zftp.c
+++ b/Src/Modules/zftp.c
@@ -1257,14 +1257,7 @@ zfstats(char *fnam, int remote, off_t *retsize, char **retmdtm, int fd)
 	if (retmdtm) {
 	    /* use gmtime() rather than localtime() for consistency */
 	    tm = gmtime(&statbuf.st_mtime);
-	    /*
-	     * FTP format for data is YYYYMMDDHHMMSS
-	     * Using tm directly is easier than worrying about
-	     * incompatible strftime()'s.
-	     */
-	    sprintf(tmbuf, "%04d%02d%02d%02d%02d%02d",
-		    tm->tm_year + 1900, tm->tm_mon+1, tm->tm_mday,
-		    tm->tm_hour, tm->tm_min, tm->tm_sec);
+	    strftime(tmbuf, 15, "%Y%m%d%H%M%S", tm);
 	    mt = ztrdup(tmbuf);
 	}
     }
-- 
2.21.0.196.g041f5ea1cf


  reply	other threads:[~2019-03-23 10:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-23 10:11 [PATCH 0/1] Fix -Wformat-overflow= warnings " Wesley Schwengle
2019-03-23 10:11 ` Wesley Schwengle [this message]
2019-03-25 12:13   ` [PATCH] Change handrolled strftime to strftime " Jun T
2019-03-25 12:42     ` Peter Stephenson
2019-03-25 13:07       ` Jun T.
2019-03-25 13:32         ` Jun T.
2019-03-25 14:36         ` Peter Stephenson
2019-03-25 15:06           ` Jun T.
2019-03-25 15:08           ` Peter Stephenson

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=20190323101135.14344-2-wesley@mintlab.nl \
    --to=wesleyschwengle@gmail.com \
    --cc=wesley@schwengle.net \
    --cc=zsh-workers@zsh.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).