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>
This commit is contained in:
Corinna Vinschen 2020-12-02 14:12:24 +01:00
parent 80e35a211f
commit 702bec7bc9
4 changed files with 19 additions and 12 deletions

View 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;

View 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);

View 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);
}

View 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;
}