X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=engines%2Fsg.c;h=833d9205470075c9d2d0354fc67981bb7e88449e;hb=be660713de581921b71ea7b76a664f360884c205;hp=9d339bd345554e671395e9c96fc13c66c0c14dab;hpb=b63fe8bec4c7f5defe6b6842b4d251ecc67add60;p=fio.git diff --git a/engines/sg.c b/engines/sg.c index 9d339bd3..833d9205 100644 --- a/engines/sg.c +++ b/engines/sg.c @@ -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,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; } /*