Fix the many warnings that gcc 9 spits out.
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
{
unsigned int len;
- len = strlen(string);
- if (len > sizeof(lexer_input_buffer) - 3)
- len = sizeof(lexer_input_buffer) - 3;
+ len = sizeof(lexer_input_buffer) - 3;
+ if (len > strlen(string))
+ len = strlen(string);
strncpy(lexer_input_buffer, string, len);
lexer_input_buffer[len] = '\0';
continue;
fm = calloc(1, sizeof(*fm));
- strncpy(fm->__base, buf, sizeof(fm->__base) - 1);
+ strncpy(fm->__base, buf, sizeof(fm->__base));
+ fm->__base[255] = '\0';
fm->base = basename(fm->__base);
fm->key = sb.st_dev;
flist_add(&fm->list, &list);
int recursed, int client_type)
{
unsigned int i;
- char fname[PATH_MAX];
+ char fname[PATH_MAX + 1];
int numjobs, file_alloced;
struct thread_options *o = &td->o;
char logname[PATH_MAX + 32];
strncpy(full_fn,
file, (ts - file) + 1);
strncpy(full_fn + (ts - file) + 1,
- filename, strlen(filename));
+ filename,
+ len - (ts - file) - 1);
full_fn[len - 1] = 0;
filename = full_fn;
}
memset(&p, 0, sizeof(p));
- strncpy(p.ts.name, ts->name, FIO_JOBNAME_SIZE - 1);
- strncpy(p.ts.verror, ts->verror, FIO_VERROR_SIZE - 1);
- strncpy(p.ts.description, ts->description, FIO_JOBDESC_SIZE - 1);
+ strncpy(p.ts.name, ts->name, FIO_JOBNAME_SIZE);
+ p.ts.name[FIO_JOBNAME_SIZE - 1] = '\0';
+ strncpy(p.ts.verror, ts->verror, FIO_VERROR_SIZE);
+ p.ts.verror[FIO_VERROR_SIZE - 1] = '\0';
+ strncpy(p.ts.description, ts->description, FIO_JOBDESC_SIZE);
+ p.ts.description[FIO_JOBDESC_SIZE - 1] = '\0';
p.ts.error = cpu_to_le32(ts->error);
p.ts.thread_number = cpu_to_le32(ts->thread_number);