diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2020-12-02 14:12:24 +0100 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2020-12-02 14:12:56 +0100 |
commit | 702bec7bc9e903500dcfe9e5a572c35b8bd0fa46 (patch) | |
tree | ebc341b567b4b5ff5753972a073dd26160d9d852 /winsup/testsuite | |
parent | 80e35a211f69f23fa57003a08d1758657364f00e (diff) | |
download | newlib-702bec7bc9e903500dcfe9e5a572c35b8bd0fa46.zip newlib-702bec7bc9e903500dcfe9e5a572c35b8bd0fa46.tar.gz newlib-702bec7bc9e903500dcfe9e5a572c35b8bd0fa46.tar.bz2 |
Cygwin: testsuite: libltp: fix warnings showing up with -Wall
This libltp is old as old dirt and still using K&R style.
If it's really to be used again at all, it needs a serious
refresh.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/testsuite')
-rw-r--r-- | winsup/testsuite/libltp/lib/databin.c | 2 | ||||
-rw-r--r-- | winsup/testsuite/libltp/lib/search_path.c | 5 | ||||
-rw-r--r-- | winsup/testsuite/libltp/lib/tst_tmpdir.c | 6 | ||||
-rw-r--r-- | winsup/testsuite/libltp/lib/write_log.c | 18 |
4 files changed, 19 insertions, 12 deletions
diff --git a/winsup/testsuite/libltp/lib/databin.c b/winsup/testsuite/libltp/lib/databin.c index f09c2c8..e43fef4 100644 --- a/winsup/testsuite/libltp/lib/databin.c +++ b/winsup/testsuite/libltp/lib/databin.c @@ -98,12 +98,10 @@ char **errmsg; { int cnt; unsigned char *chr; - int total; long expbits; long actbits; chr=buffer; - total=bsize; if ( errmsg != NULL ) { *errmsg = Errmsg; diff --git a/winsup/testsuite/libltp/lib/search_path.c b/winsup/testsuite/libltp/lib/search_path.c index 775c7b1..697b403 100644 --- a/winsup/testsuite/libltp/lib/search_path.c +++ b/winsup/testsuite/libltp/lib/search_path.c @@ -50,6 +50,9 @@ #include <sys/param.h> #include <sys/stat.h> +#pragma GCC diagnostic ignored "-Wformat-overflow" +#pragma GCC diagnostic ignored "-Wformat-truncation" + extern int errno; struct stat stbuf; @@ -221,7 +224,7 @@ printf("search_path: res_path = '%s'\n", res_path); toolong++; continue; } - sprintf(tmppath, "%s/%s", curpath, res_path); + snprintf(tmppath, sizeof tmppath, "%s/%s", curpath, res_path); strcpy(res_path, tmppath); #if DEBUG printf("search_path: full res_path= '%s'\n", res_path); diff --git a/winsup/testsuite/libltp/lib/tst_tmpdir.c b/winsup/testsuite/libltp/lib/tst_tmpdir.c index cd9d9c8..064861e 100644 --- a/winsup/testsuite/libltp/lib/tst_tmpdir.c +++ b/winsup/testsuite/libltp/lib/tst_tmpdir.c @@ -69,6 +69,9 @@ #include "test.h" #include "rmobj.h" +#pragma GCC diagnostic ignored "-Wformat-overflow" +#pragma GCC diagnostic ignored "-Wformat-truncation" + /* * Define some useful macros. */ @@ -259,7 +262,8 @@ tst_rmdir() if ( getcwd(current_dir,PATH_MAX) == NULL ) strcpy(parent_dir, TESTDIR); else - sprintf(parent_dir, "%s/%s", current_dir, TESTDIR); + snprintf(parent_dir, sizeof parent_dir, + "%s/%s", current_dir, TESTDIR); } else { strcpy(parent_dir, TESTDIR); } diff --git a/winsup/testsuite/libltp/lib/write_log.c b/winsup/testsuite/libltp/lib/write_log.c index 316dfe7..8104b05 100644 --- a/winsup/testsuite/libltp/lib/write_log.c +++ b/winsup/testsuite/libltp/lib/write_log.c @@ -90,7 +90,7 @@ /*#define PATH_MAX pathconf("/", _PC_PATH_MAX)*/ #endif -char Wlog_Error_String[256]; +char Wlog_Error_String[2048]; #if __STDC__ static int wlog_rec_pack(struct wlog_rec *wrec, char *buf, int flag); @@ -137,7 +137,7 @@ int mode; umask(omask); if (wfile->w_afd == -1) { - sprintf(Wlog_Error_String, + snprintf(Wlog_Error_String, sizeof Wlog_Error_String, "Could not open write_log - open(%s, %#o, %#o) failed: %s\n", wfile->w_file, oflags, mode, strerror(errno)); return -1; @@ -149,7 +149,7 @@ int mode; oflags = O_RDWR; if ((wfile->w_rfd = open(wfile->w_file, oflags)) == -1) { - sprintf(Wlog_Error_String, + snprintf(Wlog_Error_String, sizeof Wlog_Error_String, "Could not open write log - open(%s, %#o) failed: %s\n", wfile->w_file, oflags, strerror(errno)); close(wfile->w_afd); @@ -255,8 +255,9 @@ int nrecs; int (*func)(); long data; { - int fd, leftover, nbytes, offset, recnum, reclen, rval; - char buf[BSIZE*32], *bufend, *cp, *bufstart; + int fd, leftover, nbytes, recnum, reclen, rval; + off_t offset; + char buf[BSIZE*32], *bufend, *cp, *bufstart; char albuf[WLOG_REC_MAX_SIZE]; struct wlog_rec wrec; @@ -295,9 +296,10 @@ long data; nbytes = read(fd, bufstart, bufend - bufstart - leftover); if (nbytes == -1) { - sprintf(Wlog_Error_String, - "Could not read history file at offset %d - read(%d, %#o, %d) failed: %s\n", - offset, fd, (int)bufstart, + snprintf(Wlog_Error_String, sizeof Wlog_Error_String, + "Could not read history file at offset %jd - " + "read(%d, %#to, %td) failed: %s\n", + (intmax_t)offset, fd, (ptrdiff_t)bufstart, bufend - bufstart - leftover, strerror(errno)); return -1; } |