X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=engines%2Fsg.c;h=4540b57354cd1c1d02e84faa429cd6e069aa376c;hp=2148e87c190f8c1dfc4f648aecb99796888ca777;hb=6b86fc18e13d1c8f36b24c409f4c7653508c7f85;hpb=861e3790be5f1e22b16e827b142147e530205441 diff --git a/engines/sg.c b/engines/sg.c index 2148e87c..4540b573 100644 --- a/engines/sg.c +++ b/engines/sg.c @@ -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); @@ -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; } } @@ -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,14 +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"); + 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; } /*