Skip to content

Commit

Permalink
Fix string copy compilation warnings
Browse files Browse the repository at this point in the history
Fix the many warnings that gcc 9 spits out.

Signed-off-by: Damien Le Moal <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
damien-lemoal authored and axboe committed Jun 4, 2019
1 parent 971341a commit 32e31c8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
6 changes: 3 additions & 3 deletions exp/expression-parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ static void setup_to_parse_string(const char *string)
{
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';
Expand Down
3 changes: 2 additions & 1 deletion filesetup.c
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,8 @@ static unsigned long long get_fs_free_counts(struct thread_data *td)
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);
Expand Down
5 changes: 3 additions & 2 deletions init.c
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num,
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];
Expand Down Expand Up @@ -2040,7 +2040,8 @@ static int __parse_jobs_ini(struct thread_data *td,
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;
}
Expand Down
9 changes: 6 additions & 3 deletions server.c
Original file line number Diff line number Diff line change
Expand Up @@ -1470,9 +1470,12 @@ void fio_server_send_ts(struct thread_stat *ts, struct group_run_stats *rs)

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);
Expand Down

0 comments on commit 32e31c8

Please sign in to comment.