aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2021-05-03 05:26:48 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2021-05-03 05:26:48 +0000
commitb2d08c24d50a7b1ff3b30f6a5c34cb4e5a155326 (patch)
treea6ac3874718c32f5f075bc4b56d461909c42a4dc
parent1b551c7b147d0ed75a841e09d61d39cff1d57a4a (diff)
downloadsg3_utils-b2d08c24d50a7b1ff3b30f6a5c34cb4e5a155326.tar.gz
sg_ses: On Windows fix 'No command (cdb) given'
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@898 6180dd3e-e324-4e3e-922d-17de1ae2f315
-rw-r--r--ChangeLog3
-rw-r--r--lib/sg_pt_win32.c16
2 files changed, 15 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 5a5e0c2f..56e4435c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,8 +2,9 @@ Each utility has its own version number, date of last change and
some description at the top of its ".c" file. All utilities in the main
directory have their own "man" pages. There is also a sg3_utils man page.
-Changelog for pre-release sg3_utils-1.47 [20210502] [svn: r897]
+Changelog for pre-release sg3_utils-1.47 [20210503] [svn: r898]
- sg_raw: fix prints of NVMe NVM command names
+ - sg_ses: fix Windows problem "No command (cdb) given"
- sg_lib: add sg_scsi_status_is_good()
- pt_linux: fix verify(BytChk=0) which Linux SNTL translated
to write, other SNTL cleanups
diff --git a/lib/sg_pt_win32.c b/lib/sg_pt_win32.c
index cc56a26d..4ed4a0ad 100644
--- a/lib/sg_pt_win32.c
+++ b/lib/sg_pt_win32.c
@@ -929,7 +929,17 @@ get_scsi_pt_cdb_buf(const struct sg_pt_base * vp)
{
const struct sg_pt_win32_scsi * psp = vp->implp;
- return (uint8_t *)(spt_direct ? psp->swb_d.spt.Cdb : psp->swb_i.spt.Cdb);
+ if (spt_direct) {
+ if (psp->swb_d.spt.CdbLength > 0)
+ return (uint8_t *)(psp->swb_d.spt.Cdb);
+ else
+ return NULL;
+ } else {
+ if (psp->swb_i.spt.CdbLength > 0)
+ return (uint8_t *)(psp->swb_i.spt.Cdb);
+ else
+ return NULL;
+ }
}
void
@@ -1051,7 +1061,7 @@ scsi_pt_direct(struct sg_pt_win32_scsi * psp, struct sg_pt_handle * shp,
psp->os_err = 0;
if (0 == psp->swb_d.spt.CdbLength) {
if (vb)
- pr2ws("No command (cdb) given\n");
+ pr2ws("%s: No command (cdb) given\n", __func__);
return SCSI_PT_DO_BAD_PARAMS;
}
psp->swb_d.spt.Length = sizeof (SCSI_PASS_THROUGH_DIRECT);
@@ -1127,7 +1137,7 @@ scsi_pt_indirect(struct sg_pt_base * vp, struct sg_pt_handle * shp,
if (0 == psp->swb_i.spt.CdbLength) {
if (vb)
- pr2ws("No command (cdb) given\n");
+ pr2ws("%s: No command (cdb) given\n", __func__);
return SCSI_PT_DO_BAD_PARAMS;
}
if (psp->dxfer_len > (int)sizeof(psp->swb_i.ucDataBuf)) {