]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: testsuite: libltp: fix warnings showing up with -Wall
authorCorinna Vinschen <corinna@vinschen.de>
Wed, 2 Dec 2020 13:12:24 +0000 (14:12 +0100)
committerCorinna Vinschen <corinna@vinschen.de>
Wed, 2 Dec 2020 13:12:56 +0000 (14:12 +0100)
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>
winsup/testsuite/libltp/lib/databin.c
winsup/testsuite/libltp/lib/search_path.c
winsup/testsuite/libltp/lib/tst_tmpdir.c
winsup/testsuite/libltp/lib/write_log.c

index f09c2c86c7f17f72445009cdbd805a0e3bbb446b..e43fef4e464db1e6b9847864d690dde32ee4fce8 100644 (file)
@@ -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;
index 775c7b1a6bc789fec409ade45d26428590905665..697b4037b2b93edeaa746dab06526f7aa2046dcf 100644 (file)
@@ -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);
index cd9d9c8b827914ab4de3a842465f1e61d0cbe1cb..064861e56ee81d103b99ae638ad92a3d0960efef 100644 (file)
@@ -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);
    }
index 316dfe79b62c7c414396ee90c29b2c70226fda2a..8104b05acdf54555481eeea346013fd627636fe6 100644 (file)
@@ -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;
                }
This page took 0.037453 seconds and 5 git commands to generate.