ioengine fixes
cover ioengine fixes
From: Tomohiro Kusumi <[email protected]>
Tomohiro Kusumi (6):
sg: add missing free(msg); in ->errdetails() handler
sg: drop unneeded strdup from ->errdetails() handler
sg: drop redundant void* cast
sg: don't use void* for pointer arithmetic (gcc)
splice: don't use void* for pointer arithmetic (gcc)
binject: don't use void* for pointer arithmetic (gcc)
engines/binject.c | 3 ++- engines/sg.c | 16 ++++++++-------- engines/splice.c | 5 +++-- 3 files changed, 13 insertions(+), 11 deletions(-)
Signature · 1 line
2.9.4
PATCH 1/6 sg: add missing free(msg); in ->errdetails() handler
From: Tomohiro Kusumi <[email protected]>
msg gets malloc'd unconditionally, so we need to free msg if we're not using msg for ret (strdup isn't really needed here to begin with).
--- engines/sg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
engines/sg.c +3 -1
@@ -759,8 +759,10 @@ static char *fio_sgio_errdetails(struct io_u *io_u) } } -if (!ret) +if (!ret) { ret =strdup ("SG Driver did not report a Host, Driver or Device check" ); +free (msg); + }return ret; }
Signature · 1 line
2.9.4
PATCH 2/6 sg: drop unneeded strdup from ->errdetails() handler
In reply to [email protected]From: Tomohiro Kusumi <[email protected]>
*ret as well as strdup aren't really necessary, but only make the code complicated as shown in the previous commit. No functional change.
This commit includes reverting of the previous commit.
--- engines/sg.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
engines/sg.c +6 -8
@@ -572,17 +572,17 @@ static char *fio_sgio_errdetails(struct io_u *io_u)struct sg_io_hdr *hdr = &io_u->hdr;#define MAXERRDETAIL 1024#define MAXMSGCHUNK 128 -char *msg, msgchunk[MAXMSGCHUNK ], *ret =NULL ; +char *msg, msgchunk[MAXMSGCHUNK ];int i; msg =calloc (1 ,MAXERRDETAIL ); +strcpy (msg,"" );/* * can't seem to find sg_err.h, so I'll just echo the define values * so others can search on internet to find clearer clues of meaning. */ if (hdr->info &SG_INFO_CHECK ) { - ret = msg;if (hdr->host_status) {snprintf (msgchunk,MAXMSGCHUNK ,"SG Host Status: 0x%02x; " , hdr->host_status);strlcat (msg, msgchunk,MAXERRDETAIL );
@@ -755,16 +755,14 @@ static char *fio_sgio_errdetails(struct io_u *io_u)if (hdr->resid !=0 ) {snprintf (msgchunk,MAXMSGCHUNK ,"SG Driver: %d bytes out of %d not transferred. " , hdr->resid, hdr->dxfer_len);strlcat (msg, msgchunk,MAXERRDETAIL ); - ret = msg; } } -if (!ret) { - ret =strdup ("SG Driver did not report a Host, Driver or Device check" ); -free (msg); - } +if (!(hdr->info &SG_INFO_CHECK ) && !strlen (msg)) +strncpy (msg,"SG Driver did not report a Host, Driver or Device check" , +MAXERRDETAIL -1 ); -return ret; +return msg; }/*
Signature · 1 line
2.9.4
PATCH 3/6 sg: drop redundant void* cast
In reply to [email protected]From: Tomohiro Kusumi <[email protected]>
No need to cast to void*.
This is the only void* cast for memcpy(3) in the entire fio.
--- engines/sg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
engines/sg.c +1 -1
@@ -184,7 +184,7 @@ re_read:if (hdr->info &SG_INFO_CHECK ) {struct io_u *io_u; io_u = (struct io_u *)(hdr->usr_ptr); -memcpy ((void *)&(io_u->hdr), (void *)hdr,sizeof (struct sg_io_hdr )); +memcpy (&io_u->hdr, hdr,sizeof (struct sg_io_hdr )); sd->events[i]->error =EIO ; } }
Signature · 1 line
2.9.4
PATCH 4/6 sg: don't use void* for pointer arithmetic (gcc)
In reply to [email protected]From: Tomohiro Kusumi <[email protected]>
I think gcc extension should be avoided when it can be done by just changing a pointer type.
--- engines/sg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
engines/sg.c +1 -1
@@ -124,7 +124,7 @@ static int fio_sgio_getevents(struct thread_data *td, unsigned int min, }while (left) { -void *p; +char *p;dprint (FD_IO ,"sgio_getevents: sd %p: left=%d\n" , sd, left);
Signature · 1 line
2.9.4
PATCH 5/6 splice: don't use void* for pointer arithmetic (gcc)
In reply to [email protected]From: Tomohiro Kusumi <[email protected]>
I think gcc extension should be avoided when it can be done by just changing a pointer type.
--- engines/splice.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
engines/splice.c +3 -2
@@ -32,7 +32,7 @@ static int fio_splice_read_old(struct thread_data *td, struct io_u *io_u)struct fio_file *f = io_u->file;int ret, ret2, buflen;off_t offset; -void *p; +char *p; offset = io_u->offset; buflen = io_u->xfer_buflen;
@@ -77,7 +77,8 @@ static int fio_splice_read(struct thread_data *td, struct io_u *io_u)struct iovec iov;int ret , buflen, mmap_len;off_t offset; -void *p, *map; +void *map; +char *p; ret =0 ; offset = io_u->offset;
Signature · 1 line
2.9.4
PATCH 6/6 binject: don't use void* for pointer arithmetic (gcc)
In reply to [email protected]From: Tomohiro Kusumi <[email protected]>
I think gcc extension should be avoided when it can be done by just changing a pointer type.
--- engines/binject.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
engines/binject.c +2 -1
@@ -59,11 +59,12 @@ static int pollin_events(struct pollfd *pfds, int fds)return 0 ; } -static unsigned int binject_read_commands (struct thread_data *td,void *p, +static unsigned int binject_read_commands (struct thread_data *td,void *buf,int left,int *err) {struct fio_file *f;int i, ret, events; +char *p = buf; one_more: events =0 ;
Signature · 1 line
2.9.4
Jens Axboe
AppliedQuoted 10 lines · On 06/12/2017 02:02 PM, [email protected] wrote:
From: Tomohiro Kusumi <[email protected]>
Tomohiro Kusumi (6):
sg: add missing free(msg); in ->errdetails() handler
sg: drop unneeded strdup from ->errdetails() handler
sg: drop redundant void* cast
sg: don't use void* for pointer arithmetic (gcc)
splice: don't use void* for pointer arithmetic (gcc)
binject: don't use void* for pointer arithmetic (gcc)
Thanks, applied. Patch 1+2 could have been squashed, but not a big deal.
Signature · 1 line
Jens Axboe