aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2016-04-05 03:18:04 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2016-04-05 03:18:04 +0000
commit63a8ecf3099475c7560036054dae728a1869685e (patch)
tree25077d46b98c0231e960624e7fea47dc7257f167
parent61a0b017ebca98eca9c5d85264af45b3eb1853e5 (diff)
downloadsg3_utils-63a8ecf3099475c7560036054dae728a1869685e.tar.gz
clang --analyze static checker clean ups
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@689 6180dd3e-e324-4e3e-922d-17de1ae2f315
-rw-r--r--ChangeLog3
-rw-r--r--doc/sg_safte.818
-rw-r--r--lib/Makefile.am5
-rw-r--r--lib/Makefile.in3
-rw-r--r--lib/sg_cmds_mmc.c14
-rw-r--r--lib/sg_io_linux.c15
-rw-r--r--lib/sg_lib.c30
-rw-r--r--src/Makefile.am1
-rw-r--r--src/Makefile.in1
-rw-r--r--src/sg_copy_results.c5
-rw-r--r--src/sg_dd.c4
-rw-r--r--src/sg_decode_sense.c10
-rw-r--r--src/sg_get_config.c320
-rw-r--r--src/sg_inq.c4
-rw-r--r--src/sg_inq_data.c2
-rw-r--r--src/sg_logs.c1392
-rw-r--r--src/sg_map26.c6
-rw-r--r--src/sg_modes.c184
-rw-r--r--src/sg_read.c1
-rw-r--r--src/sg_read_attr.c18
-rw-r--r--src/sg_read_buffer.c18
-rw-r--r--src/sg_reassign.c1
-rw-r--r--src/sg_referrals.c1
-rw-r--r--src/sg_safte.c11
-rw-r--r--src/sg_scan_linux.c13
-rw-r--r--src/sg_senddiag.c27
-rw-r--r--src/sg_ses.c16
-rw-r--r--src/sg_start.c1
-rw-r--r--src/sg_vpd.c85
-rw-r--r--src/sg_write_same.c1
-rw-r--r--src/sg_xcopy.c53
-rw-r--r--src/sginfo.c12
-rw-r--r--src/sgm_dd.c2
-rw-r--r--src/sgp_dd.c1
34 files changed, 1150 insertions, 1128 deletions
diff --git a/ChangeLog b/ChangeLog
index 158a6aa2..bdd6ba5e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,7 @@ 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 sg3_utils-1.43 [20160401] [svn: r688]
+Changelog for sg3_utils-1.43 [20160404] [svn: r689]
- sg_senddiag: add --timeout=SEC option
- sg_sanitize: add --timeout=SEC option
- sg_format: add --timeout=SEC option
@@ -23,6 +23,7 @@ Changelog for sg3_utils-1.43 [20160401] [svn: r688]
- sg_lib: add SSC maintenance in/out sa names
- add read buffer(16) mode names
- rescan-scsi-bus.sh: harden code
+ - clang --analyze static checker clean ups
- shellcheck cleanup on scripts
- automake: add AM_PROG_AR to configure.ac
diff --git a/doc/sg_safte.8 b/doc/sg_safte.8
index 48c7e620..0b9c43e6 100644
--- a/doc/sg_safte.8
+++ b/doc/sg_safte.8
@@ -1,4 +1,4 @@
-.TH SG_SAFTE "8" "November 2012" "sg3_utils\-1.35" SG3_UTILS
+.TH SG_SAFTE "8" "April 2016" "sg3_utils\-1.43" SG3_UTILS
.SH NAME
sg_safte \- access SCSI Accessed Fault\-Tolerant Enclosure (SAF\-TE) device
.SH SYNOPSIS
@@ -96,15 +96,15 @@ increase the level of verbosity, (i.e. debug output).
\fB\-V\fR, \fB\-\-version\fR
print the version string and then exit.
.SH NOTES
-The implementation is based on the intermediate review document eg as
-found at
+This implementation is based on the intermediate review document dated
+19970414 and named "SR041497.pdf". So it is quite old. Intel and nStor
+are the authors. Intel have a zip archive containing this and related
+documents in the "SAF\-TE: SCSI Accessed Fault Tolerant Enclosures
+Interface Specification" section of this page:
.PP
-http://www.intel.com/design/servers/ipmi/saf\-te.htm
+http://www.intel.com/content/www/us/en/servers/ipmi/ipmi\-technical\-resources.html
.PP
-As the specification was never finalized this document serves as the
-de\-facto standard.
-.PP
-Similar functionality is provided by SPC\-4 SCSI Enclosure Services
+Similar functionality is provided by SPC\-4 SCSI Enclosure Services (SES)
devices (Peripheral device type 0xd), which can be queried with the
sg_ses utility.
.SH EXAMPLES
@@ -124,7 +124,7 @@ Written by Hannes Reinecke and Douglas Gilbert.
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
-Copyright \(co 2004\-2012 Hannes Reinecke and Douglas Gilbert
+Copyright \(co 2004\-2016 Hannes Reinecke and Douglas Gilbert
.br
This software is distributed under a FreeBSD license. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/lib/Makefile.am b/lib/Makefile.am
index c8ab0ccd..e72e5fca 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -37,14 +37,15 @@ endif
## CC = gcc
## CC = g++
## CC = clang
-## CC = clang++
+## CC = clang++-3.7
# -std=<s> can be c99, c11, gnu11, etc. Default is gnu89 (gnu90 is the same)
# -Wall is no longer all warnings. Add -W (since renamed to -Wextra) for more
AM_CPPFLAGS = -iquote ${top_srcdir}/include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
AM_CFLAGS = -Wall -W
# AM_CFLAGS = -Wall -W -pedantic -std=c11
-# AM_CFLAGS = -Wall -W -pedantic -std=c++11
+# AM_CFLAGS = -Wall -W -pedantic -std=c11 --analyze
+# AM_CFLAGS = -Wall -W -pedantic -std=c++14 --analyze
lib_LTLIBRARIES = libsgutils2.la
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 942ad8b4..5cbc591d 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -352,7 +352,8 @@ libsgutils2_la_SOURCES = sg_lib.c sg_lib_data.c sg_cmds_basic.c \
AM_CPPFLAGS = -iquote ${top_srcdir}/include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
AM_CFLAGS = -Wall -W
# AM_CFLAGS = -Wall -W -pedantic -std=c11
-# AM_CFLAGS = -Wall -W -pedantic -std=c++11
+# AM_CFLAGS = -Wall -W -pedantic -std=c11 --analyze
+# AM_CFLAGS = -Wall -W -pedantic -std=c++14 --analyze
lib_LTLIBRARIES = libsgutils2.la
libsgutils2_la_LDFLAGS = -version-info 2:0:0 -no-undefined
libsgutils2_la_LIBADD = @GETOPT_O_FILES@ @os_libs@
diff --git a/lib/sg_cmds_mmc.c b/lib/sg_cmds_mmc.c
index 3dab6e7b..65c909e8 100644
--- a/lib/sg_cmds_mmc.c
+++ b/lib/sg_cmds_mmc.c
@@ -194,13 +194,13 @@ sg_ll_get_config(int sg_fd, int rt, int starting, void * resp,
if (len < 0)
len = 0;
len = (ret < len) ? ret : len;
- pr2ws(" get configuration: response");
+ pr2ws(" get configuration: response:\n");
if (3 == verbose) {
- pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
- dStrHexErr((const char *)resp, (ret > 256 ? 256 : ret), -1);
+ pr2ws("%s:\n", (len > 256 ? ", first 256 bytes" : ""));
+ dStrHexErr((const char *)resp, (len > 256 ? 256 : len), -1);
} else {
pr2ws(":\n");
- dStrHexErr((const char *)resp, ret, 0);
+ dStrHexErr((const char *)resp, len, 0);
}
}
ret = 0;
@@ -289,11 +289,11 @@ sg_ll_get_performance(int sg_fd, int data_type, unsigned int starting_lba,
len = (ret < len) ? ret : len;
pr2ws(" get performance:: response");
if (3 == verbose) {
- pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
- dStrHexErr((const char *)resp, (ret > 256 ? 256 : ret), -1);
+ pr2ws("%s:\n", (len > 256 ? ", first 256 bytes" : ""));
+ dStrHexErr((const char *)resp, (len > 256 ? 256 : len), -1);
} else {
pr2ws(":\n");
- dStrHexErr((const char *)resp, ret, 0);
+ dStrHexErr((const char *)resp, len, 0);
}
}
ret = 0;
diff --git a/lib/sg_io_linux.c b/lib/sg_io_linux.c
index e8d4778d..ec6d1775 100644
--- a/lib/sg_io_linux.c
+++ b/lib/sg_io_linux.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999-2015 Douglas Gilbert.
+ * Copyright (c) 1999-2016 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
@@ -8,6 +8,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
+#include <stdbool.h>
#include <string.h>
#include <ctype.h>
@@ -119,8 +120,8 @@ sg_linux_sense_print(const char * leadin, int scsi_status, int host_status,
int driver_status, const unsigned char * sense_buffer,
int sb_len, int raw_sinfo)
{
- int done_leadin = 0;
- int done_sense = 0;
+ bool done_leadin = false;
+ bool done_sense = false;
scsi_status &= 0x7e; /*sanity */
if ((0 == scsi_status) && (0 == host_status) && (0 == driver_status))
@@ -128,7 +129,7 @@ sg_linux_sense_print(const char * leadin, int scsi_status, int host_status,
if (0 != scsi_status) {
if (leadin)
pr2ws("%s: ", leadin);
- done_leadin = 1;
+ done_leadin = true;
pr2ws("SCSI status: ");
sg_print_scsi_status(scsi_status);
pr2ws("\n");
@@ -136,7 +137,7 @@ sg_linux_sense_print(const char * leadin, int scsi_status, int host_status,
(scsi_status == SAM_STAT_COMMAND_TERMINATED))) {
/* SAM_STAT_COMMAND_TERMINATED is obsolete */
sg_print_sense(0, sense_buffer, sb_len, raw_sinfo);
- done_sense = 1;
+ done_sense = true;
}
}
if (0 != host_status) {
@@ -145,7 +146,7 @@ sg_linux_sense_print(const char * leadin, int scsi_status, int host_status,
if (done_leadin)
pr2ws("plus...: ");
else
- done_leadin = 1;
+ done_leadin = true;
sg_print_host_status(host_status);
pr2ws("\n");
}
@@ -157,8 +158,6 @@ sg_linux_sense_print(const char * leadin, int scsi_status, int host_status,
pr2ws("%s: ", leadin);
if (done_leadin)
pr2ws("plus...: ");
- else
- done_leadin = 1;
sg_print_driver_status(driver_status);
pr2ws("\n");
if (sense_buffer && (! done_sense) &&
diff --git a/lib/sg_lib.c b/lib/sg_lib.c
index 496e19de..4dcfbb6d 100644
--- a/lib/sg_lib.c
+++ b/lib/sg_lib.c
@@ -255,8 +255,8 @@ sg_get_asc_ascq_str(int asc, int ascq, int buff_len, char * buff)
found = true;
num = my_snprintf(buff, buff_len, "Additional sense: ");
rlen = buff_len - num;
- num += my_snprintf(buff + num, ((rlen > 0) ? rlen : 0),
- ei2p->text, ascq);
+ my_snprintf(buff + num, ((rlen > 0) ? rlen : 0), ei2p->text,
+ ascq);
}
}
if (found)
@@ -1434,8 +1434,8 @@ sg_get_sense_str(const char * leadin, const unsigned char * sense_buffer,
{
int len, progress, n, r, pr, rem, blen;
unsigned int info;
- int descriptor_format = 0;
- int sdat_ovfl = 0;
+ bool descriptor_format = false;
+ bool sdat_ovfl = false;
bool valid;
const char * ebp = NULL;
char error_buff[64];
@@ -1465,24 +1465,24 @@ sg_get_sense_str(const char * leadin, const unsigned char * sense_buffer,
ebp = "Fixed format, current";
len = (sb_len > 7) ? (sense_buffer[7] + 8) : sb_len;
len = (len > sb_len) ? sb_len : len;
- sdat_ovfl = (len > 2) ? !!(sense_buffer[2] & 0x10) : 0;
+ sdat_ovfl = (len > 2) ? !!(sense_buffer[2] & 0x10) : false;
break;
case 0x71: /* fixed, deferred */
/* error related to a previous command */
ebp = "Fixed format, <<<deferred>>>";
len = (sb_len > 7) ? (sense_buffer[7] + 8) : sb_len;
len = (len > sb_len) ? sb_len : len;
- sdat_ovfl = (len > 2) ? !!(sense_buffer[2] & 0x10) : 0;
+ sdat_ovfl = (len > 2) ? !!(sense_buffer[2] & 0x10) : false;
break;
case 0x72: /* descriptor, current */
- descriptor_format = 1;
+ descriptor_format = true;
ebp = "Descriptor format, current";
- sdat_ovfl = (sb_len > 4) ? !!(sense_buffer[4] & 0x80) : 0;
+ sdat_ovfl = (sb_len > 4) ? !!(sense_buffer[4] & 0x80) : false;
break;
case 0x73: /* descriptor, deferred */
- descriptor_format = 1;
+ descriptor_format = true;
ebp = "Descriptor format, <<<deferred>>>";
- sdat_ovfl = (sb_len > 4) ? !!(sense_buffer[4] & 0x80) : 0;
+ sdat_ovfl = (sb_len > 4) ? !!(sense_buffer[4] & 0x80) : false;
break;
case 0x0:
ebp = "Response code: 0x0 (?)";
@@ -1624,8 +1624,8 @@ sg_get_sense_str(const char * leadin, const unsigned char * sense_buffer,
((sense_buffer[0] >> 4) & 0x7),
(sense_buffer[0] & 0xf));
if (sense_buffer[0] & 0x80)
- r += my_snprintf(b + r, blen - r, "%s lba=0x%x\n", lip,
- sg_get_unaligned_be24(sense_buffer + 1) & 0x1fffff);
+ my_snprintf(b + r, blen - r, "%s lba=0x%x\n", lip,
+ sg_get_unaligned_be24(sense_buffer + 1) & 0x1fffff);
n += my_snprintf(buff + n, buff_len - n, "%s\n", b);
len = sb_len;
if (len > 32)
@@ -2441,7 +2441,8 @@ sg_get_num(const char * buf)
char * cp;
const char * b;
char c = 'c';
- char c2, c3;
+ char c2 = '\0'; /* keep static checker happy */
+ char c3 = '\0'; /* keep static checker happy */
char lb[16];
if ((NULL == buf) || ('\0' == buf[0]))
@@ -2576,7 +2577,8 @@ sg_get_llnum(const char * buf)
char * cp;
const char * b;
char c = 'c';
- char c2, c3;
+ char c2 = '\0'; /* keep static checker happy */
+ char c3 = '\0'; /* keep static checker happy */
char lb[32];
if ((NULL == buf) || ('\0' == buf[0]))
diff --git a/src/Makefile.am b/src/Makefile.am
index 0fbf84ec..e840a28a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -44,6 +44,7 @@ endif
AM_CPPFLAGS = -iquote ${top_srcdir}/include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
AM_CFLAGS = -Wall -W @os_cflags@
# AM_CFLAGS = -Wall -W @os_cflags@ -pedantic -std=c11
+# AM_CFLAGS = -Wall -W @os_cflags@ -pedantic -std=c11 --analyze
# AM_CFLAGS = -Wall -W @os_cflags@ -pedantic -std=c++11
sg_compare_and_write_LDADD = ../lib/libsgutils2.la @os_libs@
diff --git a/src/Makefile.in b/src/Makefile.in
index cc268d28..8980c7b8 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -560,6 +560,7 @@ sg_scan_SOURCES = $(am__append_2) $(am__append_4) $(am__append_6)
AM_CPPFLAGS = -iquote ${top_srcdir}/include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
AM_CFLAGS = -Wall -W @os_cflags@
# AM_CFLAGS = -Wall -W @os_cflags@ -pedantic -std=c11
+# AM_CFLAGS = -Wall -W @os_cflags@ -pedantic -std=c11 --analyze
# AM_CFLAGS = -Wall -W @os_cflags@ -pedantic -std=c++11
sg_compare_and_write_LDADD = ../lib/libsgutils2.la @os_libs@
sg_copy_results_LDADD = ../lib/libsgutils2.la @os_libs@
diff --git a/src/sg_copy_results.c b/src/sg_copy_results.c
index 1f490d07..235ca616 100644
--- a/src/sg_copy_results.c
+++ b/src/sg_copy_results.c
@@ -432,25 +432,20 @@ main(int argc, char * argv[])
}
if (1 == do_hex) {
dStrHex((const char *)cpResultBuff, xfer_len, 1);
- res = 0;
goto finish;
}
switch (sa) {
case 4: /* Failed segment details */
scsi_failed_segment_details(cpResultBuff, xfer_len);
- res = 0;
break;
case 3: /* Operating parameters */
scsi_operating_parameters(cpResultBuff, xfer_len);
- res = 0;
break;
case 0: /* Copy status */
scsi_copy_status(cpResultBuff, xfer_len);
- res = 0;
break;
default:
dStrHex((const char *)cpResultBuff, xfer_len, 1);
- res = 0;
break;
}
diff --git a/src/sg_dd.c b/src/sg_dd.c
index b0370a5a..834e89b0 100644
--- a/src/sg_dd.c
+++ b/src/sg_dd.c
@@ -336,7 +336,7 @@ dd_filetype_str(int ft, char * buff)
if (FT_OTHER & ft)
off += snprintf(buff + off, 32, "other (perhaps ordinary file) ");
if (FT_ERROR & ft)
- off += snprintf(buff + off, 32, "unable to 'stat' file ");
+ snprintf(buff + off, 32, "unable to 'stat' file ");
return buff;
}
@@ -673,7 +673,7 @@ sg_read_low(int sg_fd, unsigned char * buff, int blocks, int64_t from_block,
(0x64 == ssh.asc) && (0x0 == ssh.ascq)) {
if (sg_get_sense_filemark_eom_ili(sbp, slen, NULL, NULL,
&ili) && ili) {
- info_valid = sg_get_sense_info_fld(sbp, slen, io_addrp);
+ sg_get_sense_info_fld(sbp, slen, io_addrp);
if (*io_addrp > 0) {
++unrecovered_errs;
return SG_LIB_CAT_MEDIUM_HARD_WITH_INFO;
diff --git a/src/sg_decode_sense.c b/src/sg_decode_sense.c
index d8d8dfd2..5dfb8c3d 100644
--- a/src/sg_decode_sense.c
+++ b/src/sg_decode_sense.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2015 Douglas Gilbert.
+ * Copyright (c) 2010-2016 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
@@ -26,7 +26,7 @@
#include "sg_pr2serr.h"
-static const char * version_str = "1.08 20151219";
+static const char * version_str = "1.09 20160403";
#define MAX_SENSE_LEN 1024 /* max descriptor format actually: 256+8 */
@@ -369,12 +369,18 @@ write2wfn(FILE * fp, struct opts_t * optsp)
if (15 == (k % 16)) {
b[n] = '\n';
s = fwrite(b, 1, n + 1, fp);
+ if ((int)s != (n + 1))
+ pr2serr("only able to write %d of %d bytes to %s\n",
+ (int)s, n + 1);
n = 0;
}
}
if (n > 0) {
b[n] = '\n';
s = fwrite(b, 1, n + 1, fp);
+ if ((int)s != (n + 1))
+ pr2serr("only able to write %d of %d bytes to %s\n", (int)s,
+ n + 1);
}
} else {
s = fwrite(optsp->sense, 1, optsp->sense_len, fp);
diff --git a/src/sg_get_config.c b/src/sg_get_config.c
index 2e20a6b4..4f9bfc3c 100644
--- a/src/sg_get_config.c
+++ b/src/sg_get_config.c
@@ -241,35 +241,34 @@ dStrRaw(const char * str, int len)
}
static void
-decode_feature(int feature, unsigned char * ucp, int len)
+decode_feature(int feature, unsigned char * bp, int len)
{
int k, num, n, profile;
char buff[128];
const char * cp;
- cp = "";
switch (feature) {
case 0: /* Profile list */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 2), !!(ucp[2] & 1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 2), !!(bp[2] & 1),
feature);
printf(" available profiles [more recent typically higher "
"in list]:\n");
for (k = 4; k < len; k += 4) {
- profile = sg_get_unaligned_be16(ucp + k);
+ profile = sg_get_unaligned_be16(bp + k);
printf(" profile: %s , currentP=%d\n",
- get_profile_str(profile, buff), !!(ucp[k + 2] & 1));
+ get_profile_str(profile, buff), !!(bp[k + 2] & 1));
}
break;
case 1: /* Core */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 2), !!(ucp[2] & 1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 2), !!(bp[2] & 1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
- num = sg_get_unaligned_be32(ucp + 4);
+ num = sg_get_unaligned_be32(bp + 4);
switch (num) {
case 0: cp = "unspecified"; break;
case 1: cp = "SCSI family"; break;
@@ -288,30 +287,29 @@ decode_feature(int feature, unsigned char * ucp, int len)
}
printf(" Physical interface standard: %s", cp);
if (len > 8)
- printf(", INQ2=%d, DBE=%d\n", !!(ucp[8] & 2), !!(ucp[8] & 1));
+ printf(", INQ2=%d, DBE=%d\n", !!(bp[8] & 2), !!(bp[8] & 1));
else
printf("\n");
break;
case 2: /* Morphing */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 2), !!(ucp[2] & 1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 2), !!(bp[2] & 1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
- printf(" OCEvent=%d, ASYNC=%d\n", !!(ucp[4] & 2),
- !!(ucp[4] & 1));
+ printf(" OCEvent=%d, ASYNC=%d\n", !!(bp[4] & 2), !!(bp[4] & 1));
break;
case 3: /* Removable medium */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 2), !!(ucp[2] & 1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 2), !!(bp[2] & 1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
- num = (ucp[4] >> 5) & 0x7;
+ num = (bp[4] >> 5) & 0x7;
switch (num) {
case 0: cp = "Caddy/slot type"; break;
case 1: cp = "Tray type"; break;
@@ -326,31 +324,31 @@ decode_feature(int feature, unsigned char * ucp, int len)
}
printf(" Loading mechanism: %s\n", cp);
printf(" Load=%d, Eject=%d, Prevent jumper=%d, Lock=%d\n",
- !!(ucp[4] & 0x10), !!(ucp[4] & 0x8), !!(ucp[4] & 0x4),
- !!(ucp[4] & 0x1));
+ !!(bp[4] & 0x10), !!(bp[4] & 0x8), !!(bp[4] & 0x4),
+ !!(bp[4] & 0x1));
break;
case 4: /* Write protect */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
- printf(" DWP=%d, WDCB=%d, SPWP=%d, SSWPP=%d\n", !!(ucp[4] & 0x8),
- !!(ucp[4] & 0x4), !!(ucp[4] & 0x2), !!(ucp[4] & 0x1));
+ printf(" DWP=%d, WDCB=%d, SPWP=%d, SSWPP=%d\n", !!(bp[4] & 0x8),
+ !!(bp[4] & 0x4), !!(bp[4] & 0x2), !!(bp[4] & 0x1));
break;
case 0x10: /* Random readable */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 12) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
- num = sg_get_unaligned_be32(ucp + 4);
+ num = sg_get_unaligned_be32(bp + 4);
printf(" Logical block size=0x%x, blocking=0x%x, PP=%d\n",
- num, sg_get_unaligned_be16(ucp + 8), !!(ucp[10] & 0x1));
+ num, sg_get_unaligned_be16(bp + 8), !!(bp[10] & 0x1));
break;
case 0x1d: /* Multi-read */
case 0x22: /* Sector erasable */
@@ -364,247 +362,247 @@ decode_feature(int feature, unsigned char * ucp, int len)
case 0x110: /* VCPS */
case 0x113: /* SecurDisc */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
break;
case 0x1e: /* CD read */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
- printf(" DAP=%d, C2 flags=%d, CD-Text=%d\n", !!(ucp[4] & 0x80),
- !!(ucp[4] & 0x2), !!(ucp[4] & 0x1));
+ printf(" DAP=%d, C2 flags=%d, CD-Text=%d\n", !!(bp[4] & 0x80),
+ !!(bp[4] & 0x2), !!(bp[4] & 0x1));
break;
case 0x1f: /* DVD read */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len > 7)
printf(" MULTI110=%d, Dual-RW=%d, Dual-R=%d\n",
- !!(ucp[4] & 0x1), !!(ucp[6] & 0x2), !!(ucp[6] & 0x1));
+ !!(bp[4] & 0x1), !!(bp[6] & 0x2), !!(bp[6] & 0x1));
break;
case 0x20: /* Random writable */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 16) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
- num = sg_get_unaligned_be32(ucp + 4);
- n = sg_get_unaligned_be32(ucp + 8);
+ num = sg_get_unaligned_be32(bp + 4);
+ n = sg_get_unaligned_be32(bp + 8);
printf(" Last lba=0x%x, Logical block size=0x%x, blocking=0x%x,"
- " PP=%d\n", num, n, sg_get_unaligned_be16(ucp + 12),
- !!(ucp[14] & 0x1));
+ " PP=%d\n", num, n, sg_get_unaligned_be16(bp + 12),
+ !!(bp[14] & 0x1));
break;
case 0x21: /* Incremental streaming writable */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
printf(" Data block types supported=0x%x, TRIO=%d, ARSV=%d, "
- "BUF=%d\n", sg_get_unaligned_be16(ucp + 4), !!(ucp[6] & 0x4),
- !!(ucp[6] & 0x2), !!(ucp[6] & 0x1));
- num = ucp[7];
+ "BUF=%d\n", sg_get_unaligned_be16(bp + 4), !!(bp[6] & 0x4),
+ !!(bp[6] & 0x2), !!(bp[6] & 0x1));
+ num = bp[7];
printf(" Number of link sizes=%d\n", num);
for (k = 0; k < num; ++k)
- printf(" %d\n", ucp[8 + k]);
+ printf(" %d\n", bp[8 + k]);
break;
/* case 0x22: Sector erasable -> see 0x1d entry */
case 0x23: /* Formattable */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len > 4)
printf(" BD-RE: RENoSA=%d, Expand=%d, QCert=%d, Cert=%d, "
- "FRF=%d\n", !!(ucp[4] & 0x8), !!(ucp[4] & 0x4),
- !!(ucp[4] & 0x2), !!(ucp[4] & 0x1), !!(ucp[5] & 0x80));
+ "FRF=%d\n", !!(bp[4] & 0x8), !!(bp[4] & 0x4),
+ !!(bp[4] & 0x2), !!(bp[4] & 0x1), !!(bp[5] & 0x80));
if (len > 8)
- printf(" BD-R: RRM=%d\n", !!(ucp[8] & 0x1));
+ printf(" BD-R: RRM=%d\n", !!(bp[8] & 0x1));
break;
case 0x24: /* Hardware defect management */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len > 4)
- printf(" SSA=%d\n", !!(ucp[4] & 0x80));
+ printf(" SSA=%d\n", !!(bp[4] & 0x80));
break;
case 0x25: /* Write once */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 12) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
- num = sg_get_unaligned_be16(ucp + 4);
+ num = sg_get_unaligned_be16(bp + 4);
printf(" Logical block size=0x%x, blocking=0x%x, PP=%d\n",
- num, sg_get_unaligned_be16(ucp + 8), !!(ucp[10] & 0x1));
+ num, sg_get_unaligned_be16(bp + 8), !!(bp[10] & 0x1));
break;
/* case 0x26: Restricted overwrite -> see 0x1d entry */
/* case 0x27: CDRW CAV write -> see 0x1d entry */
case 0x28: /* MRW (Mount Rainier reWriteable) */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len > 4)
printf(" DVD+Write=%d, DVD+Read=%d, Write=%d\n",
- !!(ucp[4] & 0x4), !!(ucp[4] & 0x2), !!(ucp[4] & 0x1));
+ !!(bp[4] & 0x4), !!(bp[4] & 0x2), !!(bp[4] & 0x1));
break;
case 0x29: /* Enhanced defect reporting */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
printf(" DRT-DM=%d, number of DBI cache zones=0x%x, number of "
- "entries=0x%x\n", !!(ucp[4] & 0x1), ucp[5],
- sg_get_unaligned_be16(ucp + 6));
+ "entries=0x%x\n", !!(bp[4] & 0x1), bp[5],
+ sg_get_unaligned_be16(bp + 6));
break;
case 0x2a: /* DVD+RW */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
printf(" Write=%d, Quick start=%d, Close only=%d\n",
- !!(ucp[4] & 0x1), !!(ucp[5] & 0x2), !!(ucp[5] & 0x1));
+ !!(bp[4] & 0x1), !!(bp[5] & 0x2), !!(bp[5] & 0x1));
break;
case 0x2b: /* DVD+R */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
- printf(" Write=%d\n", !!(ucp[4] & 0x1));
+ printf(" Write=%d\n", !!(bp[4] & 0x1));
break;
case 0x2c: /* Rigid restricted overwrite */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
printf(" DSDG=%d, DSDR=%d, Intermediate=%d, Blank=%d\n",
- !!(ucp[4] & 0x8), !!(ucp[4] & 0x4), !!(ucp[4] & 0x2),
- !!(ucp[4] & 0x1));
+ !!(bp[4] & 0x8), !!(bp[4] & 0x4), !!(bp[4] & 0x2),
+ !!(bp[4] & 0x1));
break;
case 0x2d: /* CD Track at once */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
printf(" BUF=%d, R-W raw=%d, R-W pack=%d, Test write=%d\n",
- !!(ucp[4] & 0x40), !!(ucp[4] & 0x10), !!(ucp[4] & 0x8),
- !!(ucp[4] & 0x4));
+ !!(bp[4] & 0x40), !!(bp[4] & 0x10), !!(bp[4] & 0x8),
+ !!(bp[4] & 0x4));
printf(" CD-RW=%d, R-W sub-code=%d, Data type supported=%d\n",
- !!(ucp[4] & 0x2), !!(ucp[4] & 0x1),
- sg_get_unaligned_be16(ucp + 6));
+ !!(bp[4] & 0x2), !!(bp[4] & 0x1),
+ sg_get_unaligned_be16(bp + 6));
break;
case 0x2e: /* CD mastering (session at once) */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
printf(" BUF=%d, SAO=%d, Raw MS=%d, Raw=%d\n",
- !!(ucp[4] & 0x40), !!(ucp[4] & 0x20), !!(ucp[4] & 0x10),
- !!(ucp[4] & 0x8));
+ !!(bp[4] & 0x40), !!(bp[4] & 0x20), !!(bp[4] & 0x10),
+ !!(bp[4] & 0x8));
printf(" Test write=%d, CD-RW=%d, R-W=%d\n",
- !!(ucp[4] & 0x4), !!(ucp[4] & 0x2), !!(ucp[4] & 0x1));
+ !!(bp[4] & 0x4), !!(bp[4] & 0x2), !!(bp[4] & 0x1));
printf(" Maximum cue sheet length=0x%x\n",
- sg_get_unaligned_be24(ucp + 5));
+ sg_get_unaligned_be24(bp + 5));
break;
case 0x2f: /* DVD-R/-RW write */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
printf(" BUF=%d, RDL=%d, Test write=%d, DVD-RW SL=%d\n",
- !!(ucp[4] & 0x40), !!(ucp[4] & 0x8), !!(ucp[4] & 0x4),
- !!(ucp[4] & 0x2));
+ !!(bp[4] & 0x40), !!(bp[4] & 0x8), !!(bp[4] & 0x4),
+ !!(bp[4] & 0x2));
break;
case 0x33: /* Layer jump recording */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
- num = ucp[7];
+ num = bp[7];
printf(" Number of link sizes=%d\n", num);
for (k = 0; k < num; ++k)
- printf(" %d\n", ucp[8 + k]);
+ printf(" %d\n", bp[8 + k]);
break;
case 0x34: /* Layer jump rigid restricted overwrite */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
- printf(" CLJB=%d\n", !!(ucp[4] & 0x1));
- printf(" Buffer block size=%d\n", ucp[7]);
+ printf(" CLJB=%d\n", !!(bp[4] & 0x1));
+ printf(" Buffer block size=%d\n", bp[7]);
break;
/* case 0x35: Stop long operation -> see 0x1d entry */
case 0x37: /* CD-RW media write support */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
- printf(" CD-RW media sub-type support (bitmask)=0x%x\n", ucp[5]);
+ printf(" CD-RW media sub-type support (bitmask)=0x%x\n", bp[5]);
break;
/* case 0x38: BD-R pseudo-overwrite (POW) -> see 0x1d entry */
case 0x3a: /* DVD+RW dual layer */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
printf(" write=%d, quick_start=%d, close_only=%d\n",
- !!(ucp[4] & 0x1), !!(ucp[5] & 0x2), !!(ucp[5] & 0x1));
+ !!(bp[4] & 0x1), !!(bp[5] & 0x2), !!(bp[5] & 0x1));
break;
case 0x3b: /* DVD+R dual layer */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
- printf(" write=%d\n", !!(ucp[4] & 0x1));
+ printf(" write=%d\n", !!(bp[4] & 0x1));
break;
case 0x40: /* BD Read */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 32) {
printf(" additional length [%d] too short\n", len - 4);
@@ -612,271 +610,271 @@ decode_feature(int feature, unsigned char * ucp, int len)
}
printf(" Bitmaps for BD-RE read support:\n");
printf(" Class 0=0x%x, Class 1=0x%x, Class 2=0x%x, "
- "Class 3=0x%x\n", sg_get_unaligned_be16(ucp + 8),
- sg_get_unaligned_be16(ucp + 10),
- sg_get_unaligned_be16(ucp + 12),
- sg_get_unaligned_be16(ucp + 14));
+ "Class 3=0x%x\n", sg_get_unaligned_be16(bp + 8),
+ sg_get_unaligned_be16(bp + 10),
+ sg_get_unaligned_be16(bp + 12),
+ sg_get_unaligned_be16(bp + 14));
printf(" Bitmaps for BD-R read support:\n");
printf(" Class 0=0x%x, Class 1=0x%x, Class 2=0x%x, "
- "Class 3=0x%x\n", sg_get_unaligned_be16(ucp + 16),
- sg_get_unaligned_be16(ucp + 18),
- sg_get_unaligned_be16(ucp + 20),
- sg_get_unaligned_be16(ucp + 22));
+ "Class 3=0x%x\n", sg_get_unaligned_be16(bp + 16),
+ sg_get_unaligned_be16(bp + 18),
+ sg_get_unaligned_be16(bp + 20),
+ sg_get_unaligned_be16(bp + 22));
printf(" Bitmaps for BD-ROM read support:\n");
printf(" Class 0=0x%x, Class 1=0x%x, Class 2=0x%x, "
- "Class 3=0x%x\n", sg_get_unaligned_be16(ucp + 24),
- sg_get_unaligned_be16(ucp + 26),
- sg_get_unaligned_be16(ucp + 28),
- sg_get_unaligned_be16(ucp + 30));
+ "Class 3=0x%x\n", sg_get_unaligned_be16(bp + 24),
+ sg_get_unaligned_be16(bp + 26),
+ sg_get_unaligned_be16(bp + 28),
+ sg_get_unaligned_be16(bp + 30));
break;
case 0x41: /* BD Write */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 32) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
- printf(" SVNR=%d\n", !!(ucp[4] & 0x1));
+ printf(" SVNR=%d\n", !!(bp[4] & 0x1));
printf(" Bitmaps for BD-RE write support:\n");
printf(" Class 0=0x%x, Class 1=0x%x, Class 2=0x%x, "
- "Class 3=0x%x\n", sg_get_unaligned_be16(ucp + 8),
- sg_get_unaligned_be16(ucp + 10),
- sg_get_unaligned_be16(ucp + 12),
- sg_get_unaligned_be16(ucp + 14));
+ "Class 3=0x%x\n", sg_get_unaligned_be16(bp + 8),
+ sg_get_unaligned_be16(bp + 10),
+ sg_get_unaligned_be16(bp + 12),
+ sg_get_unaligned_be16(bp + 14));
printf(" Bitmaps for BD-R write support:\n");
printf(" Class 0=0x%x, Class 1=0x%x, Class 2=0x%x, "
- "Class 3=0x%x\n", sg_get_unaligned_be16(ucp + 16),
- sg_get_unaligned_be16(ucp + 18),
- sg_get_unaligned_be16(ucp + 20),
- sg_get_unaligned_be16(ucp + 22));
+ "Class 3=0x%x\n", sg_get_unaligned_be16(bp + 16),
+ sg_get_unaligned_be16(bp + 18),
+ sg_get_unaligned_be16(bp + 20),
+ sg_get_unaligned_be16(bp + 22));
printf(" Bitmaps for BD-ROM write support:\n");
printf(" Class 0=0x%x, Class 1=0x%x, Class 2=0x%x, "
- "Class 3=0x%x\n", sg_get_unaligned_be16(ucp + 24),
- sg_get_unaligned_be16(ucp + 26),
- sg_get_unaligned_be16(ucp + 28),
- sg_get_unaligned_be16(ucp + 30));
+ "Class 3=0x%x\n", sg_get_unaligned_be16(bp + 24),
+ sg_get_unaligned_be16(bp + 26),
+ sg_get_unaligned_be16(bp + 28),
+ sg_get_unaligned_be16(bp + 30));
break;
/* case 0x42: TSR (timely safe recording) -> see 0x1d entry */
case 0x50: /* HD DVD Read */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
- printf(" HD DVD-R=%d, HD DVD-RAM=%d\n", !!(ucp[4] & 0x1),
- !!(ucp[6] & 0x1));
+ printf(" HD DVD-R=%d, HD DVD-RAM=%d\n", !!(bp[4] & 0x1),
+ !!(bp[6] & 0x1));
break;
case 0x51: /* HD DVD Write */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
- printf(" HD DVD-R=%d, HD DVD-RAM=%d\n", !!(ucp[4] & 0x1),
- !!(ucp[6] & 0x1));
+ printf(" HD DVD-R=%d, HD DVD-RAM=%d\n", !!(bp[4] & 0x1),
+ !!(bp[6] & 0x1));
break;
case 0x52: /* HD DVD-RW fragment recording */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
- printf(" BGP=%d\n", !!(ucp[4] & 0x1));
+ printf(" BGP=%d\n", !!(bp[4] & 0x1));
break;
case 0x80: /* Hybrid disc */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
- printf(" RI=%d\n", !!(ucp[4] & 0x1));
+ printf(" RI=%d\n", !!(bp[4] & 0x1));
break;
/* case 0x100: Power management -> see 0x1d entry */
case 0x101: /* SMART */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
- printf(" PP=%d\n", !!(ucp[4] & 0x1));
+ printf(" PP=%d\n", !!(bp[4] & 0x1));
break;
case 0x102: /* Embedded changer */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
printf(" SCC=%d, SDP=%d, highest slot number=%d\n",
- !!(ucp[4] & 0x10), !!(ucp[4] & 0x4), (ucp[7] & 0x1f));
+ !!(bp[4] & 0x10), !!(bp[4] & 0x4), (bp[7] & 0x1f));
break;
case 0x103: /* CD audio external play (obsolete) */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
printf(" Scan=%d, SCM=%d, SV=%d, number of volume levels=%d\n",
- !!(ucp[4] & 0x4), !!(ucp[4] & 0x2), !!(ucp[4] & 0x1),
- sg_get_unaligned_be16(ucp + 6));
+ !!(bp[4] & 0x4), !!(bp[4] & 0x2), !!(bp[4] & 0x1),
+ sg_get_unaligned_be16(bp + 6));
break;
case 0x104: /* Firmware upgrade */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 4) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
if (len > 4)
- printf(" M5=%d\n", !!(ucp[4] & 0x1));
+ printf(" M5=%d\n", !!(bp[4] & 0x1));
break;
case 0x105: /* Timeout */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len > 7) {
printf(" Group 3=%d, unit length=%d\n",
- !!(ucp[4] & 0x1), sg_get_unaligned_be16(ucp + 6));
+ !!(bp[4] & 0x1), sg_get_unaligned_be16(bp + 6));
}
break;
case 0x106: /* DVD CSS */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
- printf(" CSS version=%d\n", ucp[7]);
+ printf(" CSS version=%d\n", bp[7]);
break;
case 0x107: /* Real time streaming */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
printf(" RBCB=%d, SCS=%d, MP2A=%d, WSPD=%d, SW=%d\n",
- !!(ucp[4] & 0x10), !!(ucp[4] & 0x8), !!(ucp[4] & 0x4),
- !!(ucp[4] & 0x2), !!(ucp[4] & 0x1));
+ !!(bp[4] & 0x10), !!(bp[4] & 0x8), !!(bp[4] & 0x4),
+ !!(bp[4] & 0x2), !!(bp[4] & 0x1));
break;
case 0x108: /* Drive serial number */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
num = len - 4;
n = sizeof(buff) - 1;
n = ((num < n) ? num : n);
- strncpy(buff, (const char *)(ucp + 4), n);
+ strncpy(buff, (const char *)(bp + 4), n);
buff[n] = '\0';
printf(" Drive serial number: %s\n", buff);
break;
/* case 0x109: Media serial number -> see 0x1d entry */
case 0x10a: /* Disc control blocks */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
printf(" Disc control blocks:\n");
for (k = 4; k < len; k += 4) {
- printf(" 0x%x\n", sg_get_unaligned_be32(ucp + k));
+ printf(" 0x%x\n", sg_get_unaligned_be32(bp + k));
}
break;
case 0x10b: /* DVD CPRM */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
- printf(" CPRM version=%d\n", ucp[7]);
+ printf(" CPRM version=%d\n", bp[7]);
break;
case 0x10c: /* firmware information */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 20) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
- printf(" %.2s%.2s/%.2s/%.2s %.2s:%.2s:%.2s\n", ucp + 4,
- ucp + 6, ucp + 8, ucp + 10, ucp + 12, ucp + 14, ucp + 16);
+ printf(" %.2s%.2s/%.2s/%.2s %.2s:%.2s:%.2s\n", bp + 4,
+ bp + 6, bp + 8, bp + 10, bp + 12, bp + 14, bp + 16);
break;
case 0x10d: /* AACS */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
printf(" BNG=%d, Block count for binding nonce=%d\n",
- !!(ucp[4] & 0x1), ucp[5]);
+ !!(bp[4] & 0x1), bp[5]);
printf(" Number of AGIDs=%d, AACS version=%d\n",
- (ucp[6] & 0xf), ucp[7]);
+ (bp[6] & 0xf), bp[7]);
break;
case 0x10e: /* DVD CSS managed recording */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
printf(" Maximum number of scrambled extent information "
- "entries=%d\n", ucp[4]);
+ "entries=%d\n", bp[4]);
break;
/* case 0x110: VCPS -> see 0x1d entry */
/* case 0x113: SecurDisc -> see 0x1d entry */
case 0x120: /* BD CPS */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
printf(" BD CPS major:minor version number=%d:%d, max open "
- "SACs=%d\n", ((ucp[5] >> 4) & 0xf), (ucp[5] & 0xf),
- ucp[6] & 0x3);
+ "SACs=%d\n", ((bp[5] >> 4) & 0xf), (bp[5] & 0xf),
+ bp[6] & 0x3);
break;
case 0x142: /* OSSC (Optical Security Subsystem Class) */
printf(" version=%d, persist=%d, current=%d [0x%x]\n",
- ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1),
+ ((bp[2] >> 2) & 0xf), !!(bp[2] & 0x2), !!(bp[2] & 0x1),
feature);
if (len < 8) {
printf(" additional length [%d] too short\n", len - 4);
break;
}
- printf(" PSAU=%d, LOSPB=%d, ME=%d\n", !!(ucp[4] & 0x80),
- !!(ucp[4] & 0x40), !!(ucp[4] & 0x1));
- num = ucp[5];
+ printf(" PSAU=%d, LOSPB=%d, ME=%d\n", !!(bp[4] & 0x80),
+ !!(bp[4] & 0x40), !!(bp[4] & 0x1));
+ num = bp[5];
printf(" Profile numbers:\n");
for (k = 6; (num > 0) && (k < len); --num, k += 2) {
- printf(" %u\n", sg_get_unaligned_be16(ucp + k));
+ printf(" %u\n", sg_get_unaligned_be16(bp + k));
}
break;
default:
pr2serr(" Unknown feature [0x%x], version=%d persist=%d, "
- "current=%d\n", feature, ((ucp[2] >> 2) & 0xf),
- !!(ucp[2] & 0x2), !!(ucp[2] & 0x1));
- dStrHexErr((const char *)ucp, len, 1);
+ "current=%d\n", feature, ((bp[2] >> 2) & 0xf),
+ !!(bp[2] & 0x2), !!(bp[2] & 0x1));
+ dStrHexErr((const char *)bp, len, 1);
break;
}
}
diff --git a/src/sg_inq.c b/src/sg_inq.c
index 54c455b8..9dc88388 100644
--- a/src/sg_inq.c
+++ b/src/sg_inq.c
@@ -2911,8 +2911,6 @@ std_inq_response(const struct opts_t * op, int act_len)
rp = rsp_buff;
memset(vdesc_arr, 0, sizeof(vdesc_arr));
- len = rp[4] + 5;
-
if (op->do_raw) {
dStrRaw((const char *)rp, act_len);
return 0;
@@ -3169,7 +3167,6 @@ fetch_unit_serial_num(int sg_fd, char * obuff, int obuff_len, int verbose)
int len, k, res;
unsigned char b[DEF_ALLOC_LEN];
- res = 0;
memset(b, 0xff, 4); /* guard against empty response */
res = vpd_fetch_page_from_dev(sg_fd, b, VPD_UNIT_SERIAL_NUM, -1, verbose,
&len);
@@ -3222,7 +3219,6 @@ std_inq_process(int sg_fd, const struct opts_t * op, int inhex_len)
if (len != (rsp_buff[4] + 5)) {
pr2serr("strange, consecutive INQUIRYs yield different "
"'additional lengths'\n");
- res = SG_LIB_CAT_MALFORMED;
len = rsp_buff[4] + 5;
}
}
diff --git a/src/sg_inq_data.c b/src/sg_inq_data.c
index a0a0f7fe..0afb3f61 100644
--- a/src/sg_inq_data.c
+++ b/src/sg_inq_data.c
@@ -21,7 +21,7 @@
/* Assume index is less than 16 */
-const char * sg_ansi_version_arr[] =
+const char * sg_ansi_version_arr[16] =
{
"no conformance claimed",
"SCSI-1", /* obsolete, ANSI X3.131-1986 */
diff --git a/src/sg_logs.c b/src/sg_logs.c
index e5298a7a..2c17695d 100644
--- a/src/sg_logs.c
+++ b/src/sg_logs.c
@@ -1464,16 +1464,16 @@ show_supported_pgs_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int num, k, pg_code;
- const uint8_t * ucp;
+ const uint8_t * bp;
const struct log_elem * lep;
char b[64];
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Supported log pages [0x0]:\n"); /* introduced: SPC-2 */
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
for (k = 0; k < num; ++k) {
- pg_code = ucp[k];
+ pg_code = bp[k];
snprintf(b, sizeof(b) - 1, " 0x%02x ", pg_code);
lep = pg_subpg_pdt_search(pg_code, 0, op->dev_pdt);
if (lep) {
@@ -1496,7 +1496,7 @@ show_supported_pgs_sub_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int num, k, pg_code, subpg_code;
- const uint8_t * ucp;
+ const uint8_t * bp;
const struct log_elem * lep;
char b[64];
@@ -1507,10 +1507,10 @@ show_supported_pgs_sub_page(const uint8_t * resp, int len,
printf("Supported log pages and subpages [0x0, 0xff]:\n");
}
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
for (k = 0; k < num; k += 2) {
- pg_code = ucp[k];
- subpg_code = ucp[k + 1];
+ pg_code = bp[k];
+ subpg_code = bp[k + 1];
if (NOT_SPG_SUBPG == subpg_code)
snprintf(b, sizeof(b) - 1, " 0x%02x ", pg_code);
else
@@ -1537,27 +1537,27 @@ show_buffer_over_under_run_page(const uint8_t * resp, int len,
{
int num, pl, pcb, pc;
uint64_t count;
- const uint8_t * ucp;
+ const uint8_t * bp;
const char * cp;
char pcb_str[PCB_STR_LEN];
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Buffer over-run/under-run page [0x1]\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
cp = NULL;
- pl = ucp[3] + 4;
- count = (pl > 4) ? sg_get_unaligned_be(pl - 4, ucp + 4) : 0;
- pc = sg_get_unaligned_be16(ucp + 0);
+ pl = bp[3] + 4;
+ count = (pl > 4) ? sg_get_unaligned_be(pl - 4, bp + 4) : 0;
+ pc = sg_get_unaligned_be16(bp + 0);
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
@@ -1643,7 +1643,7 @@ show_buffer_over_under_run_page(const uint8_t * resp, int len,
printf(" %s = %" PRIu64 "", cp, count);
if (op->do_pcb) {
- pcb = ucp[2];
+ pcb = bp[2];
get_pcb_str(pcb, pcb_str, sizeof(pcb_str));
printf("\n <%s>\n", pcb_str);
} else
@@ -1652,7 +1652,7 @@ show_buffer_over_under_run_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -1664,7 +1664,7 @@ show_error_counter_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int num, pl, pc, pcb, pg_code;
- const uint8_t * ucp;
+ const uint8_t * bp;
char pcb_str[PCB_STR_LEN];
pg_code = resp[0] & 0x3f;
@@ -1690,19 +1690,19 @@ show_error_counter_page(const uint8_t * resp, int len,
}
}
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
@@ -1718,7 +1718,7 @@ show_error_counter_page(const uint8_t * resp, int len,
case 0x8015: printf(" Positioning errors [Hitachi]"); break;
default: printf(" Reserved or vendor specific [0x%x]", pc); break;
}
- printf(" = %" PRIu64 "", sg_get_unaligned_be(pl - 4, ucp + 4));
+ printf(" = %" PRIu64 "", sg_get_unaligned_be(pl - 4, bp + 4));
if (op->do_pcb) {
get_pcb_str(pcb, pcb_str, sizeof(pcb_str));
printf("\n <%s>\n", pcb_str);
@@ -1728,7 +1728,7 @@ show_error_counter_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -1739,25 +1739,25 @@ show_non_medium_error_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int num, pl, pc, pcb;
- const uint8_t * ucp;
+ const uint8_t * bp;
char pcb_str[PCB_STR_LEN];
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Non-medium error page [0x6]\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
@@ -1772,7 +1772,7 @@ show_non_medium_error_page(const uint8_t * resp, int len,
printf(" Vendor specific [0x%x]", pc);
break;
}
- printf(" = %" PRIu64 "", sg_get_unaligned_be(pl - 4, ucp + 4));
+ printf(" = %" PRIu64 "", sg_get_unaligned_be(pl - 4, bp + 4));
if (op->do_pcb) {
get_pcb_str(pcb, pcb_str, sizeof(pcb_str));
printf("\n <%s>\n", pcb_str);
@@ -1782,7 +1782,7 @@ show_non_medium_error_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -1793,25 +1793,25 @@ show_power_condition_transitions_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int num, pl, pc, pcb;
- const uint8_t * ucp;
+ const uint8_t * bp;
char pcb_str[PCB_STR_LEN];
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Power condition transitions page [0x1a]\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
@@ -1831,7 +1831,7 @@ show_power_condition_transitions_page(const uint8_t * resp, int len,
default:
printf(" Reserved [0x%x]", pc);
}
- printf(" = %" PRIu64 "", sg_get_unaligned_be(pl - 4, ucp + 4));
+ printf(" = %" PRIu64 "", sg_get_unaligned_be(pl - 4, bp + 4));
if (op->do_pcb) {
get_pcb_str(pcb, pcb_str, sizeof(pcb_str));
printf("\n <%s>\n", pcb_str);
@@ -1841,7 +1841,7 @@ show_power_condition_transitions_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -1880,7 +1880,7 @@ show_environmental_reporting_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int num, pl, pc, pcb, blen;
- const uint8_t * ucp;
+ const uint8_t * bp;
char pcb_str[PCB_STR_LEN];
char b[32];
@@ -1888,19 +1888,19 @@ show_environmental_reporting_page(const uint8_t * resp, int len,
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Environmental reporting page [0xd,0x1]\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
@@ -1911,26 +1911,26 @@ show_environmental_reporting_page(const uint8_t * resp, int len,
goto skip;
}
printf(" Temperature: %s\n",
- temperature_str(ucp[5], true, b, blen));
+ temperature_str(bp[5], true, b, blen));
printf(" Lifetime maximum temperature: %s\n",
- temperature_str(ucp[6], true, b, blen));
+ temperature_str(bp[6], true, b, blen));
printf(" Lifetime minimum temperature: %s\n",
- temperature_str(ucp[7], true, b, blen));
+ temperature_str(bp[7], true, b, blen));
printf(" Maximum temperature since power on: %s\n",
- temperature_str(ucp[8], true, b, blen));
+ temperature_str(bp[8], true, b, blen));
printf(" Minimum temperature since power on: %s\n",
- temperature_str(ucp[9], true, b, blen));
+ temperature_str(bp[9], true, b, blen));
} else if (pc < 0x200) {
printf(" Relative humidity: %s\n",
- humidity_str(ucp[5], true, b, blen));
+ humidity_str(bp[5], true, b, blen));
printf(" Lifetime maximum relative humidity: %s\n",
- humidity_str(ucp[6], true, b, blen));
+ humidity_str(bp[6], true, b, blen));
printf(" Lifetime minimum relative humidity: %s\n",
- humidity_str(ucp[7], true, b, blen));
+ humidity_str(bp[7], true, b, blen));
printf(" Maximum relative humidity since power on: %s\n",
- humidity_str(ucp[8], true, b, blen));
+ humidity_str(bp[8], true, b, blen));
printf(" Minimum relative humidity since power on: %s\n",
- humidity_str(ucp[9], true, b, blen));
+ humidity_str(bp[9], true, b, blen));
} else
printf(" <<unexpect parameter code 0x%x\n", pc);
if (op->do_pcb) {
@@ -1942,7 +1942,7 @@ show_environmental_reporting_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -1953,7 +1953,7 @@ show_environmental_limits_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int num, pl, pc, pcb, blen;
- const uint8_t * ucp;
+ const uint8_t * bp;
char pcb_str[PCB_STR_LEN];
char b[32];
@@ -1961,19 +1961,19 @@ show_environmental_limits_page(const uint8_t * resp, int len,
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Environmental limits page [0xd,0x2]\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
@@ -1984,38 +1984,38 @@ show_environmental_limits_page(const uint8_t * resp, int len,
goto skip;
}
printf(" High critical temperature limit trigger: %s\n",
- temperature_str(ucp[4], false, b, blen));
+ temperature_str(bp[4], false, b, blen));
printf(" High critical temperature limit reset: %s\n",
- temperature_str(ucp[5], false, b, blen));
+ temperature_str(bp[5], false, b, blen));
printf(" Low critical temperature limit reset: %s\n",
- temperature_str(ucp[6], false, b, blen));
+ temperature_str(bp[6], false, b, blen));
printf(" Low critical temperature limit trigger: %s\n",
- temperature_str(ucp[7], false, b, blen));
+ temperature_str(bp[7], false, b, blen));
printf(" High operating temperature limit trigger: %s\n",
- temperature_str(ucp[8], false, b, blen));
+ temperature_str(bp[8], false, b, blen));
printf(" High operating temperature limit reset: %s\n",
- temperature_str(ucp[9], false, b, blen));
+ temperature_str(bp[9], false, b, blen));
printf(" Low operating temperature limit reset: %s\n",
- temperature_str(ucp[10], false, b, blen));
+ temperature_str(bp[10], false, b, blen));
printf(" Low operating temperature limit trigger: %s\n",
- temperature_str(ucp[11], false, b, blen));
+ temperature_str(bp[11], false, b, blen));
} else if (pc < 0x200) {
printf(" High critical relative humidity limit trigger: %s\n",
- humidity_str(ucp[4], false, b, blen));
+ humidity_str(bp[4], false, b, blen));
printf(" High critical relative humidity limit reset: %s\n",
- humidity_str(ucp[5], false, b, blen));
+ humidity_str(bp[5], false, b, blen));
printf(" Low critical relative humidity limit reset: %s\n",
- humidity_str(ucp[6], false, b, blen));
+ humidity_str(bp[6], false, b, blen));
printf(" Low critical relative humidity limit trigger: %s\n",
- humidity_str(ucp[7], false, b, blen));
+ humidity_str(bp[7], false, b, blen));
printf(" High operating relative humidity limit trigger: %s\n",
- humidity_str(ucp[8], false, b, blen));
+ humidity_str(bp[8], false, b, blen));
printf(" High operating relative humidity limit reset: %s\n",
- humidity_str(ucp[9], false, b, blen));
+ humidity_str(bp[9], false, b, blen));
printf(" Low operating relative humidity limit reset: %s\n",
- humidity_str(ucp[10], false, b, blen));
+ humidity_str(bp[10], false, b, blen));
printf(" Low operating relative humidity limit trigger: %s\n",
- humidity_str(ucp[11], false, b, blen));
+ humidity_str(bp[11], false, b, blen));
} else
printf(" <<unexpect parameter code 0x%x\n", pc);
if (op->do_pcb) {
@@ -2027,7 +2027,7 @@ show_environmental_limits_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -2039,43 +2039,43 @@ show_tape_usage_page(const uint8_t * resp, int len, const struct opts_t * op)
int k, num, extra, pc, pcb;
unsigned int n;
uint64_t ull;
- const uint8_t * ucp;
+ const uint8_t * bp;
char pcb_str[PCB_STR_LEN];
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
if (num < 4) {
pr2serr("badly formed tape usage page\n");
return false;
}
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Tape usage page (LTO-5 and LTO-6 specific) [0x30]\n");
- for (k = num; k > 0; k -= extra, ucp += extra) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- extra = ucp[3] + 4;
+ for (k = num; k > 0; k -= extra, bp += extra) {
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ extra = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
continue;
if (op->do_raw) {
- dStrRaw((const char *)ucp, extra);
+ dStrRaw((const char *)bp, extra);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, extra,
+ dStrHex((const char *)bp, extra,
((1 == op->do_hex) ? 1 : -1));
break;
}
}
ull = n = 0;
- switch (ucp[3]) {
+ switch (bp[3]) {
case 2:
- n = sg_get_unaligned_be16(ucp + 4);
+ n = sg_get_unaligned_be16(bp + 4);
break;
case 4:
- n = sg_get_unaligned_be32(ucp + 4);
+ n = sg_get_unaligned_be32(bp + 4);
break;
case 8:
- ull = sg_get_unaligned_be64(ucp + 4);
+ ull = sg_get_unaligned_be64(bp + 4);
break;
}
switch (pc) {
@@ -2126,7 +2126,7 @@ show_tape_usage_page(const uint8_t * resp, int len, const struct opts_t * op)
default:
printf(" unknown parameter code = 0x%x, contents in "
"hex:\n", pc);
- dStrHex((const char *)ucp, extra, 1);
+ dStrHex((const char *)bp, extra, 1);
break;
}
if (op->do_pcb) {
@@ -2147,36 +2147,36 @@ show_tape_capacity_page(const uint8_t * resp, int len,
{
int k, num, extra, pc, pcb;
unsigned int n;
- const uint8_t * ucp;
+ const uint8_t * bp;
char pcb_str[PCB_STR_LEN];
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
if (num < 4) {
pr2serr("badly formed tape capacity page\n");
return false;
}
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Tape capacity page (LTO-5 and LTO-6 specific) [0x31]\n");
- for (k = num; k > 0; k -= extra, ucp += extra) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- extra = ucp[3] + 4;
+ for (k = num; k > 0; k -= extra, bp += extra) {
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ extra = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
continue;
if (op->do_raw) {
- dStrRaw((const char *)ucp, extra);
+ dStrRaw((const char *)bp, extra);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, extra,
+ dStrHex((const char *)bp, extra,
((1 == op->do_hex) ? 1 : -1));
break;
}
}
if (extra != 8)
continue;
- n = sg_get_unaligned_be32(ucp + 4);
+ n = sg_get_unaligned_be32(bp + 4);
switch (pc) {
case 0x01:
printf(" Main partition remaining capacity (in MiB): %u", n);
@@ -2193,7 +2193,7 @@ show_tape_capacity_page(const uint8_t * resp, int len,
default:
printf(" unknown parameter code = 0x%x, contents in "
"hex:\n", pc);
- dStrHex((const char *)ucp, extra, 1);
+ dStrHex((const char *)bp, extra, 1);
break;
}
if (op->do_pcb) {
@@ -2215,12 +2215,12 @@ show_data_compression_page(const uint8_t * resp, int len,
{
int k, j, pl, num, extra, pc, pcb, pg_code;
uint64_t n;
- const uint8_t * ucp;
+ const uint8_t * bp;
char pcb_str[PCB_STR_LEN];
pg_code = resp[0] & 0x3f;
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
if (num < 4) {
pr2serr("badly formed data compression page\n");
return false;
@@ -2232,19 +2232,19 @@ show_data_compression_page(const uint8_t * resp, int len,
printf("Data compression page (LTO-5 specific) [0x%x]\n",
pg_code);
}
- for (k = num; k > 0; k -= extra, ucp += extra) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3];
+ for (k = num; k > 0; k -= extra, bp += extra) {
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3];
extra = pl + 4;
if (op->filter_given) {
if (pc != op->filter)
continue;
if (op->do_raw) {
- dStrRaw((const char *)ucp, extra);
+ dStrRaw((const char *)bp, extra);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, extra,
+ dStrHex((const char *)bp, extra,
((1 == op->do_hex) ? 1 : -1));
break;
}
@@ -2252,14 +2252,14 @@ show_data_compression_page(const uint8_t * resp, int len,
if ((0 == pl) || (pl > 8)) {
printf("badly formed data compression log parameter\n");
printf(" parameter code = 0x%x, contents in hex:\n", pc);
- dStrHex((const char *)ucp, extra, 1);
+ dStrHex((const char *)bp, extra, 1);
goto skip_para;
}
/* variable length integer, max length 8 bytes */
for (j = 0, n = 0; j < pl; ++j) {
if (j > 0)
n <<= 8;
- n |= ucp[4 + j];
+ n |= bp[4 + j];
}
switch (pc) {
case 0x00:
@@ -2298,7 +2298,7 @@ show_data_compression_page(const uint8_t * resp, int len,
default:
printf(" unknown parameter code = 0x%x, contents in "
"hex:\n", pc);
- dStrHex((const char *)ucp, extra, 1);
+ dStrHex((const char *)bp, extra, 1);
break;
}
skip_para:
@@ -2319,33 +2319,33 @@ show_last_n_error_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int k, num, pl, pc, pcb;
- const uint8_t * ucp;
+ const uint8_t * bp;
char pcb_str[PCB_STR_LEN];
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
if (num < 4) {
printf("No error events logged\n");
return true;
}
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Last n error events page [0x7]\n");
- for (k = num; k > 0; k -= pl, ucp += pl) {
+ for (k = num; k > 0; k -= pl, bp += pl) {
if (k < 3) {
printf("short Last n error events page\n");
return false;
}
- pl = ucp[3] + 4;
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
+ pl = bp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
if (op->filter_given) {
if (pc != op->filter)
continue;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
@@ -2353,12 +2353,12 @@ show_last_n_error_page(const uint8_t * resp, int len,
if (pl > 4) {
if ((pcb & 0x1) && (pcb & 0x2)) {
printf(" [binary]:\n");
- dStrHex((const char *)ucp + 4, pl - 4, 1);
+ dStrHex((const char *)bp + 4, pl - 4, 1);
} else if (pcb & 0x1)
- printf(" %.*s\n", pl - 4, (const char *)(ucp + 4));
+ printf(" %.*s\n", pl - 4, (const char *)(bp + 4));
else {
printf(" [data counter?? (LP bit should be set)]:\n");
- dStrHex((const char *)ucp + 4, pl - 4, 1);
+ dStrHex((const char *)bp + 4, pl - 4, 1);
}
}
if (op->do_pcb) {
@@ -2377,38 +2377,38 @@ show_last_n_deferred_error_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int k, num, pl, pc, pcb;
- const uint8_t * ucp;
+ const uint8_t * bp;
char pcb_str[PCB_STR_LEN];
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
if (num < 4) {
printf("No deferred errors logged\n");
return true;
}
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Last n deferred errors page [0xb]\n");
- for (k = num; k > 0; k -= pl, ucp += pl) {
+ for (k = num; k > 0; k -= pl, bp += pl) {
if (k < 3) {
printf("short Last n deferred errors page\n");
return true;
}
- pl = ucp[3] + 4;
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
+ pl = bp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
if (op->filter_given) {
if (pc != op->filter)
continue;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
printf(" Deferred error %d:\n", pc);
- dStrHex((const char *)ucp + 4, pl - 4, 1);
+ dStrHex((const char *)bp + 4, pl - 4, 1);
if (op->do_pcb) {
get_pcb_str(pcb, pcb_str, sizeof(pcb_str));
printf(" <%s>\n", pcb_str);
@@ -2443,7 +2443,7 @@ show_self_test_page(const uint8_t * resp, int len, const struct opts_t * op)
{
int k, num, n, res, pc, pl, pcb;
unsigned int v;
- const uint8_t * ucp;
+ const uint8_t * bp;
uint64_t ull;
char pcb_str[PCB_STR_LEN];
char b[80];
@@ -2456,44 +2456,44 @@ show_self_test_page(const uint8_t * resp, int len, const struct opts_t * op)
}
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Self-test results page [0x10]\n");
- for (k = 0, ucp = resp + 4; k < 20; ++k, ucp += 20 ) {
- pcb = ucp[2];
- pl = ucp[3] + 4;
- pc = sg_get_unaligned_be16(ucp + 0);
+ for (k = 0, bp = resp + 4; k < 20; ++k, bp += 20 ) {
+ pcb = bp[2];
+ pl = bp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
if (op->filter_given) {
if (pc != op->filter)
continue;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
- n = sg_get_unaligned_be16(ucp + 6);
- if ((0 == n) && (0 == ucp[4]))
+ n = sg_get_unaligned_be16(bp + 6);
+ if ((0 == n) && (0 == bp[4]))
break;
printf(" Parameter code = %d, accumulated power-on hours = %d\n",
pc, n);
printf(" self-test code: %s [%d]\n",
- self_test_code[(ucp[4] >> 5) & 0x7], (ucp[4] >> 5) & 0x7);
- res = ucp[4] & 0xf;
+ self_test_code[(bp[4] >> 5) & 0x7], (bp[4] >> 5) & 0x7);
+ res = bp[4] & 0xf;
printf(" self-test result: %s [%d]\n", self_test_result[res], res);
- if (ucp[5])
- printf(" self-test number = %d\n", (int)ucp[5]);
- if (! all_bits_set(ucp + 8, 8)) {
- ull = sg_get_unaligned_be64(ucp + 8);
+ if (bp[5])
+ printf(" self-test number = %d\n", (int)bp[5]);
+ if (! all_bits_set(bp + 8, 8)) {
+ ull = sg_get_unaligned_be64(bp + 8);
if ((res > 0) && ( res < 0xf))
printf(" address of first error = 0x%" PRIx64 "\n", ull);
}
- v = ucp[16] & 0xf;
+ v = bp[16] & 0xf;
if (v) {
printf(" sense key = 0x%x [%s] , asc = 0x%x, ascq = 0x%x",
- v, sg_get_sense_key_str(v, sizeof(b), b), ucp[17],
- ucp[18]);
- if (ucp[17] || ucp[18])
- printf(" [%s]\n", sg_get_asc_ascq_str(ucp[17], ucp[18],
+ v, sg_get_sense_key_str(v, sizeof(b), b), bp[17],
+ bp[18]);
+ if (bp[17] || bp[18])
+ printf(" [%s]\n", sg_get_asc_ascq_str(bp[17], bp[18],
sizeof(b), b));
}
if (op->do_pcb) {
@@ -2512,11 +2512,11 @@ static bool
show_temperature_page(const uint8_t * resp, int len, const struct opts_t * op)
{
int k, num, extra, pc, pcb;
- const uint8_t * ucp;
+ const uint8_t * bp;
char pcb_str[PCB_STR_LEN];
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
if (num < 4) {
pr2serr("badly formed Temperature page\n");
return false;
@@ -2525,22 +2525,22 @@ show_temperature_page(const uint8_t * resp, int len, const struct opts_t * op)
if (! op->do_temperature)
printf("Temperature page [0xd]\n");
}
- for (k = num; k > 0; k -= extra, ucp += extra) {
+ for (k = num; k > 0; k -= extra, bp += extra) {
if (k < 3) {
pr2serr("short Temperature page\n");
return true;
}
- extra = ucp[3] + 4;
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
+ extra = bp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
if (op->filter_given) {
if (pc != op->filter)
continue;
if (op->do_raw) {
- dStrRaw((const char *)ucp, extra);
+ dStrRaw((const char *)bp, extra);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, extra,
+ dStrHex((const char *)bp, extra,
((1 == op->do_hex) ? 1 : -1));
break;
}
@@ -2548,16 +2548,16 @@ show_temperature_page(const uint8_t * resp, int len, const struct opts_t * op)
switch (pc) {
case 0:
if ((extra > 5) && (k > 5)) {
- if (ucp[5] < 0xff)
- printf(" Current temperature = %d C", ucp[5]);
+ if (bp[5] < 0xff)
+ printf(" Current temperature = %d C", bp[5]);
else
printf(" Current temperature = <not available>");
}
break;
case 1:
if ((extra > 5) && (k > 5)) {
- if (ucp[5] < 0xff)
- printf(" Reference temperature = %d C", ucp[5]);
+ if (bp[5] < 0xff)
+ printf(" Reference temperature = %d C", bp[5]);
else
printf(" Reference temperature = <not available>");
}
@@ -2566,7 +2566,7 @@ show_temperature_page(const uint8_t * resp, int len, const struct opts_t * op)
if (! op->do_temperature) {
printf(" unknown parameter code = 0x%x, contents in "
"hex:\n", pc);
- dStrHex((const char *)ucp, extra, 1);
+ dStrHex((const char *)bp, extra, 1);
} else
continue;
break;
@@ -2587,33 +2587,33 @@ static bool
show_start_stop_page(const uint8_t * resp, int len, const struct opts_t * op)
{
int k, num, extra, pc, pcb;
- const uint8_t * ucp;
+ const uint8_t * bp;
char pcb_str[PCB_STR_LEN];
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
if (num < 4) {
pr2serr("badly formed Start-stop cycle counter page\n");
return false;
}
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Start-stop cycle counter page [0xe]\n");
- for (k = num; k > 0; k -= extra, ucp += extra) {
+ for (k = num; k > 0; k -= extra, bp += extra) {
if (k < 3) {
pr2serr("short Start-stop cycle counter page\n");
return true;
}
- extra = ucp[3] + 4;
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
+ extra = bp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
if (op->filter_given) {
if (pc != op->filter)
continue;
if (op->do_raw) {
- dStrRaw((const char *)ucp, extra);
+ dStrRaw((const char *)bp, extra);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, extra,
+ dStrHex((const char *)bp, extra,
((1 == op->do_hex) ? 1 : -1));
break;
}
@@ -2622,65 +2622,65 @@ show_start_stop_page(const uint8_t * resp, int len, const struct opts_t * op)
case 1:
if (10 == extra)
printf(" Date of manufacture, year: %.4s, week: %.2s",
- &ucp[4], &ucp[8]);
+ &bp[4], &bp[8]);
else if (op->verbose) {
pr2serr(" Date of manufacture parameter length strange: "
"%d\n", extra - 4);
- dStrHexErr((const char *)ucp, extra, 1);
+ dStrHexErr((const char *)bp, extra, 1);
}
break;
case 2:
if (10 == extra)
printf(" Accounting date, year: %.4s, week: %.2s",
- &ucp[4], &ucp[8]);
+ &bp[4], &bp[8]);
else if (op->verbose) {
pr2serr(" Accounting date parameter length strange: %d\n",
extra - 4);
- dStrHexErr((const char *)ucp, extra, 1);
+ dStrHexErr((const char *)bp, extra, 1);
}
break;
case 3:
if (extra > 7) {
- if (all_bits_set(ucp + 4, 4))
+ if (all_bits_set(bp + 4, 4))
printf(" Specified cycle count over device lifetime "
"= -1");
else
printf(" Specified cycle count over device lifetime "
- "= %u", sg_get_unaligned_be32(ucp + 4));
+ "= %u", sg_get_unaligned_be32(bp + 4));
}
break;
case 4:
if (extra > 7) {
- if (all_bits_set(ucp + 4, 4))
+ if (all_bits_set(bp + 4, 4))
printf(" Accumulated start-stop cycles = -1");
else
printf(" Accumulated start-stop cycles = %u",
- sg_get_unaligned_be32(ucp + 4));
+ sg_get_unaligned_be32(bp + 4));
}
break;
case 5:
if (extra > 7) {
- if (all_bits_set(ucp + 4, 4))
+ if (all_bits_set(bp + 4, 4))
printf(" Specified load-unload count over device "
"lifetime = -1");
else
printf(" Specified load-unload count over device "
- "lifetime = %u", sg_get_unaligned_be32(ucp + 4));
+ "lifetime = %u", sg_get_unaligned_be32(bp + 4));
}
break;
case 6:
if (extra > 7) {
- if (all_bits_set(ucp + 4, 4))
+ if (all_bits_set(bp + 4, 4))
printf(" Accumulated load-unload cycles = -1");
else
printf(" Accumulated load-unload cycles = %u",
- sg_get_unaligned_be32(ucp + 4));
+ sg_get_unaligned_be32(bp + 4));
}
break;
default:
printf(" unknown parameter code = 0x%x, contents in "
"hex:\n", pc);
- dStrHex((const char *)ucp, extra, 1);
+ dStrHex((const char *)bp, extra, 1);
break;
}
if (op->do_pcb) {
@@ -2699,11 +2699,11 @@ static bool
show_app_client_page(const uint8_t * resp, int len, const struct opts_t * op)
{
int k, num, extra, pc, pcb;
- const uint8_t * ucp;
+ const uint8_t * bp;
char pcb_str[PCB_STR_LEN];
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
if (num < 4) {
pr2serr("badly formed Application Client page\n");
return false;
@@ -2721,24 +2721,24 @@ show_app_client_page(const uint8_t * resp, int len, const struct opts_t * op)
return true;
}
/* only here if filter_given set */
- for (k = num; k > 0; k -= extra, ucp += extra) {
+ for (k = num; k > 0; k -= extra, bp += extra) {
if (k < 3) {
pr2serr("short Application client page\n");
return true;
}
- extra = ucp[3] + 4;
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
+ extra = bp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
if (op->filter != pc)
continue;
if (op->do_raw)
- dStrRaw((const char *)ucp, extra);
+ dStrRaw((const char *)bp, extra);
else if (0 == op->do_hex)
- dStrHex((const char *)ucp, extra, 0);
+ dStrHex((const char *)bp, extra, 0);
else if (1 == op->do_hex)
- dStrHex((const char *)ucp, extra, 1);
+ dStrHex((const char *)bp, extra, 1);
else
- dStrHex((const char *)ucp, extra, -1);
+ dStrHex((const char *)bp, extra, -1);
if (op->do_pcb) {
get_pcb_str(pcb, pcb_str, sizeof(pcb_str));
@@ -2755,13 +2755,13 @@ static bool
show_ie_page(const uint8_t * resp, int len, const struct opts_t * op)
{
int k, num, extra, pc, pcb, full;
- const uint8_t * ucp;
+ const uint8_t * bp;
char pcb_str[PCB_STR_LEN];
char b[256];
full = ! op->do_temperature;
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
if (num < 4) {
pr2serr("badly formed Informational Exceptions page\n");
return false;
@@ -2770,22 +2770,22 @@ show_ie_page(const uint8_t * resp, int len, const struct opts_t * op)
if (full)
printf("Informational Exceptions page [0x2f]\n");
}
- for (k = num; k > 0; k -= extra, ucp += extra) {
+ for (k = num; k > 0; k -= extra, bp += extra) {
if (k < 3) {
printf("short Informational Exceptions page\n");
return false;
}
- extra = ucp[3] + 4;
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
+ extra = bp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
if (op->filter_given) {
if (pc != op->filter)
continue;
if (op->do_raw) {
- dStrRaw((const char *)ucp, extra);
+ dStrRaw((const char *)bp, extra);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, extra,
+ dStrHex((const char *)bp, extra,
((1 == op->do_hex) ? 1 : -1));
break;
}
@@ -2794,20 +2794,20 @@ show_ie_page(const uint8_t * resp, int len, const struct opts_t * op)
case 0:
if (extra > 5) {
if (full) {
- printf(" IE asc = 0x%x, ascq = 0x%x", ucp[4], ucp[5]);
- if (ucp[4] || ucp[5])
- if(sg_get_asc_ascq_str(ucp[4], ucp[5], sizeof(b), b))
+ printf(" IE asc = 0x%x, ascq = 0x%x", bp[4], bp[5]);
+ if (bp[4] || bp[5])
+ if(sg_get_asc_ascq_str(bp[4], bp[5], sizeof(b), b))
printf("\n [%s]", b);
}
if (extra > 6) {
- if (ucp[6] < 0xff)
- printf("\n Current temperature = %d C", ucp[6]);
+ if (bp[6] < 0xff)
+ printf("\n Current temperature = %d C", bp[6]);
else
printf("\n Current temperature = <not available>");
if (extra > 7) {
- if (ucp[7] < 0xff)
+ if (bp[7] < 0xff)
printf("\n Threshold temperature = %d C [IBM "
- "extension]", ucp[7]);
+ "extension]", bp[7]);
else
printf("\n Threshold temperature = <not "
"available>");
@@ -2818,7 +2818,7 @@ show_ie_page(const uint8_t * resp, int len, const struct opts_t * op)
default:
if (full) {
printf(" parameter code = 0x%x, contents in hex:\n", pc);
- dStrHex((const char *)ucp, extra, 1);
+ dStrHex((const char *)bp, extra, 1);
}
break;
}
@@ -3009,7 +3009,7 @@ sas_negot_link_rate(int lrate, char * b, int blen)
/* helper for SAS port of PROTO_SPECIFIC_LPAGE [0x18] */
static void
-show_sas_port_param(const uint8_t * ucp, int param_len,
+show_sas_port_param(const uint8_t * bp, int param_len,
const struct opts_t * op)
{
int j, m, nphys, pcb, t, sz, spld_len;
@@ -3020,17 +3020,17 @@ show_sas_port_param(const uint8_t * ucp, int param_len,
char s[64];
sz = sizeof(s);
- pcb = ucp[2];
- t = sg_get_unaligned_be16(ucp + 0);
+ pcb = bp[2];
+ t = sg_get_unaligned_be16(bp + 0);
if (op->do_name)
printf("rel_target_port=%d\n", t);
else
printf("relative target port id = %d\n", t);
if (op->do_name)
- printf(" gen_code=%d\n", ucp[6]);
+ printf(" gen_code=%d\n", bp[6]);
else
- printf(" generation code = %d\n", ucp[6]);
- nphys = ucp[7];
+ printf(" generation code = %d\n", bp[6]);
+ nphys = bp[7];
if (op->do_name)
printf(" num_phys=%d\n", nphys);
else {
@@ -3042,7 +3042,7 @@ show_sas_port_param(const uint8_t * ucp, int param_len,
printf("\n");
}
- for (j = 0, vcp = ucp + 8; j < (param_len - 8);
+ for (j = 0, vcp = bp + 8; j < (param_len - 8);
vcp += spld_len, j += spld_len) {
if (op->do_name)
printf(" phy_id=%d\n", vcp[1]);
@@ -3176,28 +3176,28 @@ show_protocol_specific_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int k, num, pl, pc, pid;
- const uint8_t * ucp;
+ const uint8_t * bp;
num = len - 4;
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex))) {
if (op->do_name)
printf("log_page=0x%x\n", PROTO_SPECIFIC_LPAGE);
}
- for (k = 0, ucp = resp + 4; k < num; ) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pl = ucp[3] + 4;
+ for (k = 0, bp = resp + 4; k < num; ) {
+ pc = sg_get_unaligned_be16(bp + 0);
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
- pid = 0xf & ucp[4];
+ pid = 0xf & bp[4];
if (6 != pid) {
pr2serr("Protocol identifier: %d, only support SAS (SPL) which "
"is 6\n", pid);
@@ -3206,12 +3206,12 @@ show_protocol_specific_page(const uint8_t * resp, int len,
if ((0 == k) && (0 == op->do_name))
printf("Protocol Specific port page for SAS SSP (sas-2) "
"[0x18]\n");
- show_sas_port_param(ucp, pl, op);
+ show_sas_port_param(bp, pl, op);
if (op->filter_given)
break;
skip:
k += pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -3225,14 +3225,14 @@ show_stats_perform_pages(const uint8_t * resp, int len,
int k, num, param_len, param_code, spf, subpg_code, extra;
int pcb, nam;
unsigned int ui;
- const uint8_t * ucp;
+ const uint8_t * bp;
const char * ccp;
uint64_t ull;
char pcb_str[PCB_STR_LEN];
nam = op->do_name;
num = len - 4;
- ucp = resp + 4;
+ bp = resp + 4;
spf = !!(resp[0] & 0x40);
subpg_code = spf ? resp[1] : 0;
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex))) {
@@ -3253,21 +3253,21 @@ show_stats_perform_pages(const uint8_t * resp, int len,
if (0 == subpg_code) { /* General statistics and performance log page */
if (num < 0x5c)
return false;
- for (k = num; k > 0; k -= extra, ucp += extra) {
+ for (k = num; k > 0; k -= extra, bp += extra) {
if (k < 3)
return false;
- param_len = ucp[3];
+ param_len = bp[3];
extra = param_len + 4;
- param_code = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
+ param_code = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
if (op->filter_given) {
if (param_code != op->filter)
continue;
if (op->do_raw) {
- dStrRaw((const char *)ucp, extra);
+ dStrRaw((const char *)bp, extra);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, extra,
+ dStrHex((const char *)bp, extra,
((1 == op->do_hex) ? 1 : -1));
break;
}
@@ -3277,33 +3277,33 @@ show_stats_perform_pages(const uint8_t * resp, int len,
ccp = nam ? "parameter_code=1" : "Statistics and performance "
"log parameter";
printf("%s\n", ccp);
- ull = sg_get_unaligned_be64(ucp + 4);
+ ull = sg_get_unaligned_be64(bp + 4);
ccp = nam ? "read_commands=" : "number of read commands = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 12);
+ ull = sg_get_unaligned_be64(bp + 12);
ccp = nam ? "write_commands=" : "number of write commands = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 20);
+ ull = sg_get_unaligned_be64(bp + 20);
ccp = nam ? "lb_received="
: "number of logical blocks received = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 28);
+ ull = sg_get_unaligned_be64(bp + 28);
ccp = nam ? "lb_transmitted="
: "number of logical blocks transmitted = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 36);
+ ull = sg_get_unaligned_be64(bp + 36);
ccp = nam ? "read_proc_intervals="
: "read command processing intervals = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 44);
+ ull = sg_get_unaligned_be64(bp + 44);
ccp = nam ? "write_proc_intervals="
: "write command processing intervals = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 52);
+ ull = sg_get_unaligned_be64(bp + 52);
ccp = nam ? "weight_rw_commands=" : "weighted number of "
"read commands plus write commands = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 60);
+ ull = sg_get_unaligned_be64(bp + 60);
ccp = nam ? "weight_rw_processing=" : "weighted read command "
"processing plus write command processing = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
@@ -3311,7 +3311,7 @@ show_stats_perform_pages(const uint8_t * resp, int len,
case 2: /* Idle time log parameter */
ccp = nam ? "parameter_code=2" : "Idle time log parameter";
printf("%s\n", ccp);
- ull = sg_get_unaligned_be64(ucp + 4);
+ ull = sg_get_unaligned_be64(bp + 4);
ccp = nam ? "idle_time_intervals=" : "idle time "
"intervals = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
@@ -3320,11 +3320,11 @@ show_stats_perform_pages(const uint8_t * resp, int len,
ccp = nam ? "parameter_code=3" : "Time interval log "
"parameter for general stats";
printf("%s\n", ccp);
- ui = sg_get_unaligned_be32(ucp + 4);
+ ui = sg_get_unaligned_be32(bp + 4);
ccp = nam ? "time_interval_neg_exp=" : "time interval "
"negative exponent = ";
printf(" %s%u\n", ccp, ui);
- ui = sg_get_unaligned_be32(ucp + 8);
+ ui = sg_get_unaligned_be32(bp + 8);
ccp = nam ? "time_interval_int=" : "time interval "
"integer = ";
printf(" %s%u\n", ccp, ui);
@@ -3333,35 +3333,35 @@ show_stats_perform_pages(const uint8_t * resp, int len,
ccp = nam ? "parameter_code=4" : "Force unit access "
"statistics and performance log parameter ";
printf("%s\n", ccp);
- ull = sg_get_unaligned_be64(ucp + 4);
+ ull = sg_get_unaligned_be64(bp + 4);
ccp = nam ? "read_fua_commands=" : "number of read FUA "
"commands = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 12);
+ ull = sg_get_unaligned_be64(bp + 12);
ccp = nam ? "write_fua_commands=" : "number of write FUA "
"commands = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 20);
+ ull = sg_get_unaligned_be64(bp + 20);
ccp = nam ? "read_fua_nv_commands="
: "number of read FUA_NV commands = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 28);
+ ull = sg_get_unaligned_be64(bp + 28);
ccp = nam ? "write_fua_nv_commands="
: "number of write FUA_NV commands = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 36);
+ ull = sg_get_unaligned_be64(bp + 36);
ccp = nam ? "read_fua_proc_intervals="
: "read FUA command processing intervals = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 44);
+ ull = sg_get_unaligned_be64(bp + 44);
ccp = nam ? "write_fua_proc_intervals="
: "write FUA command processing intervals = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 52);
+ ull = sg_get_unaligned_be64(bp + 52);
ccp = nam ? "read_fua_nv_proc_intervals="
: "read FUA_NV command processing intervals = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 60);
+ ull = sg_get_unaligned_be64(bp + 60);
ccp = nam ? "write_fua_nv_proc_intervals="
: "write FUA_NV command processing intervals = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
@@ -3370,11 +3370,11 @@ show_stats_perform_pages(const uint8_t * resp, int len,
ccp = nam ? "parameter_code=6" : "Time interval log "
"parameter for cache stats";
printf("%s\n", ccp);
- ull = sg_get_unaligned_be64(ucp + 4);
+ ull = sg_get_unaligned_be64(bp + 4);
ccp = nam ? "time_interval_neg_exp=" : "time interval "
"negative exponent = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 8);
+ ull = sg_get_unaligned_be64(bp + 8);
ccp = nam ? "time_interval_int=" : "time interval "
"integer = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
@@ -3387,7 +3387,7 @@ show_stats_perform_pages(const uint8_t * resp, int len,
pr2serr("show_performance... unknown parameter code "
"%d\n", param_code);
if (op->verbose)
- dStrHexErr((const char *)ucp, extra, 1);
+ dStrHexErr((const char *)bp, extra, 1);
break;
}
if ((op->do_pcb) && (0 == op->do_name)) {
@@ -3400,21 +3400,21 @@ show_stats_perform_pages(const uint8_t * resp, int len,
} else { /* Group statistics and performance (n) log page */
if (num < 0x34)
return false;
- for (k = num; k > 0; k -= extra, ucp += extra) {
+ for (k = num; k > 0; k -= extra, bp += extra) {
if (k < 3)
return false;
- param_len = ucp[3];
+ param_len = bp[3];
extra = param_len + 4;
- param_code = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
+ param_code = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
if (op->filter_given) {
if (param_code != op->filter)
continue;
if (op->do_raw) {
- dStrRaw((const char *)ucp, extra);
+ dStrRaw((const char *)bp, extra);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, extra,
+ dStrHex((const char *)bp, extra,
((1 == op->do_hex) ? 1 : -1));
break;
}
@@ -3426,27 +3426,27 @@ show_stats_perform_pages(const uint8_t * resp, int len,
else
printf("Group %d Statistics and performance log "
"parameter\n", subpg_code);
- ull = sg_get_unaligned_be64(ucp + 4);
+ ull = sg_get_unaligned_be64(bp + 4);
ccp = nam ? "gn_read_commands=" : "group n number of read "
"commands = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 12);
+ ull = sg_get_unaligned_be64(bp + 12);
ccp = nam ? "gn_write_commands=" : "group n number of write "
"commands = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 20);
+ ull = sg_get_unaligned_be64(bp + 20);
ccp = nam ? "gn_lb_received="
: "group n number of logical blocks received = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 28);
+ ull = sg_get_unaligned_be64(bp + 28);
ccp = nam ? "gn_lb_transmitted="
: "group n number of logical blocks transmitted = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 36);
+ ull = sg_get_unaligned_be64(bp + 36);
ccp = nam ? "gn_read_proc_intervals="
: "group n read command processing intervals = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 44);
+ ull = sg_get_unaligned_be64(bp + 44);
ccp = nam ? "gn_write_proc_intervals="
: "group n write command processing intervals = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
@@ -3455,35 +3455,35 @@ show_stats_perform_pages(const uint8_t * resp, int len,
ccp = nam ? "parameter_code=4" : "Group n force unit access "
"statistics and performance log parameter";
printf("%s\n", ccp);
- ull = sg_get_unaligned_be64(ucp + 4);
+ ull = sg_get_unaligned_be64(bp + 4);
ccp = nam ? "gn_read_fua_commands="
: "group n number of read FUA commands = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 12);
+ ull = sg_get_unaligned_be64(bp + 12);
ccp = nam ? "gn_write_fua_commands="
: "group n number of write FUA commands = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 20);
+ ull = sg_get_unaligned_be64(bp + 20);
ccp = nam ? "gn_read_fua_nv_commands="
: "group n number of read FUA_NV commands = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 28);
+ ull = sg_get_unaligned_be64(bp + 28);
ccp = nam ? "gn_write_fua_nv_commands="
: "group n number of write FUA_NV commands = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 36);
+ ull = sg_get_unaligned_be64(bp + 36);
ccp = nam ? "gn_read_fua_proc_intervals="
: "group n read FUA command processing intervals = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 44);
+ ull = sg_get_unaligned_be64(bp + 44);
ccp = nam ? "gn_write_fua_proc_intervals=" : "group n write "
"FUA command processing intervals = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 52);
+ ull = sg_get_unaligned_be64(bp + 52);
ccp = nam ? "gn_read_fua_nv_proc_intervals=" : "group n "
"read FUA_NV command processing intervals = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
- ull = sg_get_unaligned_be64(ucp + 60);
+ ull = sg_get_unaligned_be64(bp + 60);
ccp = nam ? "gn_write_fua_nv_proc_intervals=" : "group n "
"write FUA_NV command processing intervals = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
@@ -3496,7 +3496,7 @@ show_stats_perform_pages(const uint8_t * resp, int len,
pr2serr("show_performance... unknown parameter code "
"%d\n", param_code);
if (op->verbose)
- dStrHexErr((const char *)ucp, extra, 1);
+ dStrHexErr((const char *)bp, extra, 1);
break;
}
if ((op->do_pcb) && (0 == op->do_name)) {
@@ -3518,14 +3518,14 @@ show_cache_stats_page(const uint8_t * resp, int len, const struct opts_t * op)
int k, num, pc, spf, subpg_code, extra;
int pcb, nam;
unsigned int ui;
- const uint8_t * ucp;
+ const uint8_t * bp;
const char * ccp;
uint64_t ull;
char pcb_str[PCB_STR_LEN];
nam = op->do_name;
num = len - 4;
- ucp = resp + 4;
+ bp = resp + 4;
if (num < 4) {
pr2serr("badly formed Cache memory statistics page\n");
return false;
@@ -3541,27 +3541,27 @@ show_cache_stats_page(const uint8_t * resp, int len, const struct opts_t * op)
printf("Cache memory statistics page [0x19,0x20]\n");
}
- for (k = num; k > 0; k -= extra, ucp += extra) {
+ for (k = num; k > 0; k -= extra, bp += extra) {
if (k < 3) {
pr2serr("short Cache memory statistics page\n");
return false;
}
- if (8 != ucp[3]) {
+ if (8 != bp[3]) {
printf("Cache memory statistics page parameter length not "
"8\n");
return false;
}
- extra = ucp[3] + 4;
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
+ extra = bp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
if (op->filter_given) {
if (pc != op->filter)
continue;
if (op->do_raw) {
- dStrRaw((const char *)ucp, extra);
+ dStrRaw((const char *)bp, extra);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, extra,
+ dStrHex((const char *)bp, extra,
((1 == op->do_hex) ? 1 : -1));
break;
}
@@ -3571,7 +3571,7 @@ show_cache_stats_page(const uint8_t * resp, int len, const struct opts_t * op)
ccp = nam ? "parameter_code=1" :
"Read cache memory hits log parameter";
printf("%s\n", ccp);
- ull = sg_get_unaligned_be64(ucp + 4);
+ ull = sg_get_unaligned_be64(bp + 4);
ccp = nam ? "read_cache_memory_hits=" :
"read cache memory hits = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
@@ -3580,7 +3580,7 @@ show_cache_stats_page(const uint8_t * resp, int len, const struct opts_t * op)
ccp = nam ? "parameter_code=2" :
"Reads to cache memory log parameter";
printf("%s\n", ccp);
- ull = sg_get_unaligned_be64(ucp + 4);
+ ull = sg_get_unaligned_be64(bp + 4);
ccp = nam ? "reads_to_cache_memory=" :
"reads to cache memory = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
@@ -3589,7 +3589,7 @@ show_cache_stats_page(const uint8_t * resp, int len, const struct opts_t * op)
ccp = nam ? "parameter_code=3" :
"Write cache memory hits log parameter";
printf("%s\n", ccp);
- ull = sg_get_unaligned_be64(ucp + 4);
+ ull = sg_get_unaligned_be64(bp + 4);
ccp = nam ? "write_cache_memory_hits=" :
"write cache memory hits = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
@@ -3598,7 +3598,7 @@ show_cache_stats_page(const uint8_t * resp, int len, const struct opts_t * op)
ccp = nam ? "parameter_code=4" :
"Writes from cache memory log parameter";
printf("%s\n", ccp);
- ull = sg_get_unaligned_be64(ucp + 4);
+ ull = sg_get_unaligned_be64(bp + 4);
ccp = nam ? "writes_from_cache_memory=" :
"writes from cache memory = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
@@ -3607,7 +3607,7 @@ show_cache_stats_page(const uint8_t * resp, int len, const struct opts_t * op)
ccp = nam ? "parameter_code=5" :
"Time from last hard reset log parameter";
printf("%s\n", ccp);
- ull = sg_get_unaligned_be64(ucp + 4);
+ ull = sg_get_unaligned_be64(bp + 4);
ccp = nam ? "time_from_last_hard_reset=" :
"time from last hard reset = ";
printf(" %s%" PRIu64 "\n", ccp, ull);
@@ -3616,11 +3616,11 @@ show_cache_stats_page(const uint8_t * resp, int len, const struct opts_t * op)
ccp = nam ? "parameter_code=6" :
"Time interval log parameter";
printf("%s\n", ccp);
- ui = sg_get_unaligned_be32(ucp + 4);
+ ui = sg_get_unaligned_be32(bp + 4);
ccp = nam ? "time_interval_neg_exp=" : "time interval "
"negative exponent = ";
printf(" %s%u\n", ccp, ui);
- ui = sg_get_unaligned_be32(ucp + 8);
+ ui = sg_get_unaligned_be32(bp + 8);
ccp = nam ? "time_interval_int=" : "time interval "
"integer = ";
printf(" %s%u\n", ccp, ui);
@@ -3633,7 +3633,7 @@ show_cache_stats_page(const uint8_t * resp, int len, const struct opts_t * op)
pr2serr("show_performance... unknown parameter code %d\n",
pc);
if (op->verbose)
- dStrHexErr((const char *)ucp, extra, 1);
+ dStrHexErr((const char *)bp, extra, 1);
break;
}
if ((op->do_pcb) && (0 == op->do_name)) {
@@ -3652,7 +3652,7 @@ show_format_status_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int k, j, num, pl, pc, pcb, all_ff, counter;
- const uint8_t * ucp;
+ const uint8_t * bp;
const uint8_t * xp;
uint64_t ull;
char pcb_str[PCB_STR_LEN];
@@ -3660,19 +3660,19 @@ show_format_status_page(const uint8_t * resp, int len,
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Format status page [0x8]\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
@@ -3683,7 +3683,7 @@ show_format_status_page(const uint8_t * resp, int len,
printf(" Format data out: <empty>\n");
else {
for (all_ff = 1, j = 4; j < pl; ++j) {
- if (0xff != ucp[j]) {
+ if (0xff != bp[j]) {
all_ff = 0;
break;
}
@@ -3692,7 +3692,7 @@ show_format_status_page(const uint8_t * resp, int len,
printf(" Format data out: <not available>\n");
else {
printf(" Format data out:\n");
- dStrHex((const char *)ucp + 4, pl - 4, 0);
+ dStrHex((const char *)bp + 4, pl - 4, 0);
}
}
counter = 0;
@@ -3712,12 +3712,12 @@ show_format_status_page(const uint8_t * resp, int len,
default:
printf(" Unknown Format status code = 0x%x\n", pc);
counter = 0;
- dStrHex((const char *)ucp, pl, 0);
+ dStrHex((const char *)bp, pl, 0);
break;
}
if (counter) {
k = pl - 4;
- xp = ucp + 4;
+ xp = bp + 4;
if (k > (int)sizeof(ull)) {
xp += (k - sizeof(ull));
k = sizeof(ull);
@@ -3751,7 +3751,7 @@ show_format_status_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -3762,33 +3762,33 @@ show_non_volatile_cache_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int j, num, pl, pc, pcb;
- const uint8_t * ucp;
+ const uint8_t * bp;
char pcb_str[PCB_STR_LEN];
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Non-volatile cache page [0x17]\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
switch (pc) {
case 0:
printf(" Remaining non-volatile time: ");
- if (3 == ucp[4]) {
- j = sg_get_unaligned_be24(ucp + 5);
+ if (3 == bp[4]) {
+ j = sg_get_unaligned_be24(bp + 5);
switch (j) {
case 0:
printf("0 (i.e. it is now volatile)\n");
@@ -3804,12 +3804,12 @@ show_non_volatile_cache_page(const uint8_t * resp, int len,
break;
}
} else
- printf("<unexpected parameter length=%d>\n", ucp[4]);
+ printf("<unexpected parameter length=%d>\n", bp[4]);
break;
case 1:
printf(" Maximum non-volatile time: ");
- if (3 == ucp[4]) {
- j = sg_get_unaligned_be24(ucp + 5);
+ if (3 == bp[4]) {
+ j = sg_get_unaligned_be24(bp + 5);
switch (j) {
case 0:
printf("0 (i.e. it is now volatile)\n");
@@ -3825,11 +3825,11 @@ show_non_volatile_cache_page(const uint8_t * resp, int len,
break;
}
} else
- printf("<unexpected parameter length=%d>\n", ucp[4]);
+ printf("<unexpected parameter length=%d>\n", bp[4]);
break;
default:
printf(" Unknown Format status code = 0x%x\n", pc);
- dStrHex((const char *)ucp, pl, 0);
+ dStrHex((const char *)bp, pl, 0);
break;
}
if (op->do_pcb) {
@@ -3840,7 +3840,7 @@ show_non_volatile_cache_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -3851,26 +3851,26 @@ show_lb_provisioning_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int num, pl, pc, pcb;
- const uint8_t * ucp;
+ const uint8_t * bp;
const char * cp;
char str[PCB_STR_LEN];
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Logical block provisioning page [0xc]\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
@@ -3908,13 +3908,13 @@ show_lb_provisioning_page(const uint8_t * resp, int len,
break;
}
if (0x3 == pc)
- printf(" %s: %u %%\n", cp, sg_get_unaligned_be16(ucp + 4));
+ printf(" %s: %u %%\n", cp, sg_get_unaligned_be16(bp + 4));
else {
printf(" %s resource count:", cp);
- printf(" %u\n", sg_get_unaligned_be32(ucp + 4));
+ printf(" %u\n", sg_get_unaligned_be32(bp + 4));
}
if (pl > 8) {
- switch (ucp[8] & 0x3) {
+ switch (bp[8] & 0x3) {
case 0: cp = "not reported"; break;
case 1: cp = "dedicated to lu"; break;
case 2: cp = "not dedicated to lu"; break;
@@ -3924,10 +3924,10 @@ show_lb_provisioning_page(const uint8_t * resp, int len,
}
} else if ((pc >= 0xfff0) && (pc <= 0xffff)) {
printf(" Vendor specific [0x%x]:", pc);
- dStrHex((const char *)ucp, ((pl < num) ? pl : num), 0);
+ dStrHex((const char *)bp, ((pl < num) ? pl : num), 0);
} else {
printf(" Reserved [parameter_code=0x%x]:\n", pc);
- dStrHex((const char *)ucp, ((pl < num) ? pl : num), 0);
+ dStrHex((const char *)bp, ((pl < num) ? pl : num), 0);
}
if (op->do_pcb) {
get_pcb_str(pcb, str, sizeof(str));
@@ -3937,7 +3937,7 @@ show_lb_provisioning_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -3947,25 +3947,25 @@ static bool
show_utilization_page(const uint8_t * resp, int len, const struct opts_t * op)
{
int num, pl, pc, pcb, k;
- const uint8_t * ucp;
+ const uint8_t * bp;
char str[PCB_STR_LEN];
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Utilization page [0xe,0x1]\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
@@ -3981,7 +3981,7 @@ show_utilization_page(const uint8_t * resp, int len, const struct opts_t * op)
pl);
break;
}
- k = sg_get_unaligned_be16(ucp + 4);
+ k = sg_get_unaligned_be16(bp + 4);
printf(" %d.%02d %%\n", k / 100, k % 100);
break;
case 0x1:
@@ -3995,11 +3995,11 @@ show_utilization_page(const uint8_t * resp, int len, const struct opts_t * op)
pl);
break;
}
- printf(" %d %%\n", ucp[4]);
+ printf(" %d %%\n", bp[4]);
break;
default:
printf(" Reserved [parameter_code=0x%x]:\n", pc);
- dStrHex((const char *)ucp, ((pl < num) ? pl : num), 0);
+ dStrHex((const char *)bp, ((pl < num) ? pl : num), 0);
break;
}
if (op->do_pcb) {
@@ -4010,7 +4010,7 @@ show_utilization_page(const uint8_t * resp, int len, const struct opts_t * op)
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -4021,25 +4021,25 @@ show_solid_state_media_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int num, pl, pc, pcb;
- const uint8_t * ucp;
+ const uint8_t * bp;
char str[PCB_STR_LEN];
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Solid state media page [0x11]\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
@@ -4055,11 +4055,11 @@ show_solid_state_media_page(const uint8_t * resp, int len,
pl);
break;
}
- printf(" %u %%\n", ucp[7]);
+ printf(" %u %%\n", bp[7]);
break;
default:
printf(" Reserved [parameter_code=0x%x]:\n", pc);
- dStrHex((const char *)ucp, ((pl < num) ? pl : num), 0);
+ dStrHex((const char *)bp, ((pl < num) ? pl : num), 0);
break;
}
if (op->do_pcb) {
@@ -4070,7 +4070,7 @@ show_solid_state_media_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -4101,26 +4101,26 @@ show_dt_device_status_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int num, pl, pc, pcb, j;
- const uint8_t * ucp;
+ const uint8_t * bp;
char str[PCB_STR_LEN];
char b[64];
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("DT device status page (ssc-3, adc-3) [0x11]\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
@@ -4136,16 +4136,16 @@ show_dt_device_status_page(const uint8_t * resp, int len,
pl);
break;
}
- printf(" PAMR=%d HUI=%d MACC=%d CMPR=%d ", !!(0x80 & ucp[4]),
- !!(0x40 & ucp[4]), !!(0x20 & ucp[4]), !!(0x10 & ucp[4]));
- printf("WRTP=%d CRQST=%d CRQRD=%d DINIT=%d\n", !!(0x8 & ucp[4]),
- !!(0x4 & ucp[4]), !!(0x2 & ucp[4]), !!(0x1 & ucp[4]));
- printf(" INXTN=%d RAA=%d MPRSNT=%d ", !!(0x80 & ucp[5]),
- !!(0x20 & ucp[5]), !!(0x10 & ucp[5]));
+ printf(" PAMR=%d HUI=%d MACC=%d CMPR=%d ", !!(0x80 & bp[4]),
+ !!(0x40 & bp[4]), !!(0x20 & bp[4]), !!(0x10 & bp[4]));
+ printf("WRTP=%d CRQST=%d CRQRD=%d DINIT=%d\n", !!(0x8 & bp[4]),
+ !!(0x4 & bp[4]), !!(0x2 & bp[4]), !!(0x1 & bp[4]));
+ printf(" INXTN=%d RAA=%d MPRSNT=%d ", !!(0x80 & bp[5]),
+ !!(0x20 & bp[5]), !!(0x10 & bp[5]));
printf("MSTD=%d MTHRD=%d MOUNTED=%d\n",
- !!(0x4 & ucp[5]), !!(0x2 & ucp[5]), !!(0x1 & ucp[5]));
+ !!(0x4 & bp[5]), !!(0x2 & bp[5]), !!(0x1 & bp[5]));
printf(" DT device activity: ");
- j = ucp[6];
+ j = bp[6];
if (j < (int)(sizeof(dt_dev_activity) /
sizeof(dt_dev_activity[0])))
printf("%s\n", dt_dev_activity[j]);
@@ -4153,10 +4153,10 @@ show_dt_device_status_page(const uint8_t * resp, int len,
printf("Reserved [0x%x]\n", j);
else
printf("Vendor specific [0x%x]\n", j);
- printf(" VS=%d TDDEC=%d EPP=%d ", !!(0x80 & ucp[7]),
- !!(0x20 & ucp[7]), !!(0x10 & ucp[7]));
- printf("ESR=%d RRQST=%d INTFC=%d TAFC=%d\n", !!(0x8 & ucp[7]),
- !!(0x4 & ucp[7]), !!(0x2 & ucp[7]), !!(0x1 & ucp[7]));
+ printf(" VS=%d TDDEC=%d EPP=%d ", !!(0x80 & bp[7]),
+ !!(0x20 & bp[7]), !!(0x10 & bp[7]));
+ printf("ESR=%d RRQST=%d INTFC=%d TAFC=%d\n", !!(0x8 & bp[7]),
+ !!(0x4 & bp[7]), !!(0x2 & bp[7]), !!(0x1 & bp[7]));
break;
case 0x1:
printf(" Very high frequency polling delay: ");
@@ -4169,7 +4169,7 @@ show_dt_device_status_page(const uint8_t * resp, int len,
pl);
break;
}
- printf(" %d milliseconds\n", sg_get_unaligned_be16(ucp + 4));
+ printf(" %d milliseconds\n", sg_get_unaligned_be16(bp + 4));
break;
case 0x2:
printf(" DT device ADC data encryption control status (hex "
@@ -4183,7 +4183,7 @@ show_dt_device_status_page(const uint8_t * resp, int len,
pl);
break;
}
- dStrHex((const char *)ucp + 4, 8, 1);
+ dStrHex((const char *)bp + 4, 8, 1);
break;
case 0x3:
printf(" Key management error data (hex only now):\n");
@@ -4196,32 +4196,32 @@ show_dt_device_status_page(const uint8_t * resp, int len,
pl);
break;
}
- dStrHex((const char *)ucp + 4, 12, 1);
+ dStrHex((const char *)bp + 4, 12, 1);
break;
default:
if ((pc >= 0x101) && (pc <= 0x1ff)) {
printf(" Primary port %d status:\n", pc - 0x100);
- if (12 == ucp[3]) { /* if length of desc is 12, assume SAS */
+ if (12 == bp[3]) { /* if length of desc is 12, assume SAS */
printf(" SAS: negotiated physical link rate: %s\n",
- sas_negot_link_rate((0xf & (ucp[4] >> 4)), b,
+ sas_negot_link_rate((0xf & (bp[4] >> 4)), b,
sizeof(b)));
- printf(" signal=%d, pic=%d, ", !!(0x2 & ucp[4]),
- !!(0x1 & ucp[4]));
+ printf(" signal=%d, pic=%d, ", !!(0x2 & bp[4]),
+ !!(0x1 & bp[4]));
printf("hashed SAS addr: 0x%u\n",
- sg_get_unaligned_be24(ucp + 5));
+ sg_get_unaligned_be24(bp + 5));
printf(" SAS addr: 0x%" PRIx64 "\n",
- sg_get_unaligned_be64(ucp + 8));
+ sg_get_unaligned_be64(bp + 8));
} else {
printf(" non-SAS transport, in hex:\n");
- dStrHex((const char *)ucp + 4,
+ dStrHex((const char *)bp + 4,
((pl < num) ? pl : num) - 4, 0);
}
} else if (pc >= 0x8000) {
printf(" Vendor specific [parameter_code=0x%x]:\n", pc);
- dStrHex((const char *)ucp, ((pl < num) ? pl : num), 0);
+ dStrHex((const char *)bp, ((pl < num) ? pl : num), 0);
} else {
printf(" Reserved [parameter_code=0x%x]:\n", pc);
- dStrHex((const char *)ucp, ((pl < num) ? pl : num), 0);
+ dStrHex((const char *)bp, ((pl < num) ? pl : num), 0);
}
break;
}
@@ -4233,7 +4233,7 @@ show_dt_device_status_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -4244,25 +4244,25 @@ show_tapealert_response_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int num, pl, pc, pcb, k, mod, div;
- const uint8_t * ucp;
+ const uint8_t * bp;
char str[PCB_STR_LEN];
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("TapeAlert response page (ssc-3, adc-3) [0x12]\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
@@ -4277,20 +4277,20 @@ show_tapealert_response_page(const uint8_t * resp, int len,
if (0 == mod) {
if (div > 0)
printf("\n");
- printf(" Flag%02Xh: %d", k, !! (ucp[4 + div] & 0x80));
+ printf(" Flag%02Xh: %d", k, !! (bp[4 + div] & 0x80));
} else
printf(" %02Xh: %d", k,
- !! (ucp[4 + div] & (1 << (7 - mod))));
+ !! (bp[4 + div] & (1 << (7 - mod))));
}
printf("\n");
break;
default:
if (pc <= 0x8000) {
printf(" Reserved [parameter_code=0x%x]:\n", pc);
- dStrHex((const char *)ucp, ((pl < num) ? pl : num), 0);
+ dStrHex((const char *)bp, ((pl < num) ? pl : num), 0);
} else {
printf(" Vendor specific [parameter_code=0x%x]:\n", pc);
- dStrHex((const char *)ucp, ((pl < num) ? pl : num), 0);
+ dStrHex((const char *)bp, ((pl < num) ? pl : num), 0);
}
break;
}
@@ -4302,7 +4302,7 @@ show_tapealert_response_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -4336,25 +4336,25 @@ show_requested_recovery_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int num, pl, pc, pcb, j, k;
- const uint8_t * ucp;
+ const uint8_t * bp;
char str[PCB_STR_LEN];
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Requested recovery page (ssc-3) [0x13]\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
@@ -4362,7 +4362,7 @@ show_requested_recovery_page(const uint8_t * resp, int len,
case 0x0:
printf(" Recovery procedures:\n");
for (k = 4; k < pl; ++ k) {
- j = ucp[k];
+ j = bp[k];
if (j < NUM_REQ_REC_ARR_ELEMS)
printf(" %s\n", req_rec_arr[j]);
else if (j < 0x80)
@@ -4374,10 +4374,10 @@ show_requested_recovery_page(const uint8_t * resp, int len,
default:
if (pc <= 0x8000) {
printf(" Reserved [parameter_code=0x%x]:\n", pc);
- dStrHex((const char *)ucp, ((pl < num) ? pl : num), 0);
+ dStrHex((const char *)bp, ((pl < num) ? pl : num), 0);
} else {
printf(" Vendor specific [parameter_code=0x%x]:\n", pc);
- dStrHex((const char *)ucp, ((pl < num) ? pl : num), 0);
+ dStrHex((const char *)bp, ((pl < num) ? pl : num), 0);
}
break;
}
@@ -4389,7 +4389,7 @@ show_requested_recovery_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -4400,26 +4400,26 @@ show_ata_pt_results_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int num, pl, pc, pcb;
- const uint8_t * ucp;
+ const uint8_t * bp;
const uint8_t * dp;
char str[PCB_STR_LEN];
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("ATA pass-through results page (sat-2) [0x16]\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
@@ -4427,7 +4427,7 @@ show_ata_pt_results_page(const uint8_t * resp, int len,
int extend, count;
printf(" Log_index=0x%x (parameter_code=0x%x)\n", pc + 1, pc);
- dp = ucp + 4; /* dp is start of ATA Return descriptor
+ dp = bp + 4; /* dp is start of ATA Return descriptor
* which is 14 bytes long */
extend = dp[2] & 1;
count = dp[5] + (extend ? (dp[4] << 8) : 0);
@@ -4441,11 +4441,11 @@ show_ata_pt_results_page(const uint8_t * resp, int len,
printf(" device=0x%x status=0x%x\n", dp[12], dp[13]);
} else if (pl > 17) {
printf(" Reserved [parameter_code=0x%x]:\n", pc);
- dStrHex((const char *)ucp, ((pl < num) ? pl : num), 0);
+ dStrHex((const char *)bp, ((pl < num) ? pl : num), 0);
} else {
printf(" short parameter length: %d [parameter_code=0x%x]:\n",
pl, pc);
- dStrHex((const char *)ucp, ((pl < num) ? pl : num), 0);
+ dStrHex((const char *)bp, ((pl < num) ? pl : num), 0);
}
if (op->do_pcb) {
get_pcb_str(pcb, str, sizeof(str));
@@ -4455,7 +4455,7 @@ show_ata_pt_results_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -4493,25 +4493,25 @@ show_background_scan_results_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int j, m, num, pl, pc, pcb;
- const uint8_t * ucp;
+ const uint8_t * bp;
char str[PCB_STR_LEN];
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Background scan results page [0x15]\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
@@ -4528,17 +4528,17 @@ show_background_scan_results_page(const uint8_t * resp, int len,
break;
}
printf(" Accumulated power on minutes: ");
- j = sg_get_unaligned_be32(ucp + 4);
+ j = sg_get_unaligned_be32(bp + 4);
printf("%d [h:m %d:%d]\n", j, (j / 60), (j % 60));
printf(" Status: ");
- j = ucp[9];
+ j = bp[9];
if (j < (int)(sizeof(bms_status) / sizeof(bms_status[0])))
printf("%s\n", bms_status[j]);
else
printf("unknown [0x%x] background scan status value\n", j);
- j = sg_get_unaligned_be16(ucp + 10);
+ j = sg_get_unaligned_be16(bp + 10);
printf(" Number of background scans performed: %d\n", j);
- j = sg_get_unaligned_be16(ucp + 12);
+ j = sg_get_unaligned_be16(bp + 12);
#ifdef SG_LIB_MINGW
printf(" Background medium scan progress: %g %%\n",
(double)(j * 100.0 / 65536.0));
@@ -4546,7 +4546,7 @@ show_background_scan_results_page(const uint8_t * resp, int len,
printf(" Background medium scan progress: %.2f %%\n",
(double)(j * 100.0 / 65536.0));
#endif
- j = sg_get_unaligned_be16(ucp + 14);
+ j = sg_get_unaligned_be16(bp + 14);
if (0 == j)
printf(" Number of background medium scans performed: 0 "
"[not reported]\n");
@@ -4562,7 +4562,7 @@ show_background_scan_results_page(const uint8_t * resp, int len,
else
printf(" Medium scan parameter # %d [0x%x], "
"reserved\n", pc, pc);
- dStrHex((const char *)ucp, ((pl < num) ? pl : num), 0);
+ dStrHex((const char *)bp, ((pl < num) ? pl : num), 0);
break;
} else
printf(" Medium scan parameter # %d [0x%x]\n", pc, pc);
@@ -4576,29 +4576,29 @@ show_background_scan_results_page(const uint8_t * resp, int len,
break;
}
printf(" Power on minutes when error detected: ");
- j = sg_get_unaligned_be32(ucp + 4);
+ j = sg_get_unaligned_be32(bp + 4);
printf("%d [%d:%d]\n", j, (j / 60), (j % 60));
- j = (ucp[8] >> 4) & 0xf;
+ j = (bp[8] >> 4) & 0xf;
if (j <
(int)(sizeof(reassign_status) / sizeof(reassign_status[0])))
printf(" %s\n", reassign_status[j]);
else
printf(" Reassign status: reserved [0x%x]\n", j);
printf(" sense key: %s [sk,asc,ascq: 0x%x,0x%x,0x%x]\n",
- sg_get_sense_key_str(ucp[8] & 0xf, sizeof(str), str),
- ucp[8] & 0xf, ucp[9], ucp[10]);
- if (ucp[9] || ucp[10])
- printf(" %s\n", sg_get_asc_ascq_str(ucp[9], ucp[10],
+ sg_get_sense_key_str(bp[8] & 0xf, sizeof(str), str),
+ bp[8] & 0xf, bp[9], bp[10]);
+ if (bp[9] || bp[10])
+ printf(" %s\n", sg_get_asc_ascq_str(bp[9], bp[10],
sizeof(str), str));
if (op->verbose) {
printf(" vendor bytes [11 -> 15]: ");
for (m = 0; m < 5; ++m)
- printf("0x%02x ", ucp[11 + m]);
+ printf("0x%02x ", bp[11 + m]);
printf("\n");
}
printf(" LBA (associated with medium error): 0x");
for (m = 0; m < 8; ++m)
- printf("%02x", ucp[16 + m]);
+ printf("%02x", bp[16 + m]);
printf("\n");
break;
}
@@ -4610,7 +4610,7 @@ show_background_scan_results_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -4621,25 +4621,25 @@ show_pending_defects_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int num, pl, pc, pcb;
- const uint8_t * ucp;
+ const uint8_t * bp;
char str[PCB_STR_LEN];
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Pending defects page [0x15,0x1]\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
@@ -4655,7 +4655,7 @@ show_pending_defects_page(const uint8_t * resp, int len,
pl);
break;
}
- printf(" %u\n", sg_get_unaligned_be32(ucp + 4));
+ printf(" %u\n", sg_get_unaligned_be32(bp + 4));
break;
default:
printf(" Pending defect: %d\n", pc);
@@ -4669,8 +4669,8 @@ show_pending_defects_page(const uint8_t * resp, int len,
break;
}
printf(" LBA: 0x%" PRIx64 " accumulated_power_on_hours: %u\n",
- sg_get_unaligned_be64(ucp + 8),
- sg_get_unaligned_be32(ucp + 4));
+ sg_get_unaligned_be64(bp + 8),
+ sg_get_unaligned_be32(bp + 4));
break;
}
if (op->do_pcb) {
@@ -4681,7 +4681,7 @@ show_pending_defects_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -4692,25 +4692,25 @@ show_background_op_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int num, pl, pc, pcb;
- const uint8_t * ucp;
+ const uint8_t * bp;
char str[PCB_STR_LEN];
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Background operation page [0x15,0x2]\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
@@ -4726,11 +4726,11 @@ show_background_op_page(const uint8_t * resp, int len,
pl);
break;
}
- printf(" BO_STATUS=%d\n", ucp[4]);
+ printf(" BO_STATUS=%d\n", bp[4]);
break;
default:
printf(" Reserved [parameter_code=0x%x]:\n", pc);
- dStrHex((const char *)ucp, ((pl < num) ? pl : num), 0);
+ dStrHex((const char *)bp, ((pl < num) ? pl : num), 0);
break;
}
if (op->do_pcb) {
@@ -4741,7 +4741,7 @@ show_background_op_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -4752,49 +4752,49 @@ show_lps_misalignment_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int num, pl, pc, pcb;
- const uint8_t * ucp;
+ const uint8_t * bp;
char pcb_str[PCB_STR_LEN];
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("LPS misalignment page [0x15,0x3]\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
switch (pc) {
case 0x0:
printf(" LPS misalignment count: ");
- if (4 == ucp[3])
+ if (4 == bp[3])
printf("max lpsm: %" PRIu16 ", count=%" PRIu16 "\n",
- sg_get_unaligned_be16(ucp + 4),
- sg_get_unaligned_be16(ucp + 6));
+ sg_get_unaligned_be16(bp + 4),
+ sg_get_unaligned_be16(bp + 6));
else
- printf("<unexpected pc=0 parameter length=%d>\n", ucp[4]);
+ printf("<unexpected pc=0 parameter length=%d>\n", bp[4]);
break;
default:
if (pc <= 0xf000) {
- if (8 == ucp[3])
+ if (8 == bp[3])
printf(" LBA of misaligned block: 0x%" PRIx64 "\n",
- sg_get_unaligned_be64(ucp + 8));
+ sg_get_unaligned_be64(bp + 8));
else
printf("<unexpected pc=0x%x parameter length=%d>\n",
- pc, ucp[4]);
+ pc, bp[4]);
} else {
printf("<unexpected pc=0x%x>\n", pc);
- dStrHex((const char *)ucp, pl, 0);
+ dStrHex((const char *)bp, pl, 0);
}
break;
}
@@ -4806,7 +4806,7 @@ show_lps_misalignment_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -4817,44 +4817,44 @@ show_service_buffer_info_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int num, pl, pc, pcb;
- const uint8_t * ucp;
+ const uint8_t * bp;
char str[PCB_STR_LEN];
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Service buffer information page (adc-3) [0x15]\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
if (pc < 0x100) {
printf(" Service buffer identifier: 0x%x\n", pc);
printf(" Buffer id: 0x%x, tu=%d, nmp=%d, nmm=%d, "
- "offline=%d\n", ucp[4], !!(0x10 & ucp[5]),
- !!(0x8 & ucp[5]), !!(0x4 & ucp[5]), !!(0x2 & ucp[5]));
+ "offline=%d\n", bp[4], !!(0x10 & bp[5]),
+ !!(0x8 & bp[5]), !!(0x4 & bp[5]), !!(0x2 & bp[5]));
printf(" pd=%d, code_set: %s, Service buffer title:\n",
- !!(0x1 & ucp[5]), sg_get_desig_code_set_str(0xf & ucp[6]));
- printf(" %.*s\n", pl - 8, ucp + 8);
+ !!(0x1 & bp[5]), sg_get_desig_code_set_str(0xf & bp[6]));
+ printf(" %.*s\n", pl - 8, bp + 8);
} else if (pc < 0x8000) {
printf(" parameter_code=0x%x, Reserved, parameter in hex:\n",
pc);
- dStrHex((const char *)ucp + 4, pl - 4, 0);
+ dStrHex((const char *)bp + 4, pl - 4, 0);
} else {
printf(" parameter_code=0x%x, Vendor-specific, parameter in "
"hex:\n", pc);
- dStrHex((const char *)ucp + 4, pl - 4, 0);
+ dStrHex((const char *)bp + 4, pl - 4, 0);
}
if (op->do_pcb) {
get_pcb_str(pcb, str, sizeof(str));
@@ -4864,7 +4864,7 @@ show_service_buffer_info_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -4875,7 +4875,7 @@ show_sequential_access_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int num, pl, pc, pcb;
- const uint8_t * ucp;
+ const uint8_t * bp;
uint64_t ull, gbytes;
bool all_set;
char pcb_str[PCB_STR_LEN];
@@ -4883,24 +4883,24 @@ show_sequential_access_page(const uint8_t * resp, int len,
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Sequential access device page (ssc-3)\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
- ull = sg_get_unaligned_be(pl - 4, ucp + 4);
- all_set = all_bits_set(ucp + 4, pl - 4);
+ ull = sg_get_unaligned_be(pl - 4, bp + 4);
+ all_set = all_bits_set(bp + 4, pl - 4);
gbytes = ull / 1000000000;
switch (pc) {
case 0:
@@ -4981,7 +4981,7 @@ show_sequential_access_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -4992,31 +4992,31 @@ show_device_stats_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int num, pl, pc, pcb;
- const uint8_t * ucp;
+ const uint8_t * bp;
uint64_t ull;
char pcb_str[PCB_STR_LEN];
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Device statistics page (ssc-3 and adc)\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
if (pc < 0x1000) {
- ull = sg_get_unaligned_be(pl - 4, ucp + 4);
+ ull = sg_get_unaligned_be(pl - 4, bp + 4);
switch (pc) {
case 0:
printf(" Lifetime media loads: %" PRIu64 "\n", ull);
@@ -5128,7 +5128,7 @@ show_device_stats_page(const uint8_t * resp, int len,
}
} else {
int k;
- const uint8_t * p = ucp + 4;
+ const uint8_t * p = bp + 4;
switch (pc) {
case 0x1000:
@@ -5146,7 +5146,7 @@ show_device_stats_page(const uint8_t * resp, int len,
"hex:\n", pc);
else
printf(" Reserved parameter [0x%x], dump in hex:\n", pc);
- dStrHex((const char *)ucp, pl, 0);
+ dStrHex((const char *)bp, pl, 0);
break;
}
}
@@ -5158,7 +5158,7 @@ show_device_stats_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -5168,30 +5168,30 @@ static bool
show_media_stats_page(const uint8_t * resp, int len, const struct opts_t * op)
{
int num, pl, pc, pcb;
- const uint8_t * ucp;
+ const uint8_t * bp;
uint64_t ull;
char pcb_str[PCB_STR_LEN];
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Media statistics page (smc-3)\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
- ull = sg_get_unaligned_be(pl - 4, ucp + 4);
+ ull = sg_get_unaligned_be(pl - 4, bp + 4);
switch (pc) {
case 0:
printf(" Number of moves: %" PRIu64 "\n", ull);
@@ -5296,7 +5296,7 @@ show_media_stats_page(const uint8_t * resp, int len, const struct opts_t * op)
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -5308,40 +5308,40 @@ show_element_stats_page(const uint8_t * resp, int len,
{
int num, pl, pc, pcb;
unsigned int v;
- const uint8_t * ucp;
+ const uint8_t * bp;
char str[PCB_STR_LEN];
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Element statistics page (smc-3) [0x15]\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
printf(" Element address: %d\n", pc);
- v = sg_get_unaligned_be32(ucp + 4);
+ v = sg_get_unaligned_be32(bp + 4);
printf(" Number of places: %u\n", v);
- v = sg_get_unaligned_be32(ucp + 8);
+ v = sg_get_unaligned_be32(bp + 8);
printf(" Number of place retries: %u\n", v);
- v = sg_get_unaligned_be32(ucp + 12);
+ v = sg_get_unaligned_be32(bp + 12);
printf(" Number of picks: %u\n", v);
- v = sg_get_unaligned_be32(ucp + 16);
+ v = sg_get_unaligned_be32(bp + 16);
printf(" Number of pick retries: %u\n", v);
- v = sg_get_unaligned_be32(ucp + 20);
+ v = sg_get_unaligned_be32(bp + 20);
printf(" Number of determined volume identifiers: %u\n", v);
- v = sg_get_unaligned_be32(ucp + 24);
+ v = sg_get_unaligned_be32(bp + 24);
printf(" Number of unreadable volume identifiers: %u\n", v);
if (op->do_pcb) {
get_pcb_str(pcb, str, sizeof(str));
@@ -5351,7 +5351,7 @@ show_element_stats_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -5363,78 +5363,78 @@ show_tape_diag_data_page(const uint8_t * resp, int len,
{
int k, num, pl, pc, pcb;
unsigned int v;
- const uint8_t * ucp;
+ const uint8_t * bp;
char str[PCB_STR_LEN];
char b[80];
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Tape diagnostics data page (ssc-3) [0x16]\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
printf(" Parameter code: %d\n", pc);
- printf(" Density code: 0x%x\n", ucp[6]);
- printf(" Medium type: 0x%x\n", ucp[7]);
- v = sg_get_unaligned_be32(ucp + 8);
+ printf(" Density code: 0x%x\n", bp[6]);
+ printf(" Medium type: 0x%x\n", bp[7]);
+ v = sg_get_unaligned_be32(bp + 8);
printf(" Lifetime media motion hours: %u\n", v);
- printf(" Repeat: %d\n", !!(ucp[13] & 0x80));
- v = ucp[13] & 0xf;
+ printf(" Repeat: %d\n", !!(bp[13] & 0x80));
+ v = bp[13] & 0xf;
printf(" Sense key: 0x%x [%s]\n", v,
sg_get_sense_key_str(v, sizeof(b), b));
- printf(" Additional sense code: 0x%x\n", ucp[14]);
- printf(" Additional sense code qualifier: 0x%x\n", ucp[15]);
- if (ucp[14] || ucp[15])
- printf(" [%s]\n", sg_get_asc_ascq_str(ucp[14], ucp[15],
+ printf(" Additional sense code: 0x%x\n", bp[14]);
+ printf(" Additional sense code qualifier: 0x%x\n", bp[15]);
+ if (bp[14] || bp[15])
+ printf(" [%s]\n", sg_get_asc_ascq_str(bp[14], bp[15],
sizeof(b), b));
- v = sg_get_unaligned_be32(ucp + 16);
+ v = sg_get_unaligned_be32(bp + 16);
printf(" Vendor specific code qualifier: 0x%x\n", v);
- v = sg_get_unaligned_be32(ucp + 20);
+ v = sg_get_unaligned_be32(bp + 20);
printf(" Product revision level: %u\n", v);
- v = sg_get_unaligned_be32(ucp + 24);
+ v = sg_get_unaligned_be32(bp + 24);
printf(" Hours since last clean: %u\n", v);
- printf(" Operation code: 0x%x\n", ucp[28]);
- printf(" Service action: 0x%x\n", ucp[29] & 0xf);
+ printf(" Operation code: 0x%x\n", bp[28]);
+ printf(" Service action: 0x%x\n", bp[29] & 0xf);
// Check Medium id number for all zeros
// ssc4r03.pdf does not define this field, why? xxxxxx
for (k = 32; k < 64; ++k) {
- if(ucp[k])
+ if(bp[k])
break;
}
if (64 == k)
printf(" Medium id number is 32 bytes of zero\n");
else {
printf(" Medium id number (in hex):\n");
- dStrHex((const char *)(ucp + 32), 32, 0);
+ dStrHex((const char *)(bp + 32), 32, 0);
}
- printf(" Timestamp origin: 0x%x\n", ucp[64] & 0xf);
+ printf(" Timestamp origin: 0x%x\n", bp[64] & 0xf);
// Check Timestamp for all zeros
for (k = 66; k < 72; ++k) {
- if(ucp[k])
+ if(bp[k])
break;
}
if (72 == k)
printf(" Timestamp is all zeros:\n");
else {
printf(" Timestamp:\n");
- dStrHex((const char *)(ucp + 66), 6, 1);
+ dStrHex((const char *)(bp + 66), 6, 1);
}
if (pl > 72) {
printf(" Vendor specific:\n");
- dStrHex((const char *)(ucp + 72), pl - 72, 0);
+ dStrHex((const char *)(bp + 72), pl - 72, 0);
}
if (op->do_pcb) {
get_pcb_str(pcb, str, sizeof(str));
@@ -5444,7 +5444,7 @@ show_tape_diag_data_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -5456,80 +5456,80 @@ show_mchanger_diag_data_page(const uint8_t * resp, int len,
{
int num, pl, pc, pcb;
unsigned int v;
- const uint8_t * ucp;
+ const uint8_t * bp;
char str[PCB_STR_LEN];
char b[80];
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Media changer diagnostics data page (smc-3) [0x16]\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
printf(" Parameter code: %d\n", pc);
- printf(" Repeat: %d\n", !!(ucp[5] & 0x80));
- v = ucp[5] & 0xf;
+ printf(" Repeat: %d\n", !!(bp[5] & 0x80));
+ v = bp[5] & 0xf;
printf(" Sense key: 0x%x [%s]\n", v,
sg_get_sense_key_str(v, sizeof(b), b));
- printf(" Additional sense code: 0x%x\n", ucp[6]);
- printf(" Additional sense code qualifier: 0x%x\n", ucp[7]);
- if (ucp[6] || ucp[7])
- printf(" [%s]\n", sg_get_asc_ascq_str(ucp[6], ucp[7],
+ printf(" Additional sense code: 0x%x\n", bp[6]);
+ printf(" Additional sense code qualifier: 0x%x\n", bp[7]);
+ if (bp[6] || bp[7])
+ printf(" [%s]\n", sg_get_asc_ascq_str(bp[6], bp[7],
sizeof(b), b));
- v = sg_get_unaligned_be32(ucp + 8);
+ v = sg_get_unaligned_be32(bp + 8);
printf(" Vendor specific code qualifier: 0x%x\n", v);
- v = sg_get_unaligned_be32(ucp + 12);
+ v = sg_get_unaligned_be32(bp + 12);
printf(" Product revision level: %u\n", v);
- v = sg_get_unaligned_be32(ucp + 16);
+ v = sg_get_unaligned_be32(bp + 16);
printf(" Number of moves: %u\n", v);
- v = sg_get_unaligned_be32(ucp + 20);
+ v = sg_get_unaligned_be32(bp + 20);
printf(" Number of pick: %u\n", v);
- v = sg_get_unaligned_be32(ucp + 24);
+ v = sg_get_unaligned_be32(bp + 24);
printf(" Number of pick retries: %u\n", v);
- v = sg_get_unaligned_be32(ucp + 28);
+ v = sg_get_unaligned_be32(bp + 28);
printf(" Number of places: %u\n", v);
- v = sg_get_unaligned_be32(ucp + 32);
+ v = sg_get_unaligned_be32(bp + 32);
printf(" Number of place retries: %u\n", v);
- v = sg_get_unaligned_be32(ucp + 36);
+ v = sg_get_unaligned_be32(bp + 36);
printf(" Number of determined volume identifiers: %u\n", v);
- v = sg_get_unaligned_be32(ucp + 40);
+ v = sg_get_unaligned_be32(bp + 40);
printf(" Number of unreadable volume identifiers: %u\n", v);
- printf(" Operation code: 0x%x\n", ucp[44]);
- printf(" Service action: 0x%x\n", ucp[45] & 0xf);
- printf(" Media changer error type: 0x%x\n", ucp[46]);
- printf(" MTAV: %d\n", !!(ucp[47] & 0x8));
- printf(" IAV: %d\n", !!(ucp[47] & 0x4));
- printf(" LSAV: %d\n", !!(ucp[47] & 0x2));
- printf(" DAV: %d\n", !!(ucp[47] & 0x1));
- v = sg_get_unaligned_be16(ucp + 48);
+ printf(" Operation code: 0x%x\n", bp[44]);
+ printf(" Service action: 0x%x\n", bp[45] & 0xf);
+ printf(" Media changer error type: 0x%x\n", bp[46]);
+ printf(" MTAV: %d\n", !!(bp[47] & 0x8));
+ printf(" IAV: %d\n", !!(bp[47] & 0x4));
+ printf(" LSAV: %d\n", !!(bp[47] & 0x2));
+ printf(" DAV: %d\n", !!(bp[47] & 0x1));
+ v = sg_get_unaligned_be16(bp + 48);
printf(" Medium transport address: 0x%x\n", v);
- v = sg_get_unaligned_be16(ucp + 50);
+ v = sg_get_unaligned_be16(bp + 50);
printf(" Intial address: 0x%x\n", v);
- v = sg_get_unaligned_be16(ucp + 52);
+ v = sg_get_unaligned_be16(bp + 52);
printf(" Last successful address: 0x%x\n", v);
- v = sg_get_unaligned_be16(ucp + 54);
+ v = sg_get_unaligned_be16(bp + 54);
printf(" Destination address: 0x%x\n", v);
if (pl > 91) {
printf(" Volume tag information:\n");
- dStrHex((const char *)(ucp + 56), 36, 0);
+ dStrHex((const char *)(bp + 56), 36, 0);
}
if (pl > 99) {
- printf(" Timestamp origin: 0x%x\n", ucp[92] & 0xf);
+ printf(" Timestamp origin: 0x%x\n", bp[92] & 0xf);
printf(" Timestamp:\n");
- dStrHex((const char *)(ucp + 94), 6, 1);
+ dStrHex((const char *)(bp + 94), 6, 1);
}
if (op->do_pcb) {
get_pcb_str(pcb, str, sizeof(str));
@@ -5539,7 +5539,7 @@ show_mchanger_diag_data_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -5620,7 +5620,7 @@ show_volume_stats_pages(const uint8_t * resp, int len,
const struct opts_t * op)
{
int num, pl, pc, pcb, spf, subpg_code;
- const uint8_t * ucp;
+ const uint8_t * bp;
char pcb_str[PCB_STR_LEN];
char b[64];
@@ -5637,19 +5637,19 @@ show_volume_stats_pages(const uint8_t * resp, int len,
}
}
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
@@ -5657,167 +5657,167 @@ show_volume_stats_pages(const uint8_t * resp, int len,
switch (pc) {
case 0:
printf(" Page valid: %" PRIu64 "\n",
- sg_get_unaligned_be(pl - 4, ucp + 4));
+ sg_get_unaligned_be(pl - 4, bp + 4));
break;
case 1:
printf(" Thread count: %" PRIu64 "\n",
- sg_get_unaligned_be(pl - 4, ucp + 4));
+ sg_get_unaligned_be(pl - 4, bp + 4));
break;
case 2:
printf(" Total data sets written: %" PRIu64 "\n",
- sg_get_unaligned_be(pl - 4, ucp + 4));
+ sg_get_unaligned_be(pl - 4, bp + 4));
break;
case 3:
printf(" Total write retries: %" PRIu64 "\n",
- sg_get_unaligned_be(pl - 4, ucp + 4));
+ sg_get_unaligned_be(pl - 4, bp + 4));
break;
case 4:
printf(" Total unrecovered write errors: %" PRIu64 "\n",
- sg_get_unaligned_be(pl - 4, ucp + 4));
+ sg_get_unaligned_be(pl - 4, bp + 4));
break;
case 5:
printf(" Total suspended writes: %" PRIu64 "\n",
- sg_get_unaligned_be(pl - 4, ucp + 4));
+ sg_get_unaligned_be(pl - 4, bp + 4));
break;
case 6:
printf(" Total fatal suspended writes: %" PRIu64 "\n",
- sg_get_unaligned_be(pl - 4, ucp + 4));
+ sg_get_unaligned_be(pl - 4, bp + 4));
break;
case 7:
printf(" Total data sets read: %" PRIu64 "\n",
- sg_get_unaligned_be(pl - 4, ucp + 4));
+ sg_get_unaligned_be(pl - 4, bp + 4));
break;
case 8:
printf(" Total read retries: %" PRIu64 "\n",
- sg_get_unaligned_be(pl - 4, ucp + 4));
+ sg_get_unaligned_be(pl - 4, bp + 4));
break;
case 9:
printf(" Total unrecovered read errors: %" PRIu64 "\n",
- sg_get_unaligned_be(pl - 4, ucp + 4));
+ sg_get_unaligned_be(pl - 4, bp + 4));
break;
case 0xa:
printf(" Total suspended reads: %" PRIu64 "\n",
- sg_get_unaligned_be(pl - 4, ucp + 4));
+ sg_get_unaligned_be(pl - 4, bp + 4));
break;
case 0xb:
printf(" Total fatal suspended reads: %" PRIu64 "\n",
- sg_get_unaligned_be(pl - 4, ucp + 4));
+ sg_get_unaligned_be(pl - 4, bp + 4));
break;
case 0xc:
printf(" Last mount unrecovered write errors: %" PRIu64 "\n",
- sg_get_unaligned_be(pl - 4, ucp + 4));
+ sg_get_unaligned_be(pl - 4, bp + 4));
break;
case 0xd:
printf(" Last mount unrecovered read errors: %" PRIu64 "\n",
- sg_get_unaligned_be(pl - 4, ucp + 4));
+ sg_get_unaligned_be(pl - 4, bp + 4));
break;
case 0xe:
printf(" Last mount megabytes written: %" PRIu64 "\n",
- sg_get_unaligned_be(pl - 4, ucp + 4));
+ sg_get_unaligned_be(pl - 4, bp + 4));
break;
case 0xf:
printf(" Last mount megabytes read: %" PRIu64 "\n",
- sg_get_unaligned_be(pl - 4, ucp + 4));
+ sg_get_unaligned_be(pl - 4, bp + 4));
break;
case 0x10:
printf(" Lifetime megabytes written: %" PRIu64 "\n",
- sg_get_unaligned_be(pl - 4, ucp + 4));
+ sg_get_unaligned_be(pl - 4, bp + 4));
break;
case 0x11:
printf(" Lifetime megabytes read: %" PRIu64 "\n",
- sg_get_unaligned_be(pl - 4, ucp + 4));
+ sg_get_unaligned_be(pl - 4, bp + 4));
break;
case 0x12:
printf(" Last load write compression ratio: %" PRIu64 "\n",
- sg_get_unaligned_be(pl - 4, ucp + 4));
+ sg_get_unaligned_be(pl - 4, bp + 4));
break;
case 0x13:
printf(" Last load read compression ratio: %" PRIu64 "\n",
- sg_get_unaligned_be(pl - 4, ucp + 4));
+ sg_get_unaligned_be(pl - 4, bp + 4));
break;
case 0x14:
printf(" Medium mount time: %" PRIu64 "\n",
- sg_get_unaligned_be(pl - 4, ucp + 4));
+ sg_get_unaligned_be(pl - 4, bp + 4));
break;
case 0x15:
printf(" Medium ready time: %" PRIu64 "\n",
- sg_get_unaligned_be(pl - 4, ucp + 4));
+ sg_get_unaligned_be(pl - 4, bp + 4));
break;
case 0x16:
printf(" Total native capacity [MB]: %s\n",
- num_or_unknown(ucp + 4, pl - 4, false, b, sizeof(b)));
+ num_or_unknown(bp + 4, pl - 4, false, b, sizeof(b)));
break;
case 0x17:
printf(" Total used native capacity [MB]: %s\n",
- num_or_unknown(ucp + 4, pl - 4, false, b, sizeof(b)));
+ num_or_unknown(bp + 4, pl - 4, false, b, sizeof(b)));
break;
case 0x40:
- printf(" Volume serial number: %.*s\n", pl - 4, ucp + 4);
+ printf(" Volume serial number: %.*s\n", pl - 4, bp + 4);
break;
case 0x41:
- printf(" Tape lot identifier: %.*s\n", pl - 4, ucp + 4);
+ printf(" Tape lot identifier: %.*s\n", pl - 4, bp + 4);
break;
case 0x42:
- printf(" Volume barcode: %.*s\n", pl - 4, ucp + 4);
+ printf(" Volume barcode: %.*s\n", pl - 4, bp + 4);
break;
case 0x43:
- printf(" Volume manufacturer: %.*s\n", pl - 4, ucp + 4);
+ printf(" Volume manufacturer: %.*s\n", pl - 4, bp + 4);
break;
case 0x44:
- printf(" Volume license code: %.*s\n", pl - 4, ucp + 4);
+ printf(" Volume license code: %.*s\n", pl - 4, bp + 4);
break;
case 0x45:
- printf(" Volume personality: %.*s\n", pl - 4, ucp + 4);
+ printf(" Volume personality: %.*s\n", pl - 4, bp + 4);
break;
case 0x80:
printf(" Write protect: %s\n",
- num_or_unknown(ucp + 4, pl - 4, false, b, sizeof(b)));
+ num_or_unknown(bp + 4, pl - 4, false, b, sizeof(b)));
break;
case 0x81:
printf(" WORM: %s\n",
- num_or_unknown(ucp + 4, pl - 4, false, b, sizeof(b)));
+ num_or_unknown(bp + 4, pl - 4, false, b, sizeof(b)));
break;
case 0x82:
printf(" Maximum recommended tape path temperature exceeded: "
- "%s\n", num_or_unknown(ucp + 4, pl - 4, false, b,
+ "%s\n", num_or_unknown(bp + 4, pl - 4, false, b,
sizeof(b)));
break;
case 0x100:
printf(" Volume write mounts: %" PRIu64 "\n",
- sg_get_unaligned_be(pl - 4, ucp + 4));
+ sg_get_unaligned_be(pl - 4, bp + 4));
break;
case 0x101:
printf(" Beginning of medium passes: %" PRIu64 "\n",
- sg_get_unaligned_be(pl - 4, ucp + 4));
+ sg_get_unaligned_be(pl - 4, bp + 4));
break;
case 0x102:
printf(" Middle of medium passes: %" PRIu64 "\n",
- sg_get_unaligned_be(pl - 4, ucp + 4));
+ sg_get_unaligned_be(pl - 4, bp + 4));
break;
case 0x200:
printf(" Logical position of first encrypted logical object:\n");
- volume_stats_partition(ucp + 4, pl - 4, true);
+ volume_stats_partition(bp + 4, pl - 4, true);
break;
case 0x201:
printf(" Logical position of first unencrypted logical object "
"after first\n encrypted logical object:\n");
- volume_stats_partition(ucp + 4, pl - 4, true);
+ volume_stats_partition(bp + 4, pl - 4, true);
break;
case 0x202:
printf(" Native capacity partition(s) [MB]:\n");
- volume_stats_partition(ucp + 4, pl - 4, false);
+ volume_stats_partition(bp + 4, pl - 4, false);
break;
case 0x203:
printf(" Used native capacity partition(s) [MB]:\n");
- volume_stats_partition(ucp + 4, pl - 4, false);
+ volume_stats_partition(bp + 4, pl - 4, false);
break;
case 0x204:
printf(" Remaining native capacity partition(s) [MB]:\n");
- volume_stats_partition(ucp + 4, pl - 4, false);
+ volume_stats_partition(bp + 4, pl - 4, false);
break;
case 0x300:
printf(" Mount history:\n");
- volume_stats_history(ucp + 4, pl - 4);
+ volume_stats_history(bp + 4, pl - 4);
break;
default:
@@ -5827,7 +5827,7 @@ show_volume_stats_pages(const uint8_t * resp, int len,
else
printf(" Reserved parameter code (0x%x), payload in hex\n",
pc);
- dStrHex((const char *)(ucp + 4), pl - 4, 0);
+ dStrHex((const char *)(bp + 4), pl - 4, 0);
break;
}
if (op->do_pcb) {
@@ -5838,7 +5838,7 @@ show_volume_stats_pages(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -5913,30 +5913,30 @@ show_tape_alert_ssc_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int num, pl, pc, pcb, flag;
- const uint8_t * ucp;
+ const uint8_t * bp;
char str[PCB_STR_LEN];
/* N.B. the Tape alert log page for smc-3 is different */
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Tape alert page (ssc-3) [0x2e]\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
- flag = ucp[4] & 1;
+ flag = bp[4] & 1;
if (op->verbose && (0 == op->do_brief) && flag)
printf(" >>>> ");
if ((0 == op->do_brief) || op->verbose || flag) {
@@ -5955,7 +5955,7 @@ show_tape_alert_ssc_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -5966,25 +5966,25 @@ show_seagate_cache_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int num, pl, pc, pcb;
- const uint8_t * ucp;
+ const uint8_t * bp;
char pcb_str[PCB_STR_LEN];
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Seagate cache page [0x37]\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
@@ -6003,7 +6003,7 @@ show_seagate_cache_page(const uint8_t * resp, int len,
"> segment size"); break;
default: printf(" Unknown Seagate parameter code = 0x%x", pc); break;
}
- printf(" = %" PRIu64 "", sg_get_unaligned_be(pl - 4, ucp + 4));
+ printf(" = %" PRIu64 "", sg_get_unaligned_be(pl - 4, bp + 4));
if (op->do_pcb) {
get_pcb_str(pcb, pcb_str, sizeof(pcb_str));
printf("\n <%s>\n", pcb_str);
@@ -6013,7 +6013,7 @@ show_seagate_cache_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -6024,26 +6024,26 @@ show_seagate_factory_page(const uint8_t * resp, int len,
const struct opts_t * op)
{
int num, pl, pc, pcb, valid;
- const uint8_t * ucp;
+ const uint8_t * bp;
uint64_t ull;
char pcb_str[PCB_STR_LEN];
if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex)))
printf("Seagate/Hitachi factory page [0x3e]\n");
num = len - 4;
- ucp = &resp[0] + 4;
+ bp = &resp[0] + 4;
while (num > 3) {
- pc = sg_get_unaligned_be16(ucp + 0);
- pcb = ucp[2];
- pl = ucp[3] + 4;
+ pc = sg_get_unaligned_be16(bp + 0);
+ pcb = bp[2];
+ pl = bp[3] + 4;
if (op->filter_given) {
if (pc != op->filter)
goto skip;
if (op->do_raw) {
- dStrRaw((const char *)ucp, pl);
+ dStrRaw((const char *)bp, pl);
break;
} else if (op->do_hex) {
- dStrHex((const char *)ucp, pl, ((1 == op->do_hex) ? 1 : -1));
+ dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1));
break;
}
}
@@ -6058,7 +6058,7 @@ show_seagate_factory_page(const uint8_t * resp, int len,
break;
}
if (valid) {
- ull = sg_get_unaligned_be(pl - 4, ucp + 4);
+ ull = sg_get_unaligned_be(pl - 4, bp + 4);
if (0 == pc)
printf(" = %.2f", ((double)ull) / 60.0 );
else
@@ -6073,7 +6073,7 @@ show_seagate_factory_page(const uint8_t * resp, int len,
break;
skip:
num -= pl;
- ucp += pl;
+ bp += pl;
}
return true;
}
@@ -6258,7 +6258,7 @@ main(int argc, char * argv[])
if (NULL == op->device_name) {
if (op->in_fn) {
const struct log_elem * lep;
- const unsigned char * ucp;
+ const unsigned char * bp;
int pg_code, subpg_code, pdt, n;
uint16_t u;
@@ -6275,10 +6275,10 @@ main(int argc, char * argv[])
if (op->pg_arg && (0 == op->do_brief))
pr2serr(">>> --page=%s option is being ignored, using values "
"in file: %s\n", op->pg_arg, op->in_fn);
- for (ucp = rsp_buff, k = 0; k < in_len; ucp += n, k += n) {
- pg_code = ucp[0] & 0x3f;
- subpg_code = (ucp[0] & 0x40) ? ucp[1] : 0;
- u = sg_get_unaligned_be16(ucp + 2);
+ for (bp = rsp_buff, k = 0; k < in_len; bp += n, k += n) {
+ pg_code = bp[0] & 0x3f;
+ subpg_code = (bp[0] & 0x40) ? bp[1] : 0;
+ u = sg_get_unaligned_be16(bp + 2);
n = u + 4;
if (n > (in_len - k)) {
pr2serr("bytes decoded remaining (%d) less than lpage "
@@ -6290,7 +6290,7 @@ main(int argc, char * argv[])
lep = pg_subpg_pdt_search(pg_code, subpg_code, pdt);
if (lep) {
if (lep->show_pagep)
- (*lep->show_pagep)(ucp, n, op);
+ (*lep->show_pagep)(bp, n, op);
else
printf("Unable to decode %s [%s]\n", lep->name,
lep->acron);
diff --git a/src/sg_map26.c b/src/sg_map26.c
index 1a1301aa..1b501783 100644
--- a/src/sg_map26.c
+++ b/src/sg_map26.c
@@ -40,7 +40,7 @@
#endif
#include "sg_lib.h"
-static const char * version_str = "1.11 20160121";
+static const char * version_str = "1.12 20160404";
#define ME "sg_map26: "
@@ -300,7 +300,7 @@ nt_typ_from_major(int ma)
struct node_match_item {
- const char * dir_name;
+ char dir_name[D_NAME_LEN_MAX];
int file_type;
int majj;
int minn;
@@ -369,7 +369,7 @@ list_matching_nodes(const char * dir_name, int file_type, int majj, int minn,
struct dirent ** namelist;
int num, k;
- nd_match.dir_name = dir_name;
+ strncpy(nd_match.dir_name, dir_name, D_NAME_LEN_MAX);
nd_match.file_type = file_type;
nd_match.majj = majj;
nd_match.minn = minn;
diff --git a/src/sg_modes.c b/src/sg_modes.c
index 01f2450a..1190edd0 100644
--- a/src/sg_modes.c
+++ b/src/sg_modes.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2000-2015 D. Gilbert
+ * Copyright (C) 2000-2016 D. Gilbert
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
@@ -16,6 +16,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
+#include <stdbool.h>
#include <string.h>
#include <ctype.h>
#include <getopt.h>
@@ -82,7 +83,7 @@ struct opts_t {
int page_control;
int pg_code;
int subpg_code;
- int subpg_code_set;
+ bool subpg_code_given;
const char * device_name;
int opt_new;
};
@@ -277,9 +278,8 @@ process_cl_new(struct opts_t * op, int argc, char * argv[])
return SG_LIB_SYNTAX_ERROR;
}
op->subpg_code = nn;
- op->subpg_code_set = 1;
- } else
- nn = 0;
+ op->subpg_code_given = true;
+ }
op->pg_code = n;
break;
case 'r':
@@ -326,8 +326,9 @@ process_cl_new(struct opts_t * op, int argc, char * argv[])
static int
process_cl_old(struct opts_t * op, int argc, char * argv[])
{
- int k, jmp_out, plen, num, n;
+ int k, plen, num, n;
unsigned int u, uu;
+ bool jmp_out;
const char * cp;
for (k = 1; k < argc; ++k) {
@@ -336,7 +337,7 @@ process_cl_old(struct opts_t * op, int argc, char * argv[])
if (plen <= 0)
continue;
if ('-' == *cp) {
- for (--plen, ++cp, jmp_out = 0; plen > 0; --plen, ++cp) {
+ for (--plen, ++cp, jmp_out = false; plen > 0; --plen, ++cp) {
switch (*cp) {
case '6':
++op->do_six;
@@ -387,7 +388,7 @@ process_cl_old(struct opts_t * op, int argc, char * argv[])
++op->do_help;
break;
default:
- jmp_out = 1;
+ jmp_out = true;
break;
}
if (jmp_out)
@@ -428,7 +429,7 @@ process_cl_old(struct opts_t * op, int argc, char * argv[])
}
op->pg_code = u;
op->subpg_code = uu;
- op->subpg_code_set = 1;
+ op->subpg_code_given = true;
} else {
pr2serr("Bad page code, subpage code sequence after 'p=' "
"option\n");
@@ -443,7 +444,7 @@ process_cl_old(struct opts_t * op, int argc, char * argv[])
return SG_LIB_SYNTAX_ERROR;
}
op->subpg_code = u;
- op->subpg_code_set = 1;
+ op->subpg_code_given = true;
if (-1 == op->pg_code)
op->pg_code = 0;
} else if (0 == strncmp("-old", cp, 4))
@@ -603,43 +604,47 @@ static struct page_code_desc pc_desc_adc[] = {
{0xe, 0x4, "Target device serial number"},
};
+/* Returns pointer to base of table for scsi_ptype or pointer to common
+ * table if scsi_ptype is -1. Yields numbers of elements in returned
+ * table via pointer sizep. If scsi_ptype not known then returns NULL
+ * with *sizep set to zero. */
static struct page_code_desc *
-mode_page_cs_table(int scsi_ptype, int * size)
+get_mpage_tbl_size(int scsi_ptype, int * sizep)
{
switch (scsi_ptype)
{
case -1: /* common list */
- *size = sizeof(pc_desc_common) / sizeof(pc_desc_common[0]);
+ *sizep = sizeof(pc_desc_common) / sizeof(pc_desc_common[0]);
return &pc_desc_common[0];
case PDT_DISK: /* disk (direct access) type devices */
case PDT_WO:
case PDT_OPTICAL:
- *size = sizeof(pc_desc_disk) / sizeof(pc_desc_disk[0]);
+ *sizep = sizeof(pc_desc_disk) / sizeof(pc_desc_disk[0]);
return &pc_desc_disk[0];
case PDT_TAPE: /* tape devices */
case PDT_PRINTER:
- *size = sizeof(pc_desc_tape) / sizeof(pc_desc_tape[0]);
+ *sizep = sizeof(pc_desc_tape) / sizeof(pc_desc_tape[0]);
return &pc_desc_tape[0];
case PDT_MMC: /* cd/dvd/bd devices */
- *size = sizeof(pc_desc_cddvd) / sizeof(pc_desc_cddvd[0]);
+ *sizep = sizeof(pc_desc_cddvd) / sizeof(pc_desc_cddvd[0]);
return &pc_desc_cddvd[0];
case PDT_MCHANGER: /* medium changer devices */
- *size = sizeof(pc_desc_smc) / sizeof(pc_desc_smc[0]);
+ *sizep = sizeof(pc_desc_smc) / sizeof(pc_desc_smc[0]);
return &pc_desc_smc[0];
case PDT_SAC: /* storage array devices */
- *size = sizeof(pc_desc_scc) / sizeof(pc_desc_scc[0]);
+ *sizep = sizeof(pc_desc_scc) / sizeof(pc_desc_scc[0]);
return &pc_desc_scc[0];
case PDT_SES: /* enclosure services devices */
- *size = sizeof(pc_desc_ses) / sizeof(pc_desc_ses[0]);
+ *sizep = sizeof(pc_desc_ses) / sizeof(pc_desc_ses[0]);
return &pc_desc_ses[0];
case PDT_RBC: /* simplified direct access device */
- *size = sizeof(pc_desc_rbc) / sizeof(pc_desc_rbc[0]);
+ *sizep = sizeof(pc_desc_rbc) / sizeof(pc_desc_rbc[0]);
return &pc_desc_rbc[0];
case PDT_ADC: /* automation device/interface */
- *size = sizeof(pc_desc_adc) / sizeof(pc_desc_adc[0]);
+ *sizep = sizeof(pc_desc_adc) / sizeof(pc_desc_adc[0]);
return &pc_desc_adc[0];
}
- *size = 0;
+ *sizep = 0;
return NULL;
}
@@ -674,24 +679,24 @@ static struct page_code_desc pc_desc_t_adc[] = {
};
static struct page_code_desc *
-mode_page_transp_table(int t_proto, int * size)
+get_mpage_trans_tbl_size(int t_proto, int * sizep)
{
switch (t_proto)
{
case TPROTO_FCP:
- *size = sizeof(pc_desc_t_fcp) / sizeof(pc_desc_t_fcp[0]);
+ *sizep = sizeof(pc_desc_t_fcp) / sizeof(pc_desc_t_fcp[0]);
return &pc_desc_t_fcp[0];
case TPROTO_SPI:
- *size = sizeof(pc_desc_t_spi4) / sizeof(pc_desc_t_spi4[0]);
+ *sizep = sizeof(pc_desc_t_spi4) / sizeof(pc_desc_t_spi4[0]);
return &pc_desc_t_spi4[0];
case TPROTO_SAS:
- *size = sizeof(pc_desc_t_sas) / sizeof(pc_desc_t_sas[0]);
+ *sizep = sizeof(pc_desc_t_sas) / sizeof(pc_desc_t_sas[0]);
return &pc_desc_t_sas[0];
case TPROTO_ADT:
- *size = sizeof(pc_desc_t_adc) / sizeof(pc_desc_t_adc[0]);
+ *sizep = sizeof(pc_desc_t_adc) / sizeof(pc_desc_t_adc[0]);
return &pc_desc_t_adc[0];
}
- *size = 0;
+ *sizep = 0;
return NULL;
}
@@ -704,7 +709,7 @@ find_page_code_desc(int page_num, int subpage_num, int scsi_ptype,
const struct page_code_desc * pcdp;
if (t_proto >= 0) {
- pcdp = mode_page_transp_table(t_proto, &num);
+ pcdp = get_mpage_trans_tbl_size(t_proto, &num);
if (pcdp) {
for (k = 0; k < num; ++k, ++pcdp) {
if ((page_num == pcdp->page_code) &&
@@ -715,7 +720,7 @@ find_page_code_desc(int page_num, int subpage_num, int scsi_ptype,
}
}
}
- pcdp = mode_page_cs_table(scsi_ptype, &num);
+ pcdp = get_mpage_tbl_size(scsi_ptype, &num);
if (pcdp) {
for (k = 0; k < num; ++k, ++pcdp) {
if ((page_num == pcdp->page_code) &&
@@ -727,7 +732,7 @@ find_page_code_desc(int page_num, int subpage_num, int scsi_ptype,
}
if ((0xd != scsi_ptype) && (inq_byte6 & 0x40)) {
/* check for attached enclosure services processor */
- pcdp = mode_page_cs_table(0xd, &num);
+ pcdp = get_mpage_tbl_size(0xd, &num);
if (pcdp) {
for (k = 0; k < num; ++k, ++pcdp) {
if ((page_num == pcdp->page_code) &&
@@ -740,7 +745,7 @@ find_page_code_desc(int page_num, int subpage_num, int scsi_ptype,
}
if ((0x8 != scsi_ptype) && (inq_byte6 & 0x8)) {
/* check for attached medium changer device */
- pcdp = mode_page_cs_table(0x8, &num);
+ pcdp = get_mpage_tbl_size(0x8, &num);
if (pcdp) {
for (k = 0; k < num; ++k, ++pcdp) {
if ((page_num == pcdp->page_code) &&
@@ -751,7 +756,7 @@ find_page_code_desc(int page_num, int subpage_num, int scsi_ptype,
}
}
}
- pcdp = mode_page_cs_table(-1, &num);
+ pcdp = get_mpage_tbl_size(-1, &num);
for (k = 0; k < num; ++k, ++pcdp) {
if ((page_num == pcdp->page_code) &&
(subpage_num == pcdp->subpage_code))
@@ -765,16 +770,17 @@ find_page_code_desc(int page_num, int subpage_num, int scsi_ptype,
static void
list_page_codes(int scsi_ptype, int inq_byte6, int t_proto)
{
- int num, num_ptype, pg, spg, c, d, valid_transport;
+ int num, num_ptype, pg, spg, c, d;
+ bool valid_transport;
const struct page_code_desc * dp;
const struct page_code_desc * pe_dp;
char b[64];
- valid_transport = ((t_proto >= 0) && (t_proto <= 0xf)) ? 1 : 0;
+ valid_transport = ((t_proto >= 0) && (t_proto <= 0xf));
printf("Page[,subpage] Name\n");
printf("=====================\n");
- dp = mode_page_cs_table(-1, &num);
- pe_dp = mode_page_cs_table(scsi_ptype, &num_ptype);
+ dp = get_mpage_tbl_size(-1, &num);
+ pe_dp = get_mpage_tbl_size(scsi_ptype, &num_ptype);
while (1) {
pg = dp ? dp->page_code : PG_CODE_ALL + 1;
spg = dp ? dp->subpage_code : SPG_CODE_ALL;
@@ -786,30 +792,37 @@ list_page_codes(int scsi_ptype, int inq_byte6, int t_proto)
((PROTO_SPECIFIC_1 == c) || (PROTO_SPECIFIC_2 == c)))
dp = (--num <= 0) ? NULL : (dp + 1); /* skip protocol specific */
else if (c == d) {
- if (pe_dp->subpage_code)
- printf(" 0x%02x,0x%02x * %s\n", pe_dp->page_code,
- pe_dp->subpage_code, pe_dp->desc);
- else
- printf(" 0x%02x * %s\n", pe_dp->page_code,
- pe_dp->desc);
- dp = (--num <= 0) ? NULL : (dp + 1);
- pe_dp = (--num_ptype <= 0) ? NULL : (pe_dp + 1);
+ if (pe_dp) {
+ if (pe_dp->subpage_code)
+ printf(" 0x%02x,0x%02x * %s\n", pe_dp->page_code,
+ pe_dp->subpage_code, pe_dp->desc);
+ else
+ printf(" 0x%02x * %s\n", pe_dp->page_code,
+ pe_dp->desc);
+ pe_dp = (--num_ptype <= 0) ? NULL : (pe_dp + 1);
+ }
+ if (dp)
+ dp = (--num <= 0) ? NULL : (dp + 1);
} else if (c < d) {
- if (dp->subpage_code)
- printf(" 0x%02x,0x%02x %s\n", dp->page_code,
- dp->subpage_code, dp->desc);
- else
- printf(" 0x%02x %s\n", dp->page_code,
- dp->desc);
- dp = (--num <= 0) ? NULL : (dp + 1);
+ if (dp) {
+ if (dp->subpage_code)
+ printf(" 0x%02x,0x%02x %s\n", dp->page_code,
+ dp->subpage_code, dp->desc);
+ else
+ printf(" 0x%02x %s\n", dp->page_code,
+ dp->desc);
+ dp = (--num <= 0) ? NULL : (dp + 1);
+ }
} else {
- if (pe_dp->subpage_code)
- printf(" 0x%02x,0x%02x %s\n", pe_dp->page_code,
- pe_dp->subpage_code, pe_dp->desc);
- else
- printf(" 0x%02x %s\n", pe_dp->page_code,
- pe_dp->desc);
- pe_dp = (--num_ptype <= 0) ? NULL : (pe_dp + 1);
+ if (pe_dp) {
+ if (pe_dp->subpage_code)
+ printf(" 0x%02x,0x%02x %s\n", pe_dp->page_code,
+ pe_dp->subpage_code, pe_dp->desc);
+ else
+ printf(" 0x%02x %s\n", pe_dp->page_code,
+ pe_dp->desc);
+ pe_dp = (--num_ptype <= 0) ? NULL : (pe_dp + 1);
+ }
}
if ((NULL == dp) && (NULL == pe_dp))
break;
@@ -817,7 +830,7 @@ list_page_codes(int scsi_ptype, int inq_byte6, int t_proto)
if ((0xd != scsi_ptype) && (inq_byte6 & 0x40)) {
/* check for attached enclosure services processor */
printf("\n Attached enclosure services processor\n");
- dp = mode_page_cs_table(0xd, &num);
+ dp = get_mpage_tbl_size(0xd, &num);
while (dp) {
if (dp->subpage_code)
printf(" 0x%02x,0x%02x %s\n", dp->page_code,
@@ -831,7 +844,7 @@ list_page_codes(int scsi_ptype, int inq_byte6, int t_proto)
if ((0x8 != scsi_ptype) && (inq_byte6 & 0x8)) {
/* check for attached medium changer device */
printf("\n Attached medium changer device\n");
- dp = mode_page_cs_table(0x8, &num);
+ dp = get_mpage_tbl_size(0x8, &num);
while (dp) {
if (dp->subpage_code)
printf(" 0x%02x,0x%02x %s\n", dp->page_code,
@@ -845,7 +858,7 @@ list_page_codes(int scsi_ptype, int inq_byte6, int t_proto)
if (valid_transport) {
printf("\n Transport protocol: %s\n",
sg_get_trans_proto_str(t_proto, sizeof(b), b));
- dp = mode_page_transp_table(t_proto, &num);
+ dp = get_mpage_trans_tbl_size(t_proto, &num);
while (dp) {
if (dp->subpage_code)
printf(" 0x%02x,0x%02x %s\n", dp->page_code,
@@ -859,8 +872,7 @@ list_page_codes(int scsi_ptype, int inq_byte6, int t_proto)
}
static int
-examine_pages(int sg_fd, int inq_pdt, int inq_byte6,
- const struct opts_t * op)
+examine_pages(int sg_fd, int inq_pdt, int inq_byte6, const struct opts_t * op)
{
int k, res, header, mresp_len, len;
unsigned char rbuf[256];
@@ -947,7 +959,7 @@ main(int argc, char * argv[])
int ret = 0;
int density_code_off, t_proto, inq_pdt, inq_byte6, resp_mode6;
int num_ua_pages;
- unsigned char * ucp;
+ unsigned char * bp;
unsigned char uc;
struct sg_simple_inquiry_resp inq_out;
char pdt_name[64];
@@ -979,7 +991,7 @@ main(int argc, char * argv[])
printf(" peripheral device type: %s\n",
sg_get_pdt_str(op->pg_code, sizeof(pdt_name),
pdt_name));
- if (op->subpg_code_set)
+ if (op->subpg_code_given)
list_page_codes(op->pg_code, 0, op->subpg_code);
else
list_page_codes(op->pg_code, 0, -1);
@@ -1051,7 +1063,7 @@ main(int argc, char * argv[])
inq_out.vendor, inq_out.product, inq_out.revision,
sg_get_pdt_str(inq_pdt, sizeof(pdt_name), pdt_name), inq_pdt);
if (op->do_list) {
- if (op->subpg_code_set)
+ if (op->subpg_code_given)
list_page_codes(inq_pdt, inq_byte6, op->subpg_code);
else
list_page_codes(inq_pdt, inq_byte6, -1);
@@ -1167,14 +1179,14 @@ main(int argc, char * argv[])
if (1 == op->do_raw)
dStrRaw((const char *)rsp_buff, md_len);
else if (op->do_raw > 1) {
- ucp = rsp_buff + bd_len + headerlen;
+ bp = rsp_buff + bd_len + headerlen;
md_len -= bd_len + headerlen;
- spf = ((ucp[0] & 0x40) ? 1 : 0);
- len = (spf ? (sg_get_unaligned_be16(ucp + 2) + 4) :
- (ucp[1] + 2));
+ spf = ((bp[0] & 0x40) ? 1 : 0);
+ len = (spf ? (sg_get_unaligned_be16(bp + 2) + 4) :
+ (bp[1] + 2));
len = (len < md_len) ? len : md_len;
for (k = 0; k < len; ++k)
- printf("%02x\n", ucp[k]);
+ printf("%02x\n", bp[k]);
} else
dStrHex((const char *)rsp_buff, md_len, -1);
goto finish;
@@ -1218,18 +1230,18 @@ main(int argc, char * argv[])
else
printf("> General mode parameter block descriptors:\n");
- ucp = rsp_buff + headerlen;
+ bp = rsp_buff + headerlen;
while (num > 0) {
printf(" Density code=0x%x\n",
- *(ucp + density_code_off));
- dStrHex((const char *)ucp, len, 1);
- ucp += len;
+ *(bp + density_code_off));
+ dStrHex((const char *)bp, len, 1);
+ bp += len;
num -= len;
}
printf("\n");
}
}
- ucp = rsp_buff + bd_len + headerlen; /* start of mode page(s) */
+ bp = rsp_buff + bd_len + headerlen; /* start of mode page(s) */
md_len -= bd_len + headerlen; /* length of mode page(s) */
num_ua_pages = 0;
for (k = 0; md_len > 0; ++k) { /* got mode page(s) */
@@ -1239,10 +1251,10 @@ main(int argc, char * argv[])
"ignore\n");
break;
}
- uc = *ucp;
+ uc = *bp;
spf = ((uc & 0x40) ? 1 : 0);
- len = (spf ? (sg_get_unaligned_be16(ucp + 2) + 4) : (ucp[1] + 2));
- page_num = ucp[0] & PG_CODE_MASK;
+ len = (spf ? (sg_get_unaligned_be16(bp + 2) + 4) : (bp[1] + 2));
+ page_num = bp[0] & PG_CODE_MASK;
if (0x0 == page_num) {
++num_ua_pages;
if((num_ua_pages > 3) && (md_len > 0xa00)) {
@@ -1255,23 +1267,23 @@ main(int argc, char * argv[])
if (op->do_hex) {
if (spf)
printf(">> page_code=0x%x, subpage_code=0x%x, page_cont"
- "rol=%d\n", page_num, ucp[1], op->page_control);
+ "rol=%d\n", page_num, bp[1], op->page_control);
else
printf(">> page_code=0x%x, page_control=%d\n", page_num,
op->page_control);
} else {
descp = NULL;
if ((0x18 == page_num) || (0x19 == page_num)) {
- t_proto = (spf ? ucp[5] : ucp[2]) & 0xf;
- descp = find_page_code_desc(page_num, (spf ? ucp[1] : 0),
+ t_proto = (spf ? bp[5] : bp[2]) & 0xf;
+ descp = find_page_code_desc(page_num, (spf ? bp[1] : 0),
inq_pdt, inq_byte6, t_proto);
} else
- descp = find_page_code_desc(page_num, (spf ? ucp[1] : 0),
+ descp = find_page_code_desc(page_num, (spf ? bp[1] : 0),
inq_pdt, inq_byte6, -1);
if (NULL == descp) {
if (spf)
snprintf(ebuff, EBUFF_SZ, "0x%x, subpage_code: 0x%x",
- page_num, ucp[1]);
+ page_num, bp[1]);
else
snprintf(ebuff, EBUFF_SZ, "0x%x", page_num);
}
@@ -1288,8 +1300,8 @@ main(int argc, char * argv[])
pr2serr(">>> page length (%d) > 256 bytes, unlikely trim\n"
" Try '-f' option\n", len);
}
- dStrHex((const char *)ucp, num , 1);
- ucp += len;
+ dStrHex((const char *)bp, num , 1);
+ bp += len;
md_len -= len;
}
}
diff --git a/src/sg_read.c b/src/sg_read.c
index 83a72b90..a107abd0 100644
--- a/src/sg_read.c
+++ b/src/sg_read.c
@@ -809,7 +809,6 @@ int main(int argc, char * argv[])
free(wrkBuff);
close(infd);
- res = 0;
if (0 != dd_count) {
pr2serr("Some error occurred,");
if (0 == ret)
diff --git a/src/sg_read_attr.c b/src/sg_read_attr.c
index 5083674b..2d87f09d 100644
--- a/src/sg_read_attr.c
+++ b/src/sg_read_attr.c
@@ -1057,27 +1057,32 @@ main(int argc, char * argv[])
if (NULL == device_name) {
if (fname) {
- if (f2hex_arr(fname, op->do_raw, 0, rabp, &in_len, op->maxlen))
- return SG_LIB_FILE_ERROR;
+ if (f2hex_arr(fname, op->do_raw, 0, rabp, &in_len, op->maxlen)) {
+ ret = SG_LIB_FILE_ERROR;
+ goto clean_up;
+ }
if (op->do_raw)
op->do_raw = 0; /* can interfere on decode */
if (in_len < 4) {
pr2serr("--in=%s only decoded %d bytes (needs 4 at least)\n",
fname, in_len);
- return SG_LIB_SYNTAX_ERROR;
+ ret = SG_LIB_SYNTAX_ERROR;
+ goto clean_up;
}
decode_all_sa_s(rabp, in_len, op);
goto clean_up;
}
pr2serr("missing device name!\n");
usage();
- return SG_LIB_SYNTAX_ERROR;
+ ret = SG_LIB_SYNTAX_ERROR;
+ goto clean_up;
}
if (op->do_raw) {
if (sg_set_binary_mode(STDOUT_FILENO) < 0) {
perror("sg_set_binary_mode");
- return SG_LIB_FILE_ERROR;
+ ret = SG_LIB_FILE_ERROR;
+ goto clean_up;
}
}
@@ -1085,7 +1090,8 @@ main(int argc, char * argv[])
if (sg_fd < 0) {
pr2serr("open error: %s: %s\n", device_name,
safe_strerror(-sg_fd));
- return SG_LIB_FILE_ERROR;
+ ret = SG_LIB_FILE_ERROR;
+ goto clean_up;
}
res = sg_ll_read_attr(sg_fd, rabp, &resid, op);
diff --git a/src/sg_read_buffer.c b/src/sg_read_buffer.c
index 384bb18d..0c129c42 100644
--- a/src/sg_read_buffer.c
+++ b/src/sg_read_buffer.c
@@ -210,7 +210,7 @@ ll_read_buffer_16(int sg_fd, int rb_mode, int rb_mode_sp, int rb_id,
{
int k, ret, res, sense_cat;
uint8_t rb16_cb[SG_READ_BUFFER_16_CMDLEN] =
- {SG_READ_BUFFER_16_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {SG_READ_BUFFER_16_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0};
uint8_t sense_b[SENSE_BUFF_LEN];
struct sg_pt_base * ptvp;
@@ -418,15 +418,13 @@ main(int argc, char * argv[])
return SG_LIB_SYNTAX_ERROR;
}
- if (rb_len > 0) {
- resp = (unsigned char *)malloc(rb_len);
- if (NULL == resp) {
- pr2serr("unable to allocate %d bytes on the heap\n", rb_len);
- return SG_LIB_CAT_OTHER;
- }
- memset(resp, 0, rb_len);
- } else
- resp = NULL;
+ len = rb_len ? rb_len : 8;
+ resp = (unsigned char *)malloc(len);
+ if (NULL == resp) {
+ pr2serr("unable to allocate %d bytes on the heap\n", len);
+ return SG_LIB_CAT_OTHER;
+ }
+ memset(resp, 0, len);
if (do_raw) {
if (sg_set_binary_mode(STDOUT_FILENO) < 0) {
diff --git a/src/sg_reassign.c b/src/sg_reassign.c
index 02ed33a9..a43efa45 100644
--- a/src/sg_reassign.c
+++ b/src/sg_reassign.c
@@ -430,7 +430,6 @@ main(int argc, char * argv[])
dStrHex((const char *)param_arr, param_len, 1);
goto err_out; /* ret is zero */
}
- lstp = "";
got_grown = !!(param_arr[1] & 0x8);
got_primary = !!(param_arr[1] & 0x10);
if (got_grown && got_primary)
diff --git a/src/sg_referrals.c b/src/sg_referrals.c
index de65010d..88ade797 100644
--- a/src/sg_referrals.c
+++ b/src/sg_referrals.c
@@ -320,7 +320,6 @@ main(int argc, char * argv[])
res = decode_referral_desc(ucp + k, rlen - 4 - k);
if (res < 0) {
pr2serr("bad user data segment referral descriptor\n");
- k = rlen - 4;
break;
}
k += res;
diff --git a/src/sg_safte.c b/src/sg_safte.c
index 8615bd77..9e92b4e2 100644
--- a/src/sg_safte.c
+++ b/src/sg_safte.c
@@ -240,13 +240,14 @@ do_safte_encl_status(int sg_fd, int do_hex, int do_raw, int verbose)
offset++;
for (i = 0; i < safte_cfg.temps; i++) {
- int temp = 0;
+ int temp = rb_buff[i + offset];
+ int is_celsius = !!(safte_cfg.flags & SAFTE_CFG_FLAG_CELSIUS);
- if (!(safte_cfg.flags & SAFTE_CFG_FLAG_CELSIUS))
+ if (! is_celsius)
temp -= 10;
- printf("\tTemperature sensor %d: %d deg %c\n", i, rb_buff[i + offset],
- safte_cfg.flags & SAFTE_CFG_FLAG_CELSIUS?'C':'F');
+ printf("\tTemperature sensor %d: %d deg %c\n", i, temp,
+ is_celsius ? 'C' : 'F');
}
offset += safte_cfg.temps;
@@ -643,12 +644,10 @@ main(int argc, char * argv[])
}
if (1 == do_raw) {
dStrRaw((const char *)rb_buff, buf_capacity);
- res = 0;
goto finish;
}
if (1 == do_hex) {
dStrHex((const char *)rb_buff, buf_capacity, 1);
- res = 0;
goto finish;
}
diff --git a/src/sg_scan_linux.c b/src/sg_scan_linux.c
index 3d405e17..667c6941 100644
--- a/src/sg_scan_linux.c
+++ b/src/sg_scan_linux.c
@@ -373,8 +373,11 @@ int main(int argc, char * argv[])
(f >= 30000))
sg_ver3 = 1;
}
- if (1 == sg_ver3)
+ if (1 == sg_ver3) {
res = sg3_inq(sg_fd, inqBuff, do_extra);
+ if (res)
+ ++num_errors;
+ }
}
}
if ((num_errors >= MAX_ERRORS) && (num_silent < num_errors) &&
@@ -522,7 +525,7 @@ void swapbytes(char *out, const char *in, size_t n)
/* Copies in to out, but removes leading and trailing whitespace. */
void trim(char *out, const char *in)
{
- int k, first, last;
+ int k, first, last, num;
/* Find the first non-space character (maybe none). */
first = -1;
@@ -543,8 +546,10 @@ void trim(char *out, const char *in)
for (k = strlen(in) - 1; k >= first && isspace((int)in[k]); k--)
;
last = k;
- strncpy(out, in + first, last - first + 1);
- out[last - first + 1] = '\0';
+ num = last - first + 1;
+ for (k = 0; k < num; ++k)
+ out[k] = in[first + k];
+ out[num] = '\0';
}
/* Convenience function for formatting strings from ata_identify_device */
diff --git a/src/sg_senddiag.c b/src/sg_senddiag.c
index f42bbbb7..29d28ba5 100644
--- a/src/sg_senddiag.c
+++ b/src/sg_senddiag.c
@@ -709,7 +709,8 @@ main(int argc, char * argv[])
printf("Bad sequence after '-raw=' option\n");
usage_old();
}
- return SG_LIB_SYNTAX_ERROR;
+ ret = SG_LIB_SYNTAX_ERROR;
+ goto fini;
}
}
@@ -721,7 +722,8 @@ main(int argc, char * argv[])
printf("setting -doff or -uoff only useful when -t is set\n");
usage_old();
}
- return SG_LIB_SYNTAX_ERROR;
+ ret = SG_LIB_SYNTAX_ERROR;
+ goto fini;
}
if ((op->do_selftest > 0) && op->do_deftest) {
if (op->opt_new) {
@@ -731,7 +733,8 @@ main(int argc, char * argv[])
printf("either set -s=SF or -t (not both)\n");
usage_old();
}
- return SG_LIB_SYNTAX_ERROR;
+ ret = SG_LIB_SYNTAX_ERROR;
+ goto fini;
}
if (op->do_raw) {
if ((op->do_selftest > 0) || op->do_deftest || op->do_extdur ||
@@ -745,7 +748,8 @@ main(int argc, char * argv[])
"'-l'\n");
usage_old();
}
- return SG_LIB_SYNTAX_ERROR;
+ ret = SG_LIB_SYNTAX_ERROR;
+ goto fini;
}
if (! op->do_pf) {
if (op->opt_new)
@@ -770,12 +774,14 @@ main(int argc, char * argv[])
op->do_verbose)) < 0) {
pr2serr(ME "error opening file: %s: %s\n", op->device_name,
safe_strerror(-sg_fd));
- return SG_LIB_FILE_ERROR;
+ ret = SG_LIB_FILE_ERROR;
+ goto fini;
}
rsp_buff = (unsigned char *)calloc(op->maxlen, 1);
if (NULL == rsp_buff) {
pr2serr("unable to allocate %d bytes (2)\n", op->maxlen);
- return SG_LIB_CAT_OTHER;
+ ret = SG_LIB_CAT_OTHER;
+ goto close_fini;
}
if (op->do_extdur) {
res = do_modes_0a(sg_fd, rsp_buff, 32, 1, 0, op->do_verbose);
@@ -865,10 +871,7 @@ main(int argc, char * argv[])
goto err_out;
}
}
- res = sg_cmds_close_device(sg_fd);
- if ((res < 0) && (0 == ret))
- return SG_LIB_SYNTAX_ERROR;
- return (ret >= 0) ? ret : SG_LIB_CAT_OTHER;
+ goto close_fini;
err_out:
if (SG_LIB_CAT_UNIT_ATTENTION == res)
@@ -882,9 +885,11 @@ err_out:
err_out9:
if (op->do_verbose < 2)
pr2serr(" try again with '-vv' for more information\n");
+close_fini:
res = sg_cmds_close_device(sg_fd);
if ((res < 0) && (0 == ret))
- return SG_LIB_FILE_ERROR;
+ ret = SG_LIB_FILE_ERROR;
+fini:
if (read_in)
free(read_in);
if (rsp_buff)
diff --git a/src/sg_ses.c b/src/sg_ses.c
index 1f025f05..c4907e7c 100644
--- a/src/sg_ses.c
+++ b/src/sg_ses.c
@@ -31,7 +31,7 @@
* commands tailored for SES (enclosure) devices.
*/
-static const char * version_str = "2.10 20160325"; /* ses3r13 */
+static const char * version_str = "2.11 20160404"; /* ses3r13 */
#define MX_ALLOC_LEN ((64 * 1024) - 4) /* max allowable for big enclosures */
#define MX_ELEM_HDR 1024
@@ -2810,7 +2810,7 @@ additional_elem_sas(const char * pad, const uint8_t * ae_bp, int etype,
aep = ae_bp + 14 + eip_offset;
for (j = 0; j < phys; ++j, aep += 2) {
printf("%s [%d] ", pad, j);
- m = aep[0];
+ m = aep[0]; /* connector element index */
if (0xff == m)
printf("no connector");
else {
@@ -2832,7 +2832,7 @@ additional_elem_sas(const char * pad, const uint8_t * ae_bp, int etype,
} else
printf("connector ei: %d", m);
}
- m = aep[1];
+ m = aep[1]; /* other element index */
if (0xff != m) {
printf("; ");
if (tesp->j_base) {
@@ -2875,7 +2875,7 @@ additional_elem_sas(const char * pad, const uint8_t * ae_bp, int etype,
printf("%sphy index: %d\n", pad, j);
printf("%s phy_id: 0x%x\n", pad, aep[0]);
printf("%s ", pad);
- m = aep[2];
+ m = aep[2]; /* connector element index */
if (0xff == m)
printf("no connector");
else {
@@ -2897,16 +2897,16 @@ additional_elem_sas(const char * pad, const uint8_t * ae_bp, int etype,
} else
printf("connector ei: %d", m);
}
- m = aep[3];
+ m = aep[3]; /* other element index */
if (0xff != m) {
printf("; ");
if (tesp->j_base) {
if (0 == eiioe)
- jrp = find_join_row_cnst(tesp, m, 2);
+ jrp = find_join_row_cnst(tesp, m, FJ_AESS);
else if ((1 == eiioe) || (3 == eiioe))
- jrp = find_join_row_cnst(tesp, m, 0);
+ jrp = find_join_row_cnst(tesp, m, FJ_IOE);
else
- jrp = find_join_row_cnst(tesp, m, 1);
+ jrp = find_join_row_cnst(tesp, m, FJ_EOE);
if (NULL == jrp)
printf("broken");
else if (jrp->elem_descp) {
diff --git a/src/sg_start.c b/src/sg_start.c
index 49c92ab0..74ef1c95 100644
--- a/src/sg_start.c
+++ b/src/sg_start.c
@@ -532,7 +532,6 @@ main(int argc, char * argv[])
return SG_LIB_FILE_ERROR;
}
- res = 0;
if (op->do_fl >= 0)
res = sg_ll_start_stop_unit(fd, op->do_immed, op->do_fl, 0 /* pc */,
1 /* fl */, 1 /* loej */,
diff --git a/src/sg_vpd.c b/src/sg_vpd.c
index 25df66a8..a02a6a32 100644
--- a/src/sg_vpd.c
+++ b/src/sg_vpd.c
@@ -704,15 +704,15 @@ dStrRaw(const char * str, int len)
}
/* Assume index is less than 16 */
-const char * sg_ansi_version_arr[] =
+const char * sg_ansi_version_arr[16] =
{
"no conformance claimed",
"SCSI-1", /* obsolete, ANSI X3.131-1986 */
"SCSI-2", /* obsolete, ANSI X3.131-1994 */
- "SPC", /* withdrawn */
- "SPC-2",
- "SPC-3",
- "SPC-4",
+ "SPC", /* withdrawn, ANSI INCITS 301-1997 */
+ "SPC-2", /* ANSI INCITS 351-2001, ISO/IEC 14776-452 */
+ "SPC-3", /* ANSI INCITS 408-2005, ISO/IEC 14776-453 */
+ "SPC-4", /* ANSI INCITS 513-2015 */
"SPC-5",
"ecma=1, [8h]",
"ecma=1, [9h]",
@@ -979,7 +979,7 @@ static int
decode_dev_ids_quiet(unsigned char * buff, int len, int m_assoc,
int m_desig_type, int m_code_set)
{
- int m, p_id, c_set, piv, desig_type, i_len, naa, off, u;
+ int k, m, p_id, c_set, piv, desig_type, i_len, naa, off, u;
int assoc, is_sas, rtp;
const unsigned char * ucp;
const unsigned char * ip;
@@ -987,38 +987,37 @@ decode_dev_ids_quiet(unsigned char * buff, int len, int m_assoc,
rtp = 0;
memset(sas_tport_addr, 0, sizeof(sas_tport_addr));
- off = -1;
- if (buff[2] != 0) {
- if (m_assoc != VPD_ASSOC_LU)
- return 0;
- ip = buff;
- p_id = 0;
- c_set = 1;
- assoc = VPD_ASSOC_LU;
- piv = 0;
- is_sas = 0;
- desig_type = 3;
- i_len = 16;
- off = 16;
- goto skip_1st_iter;
- }
- while ((u = sg_vpd_dev_id_iter(buff, len, &off, m_assoc, m_desig_type,
- m_code_set)) == 0) {
- ucp = buff + off;
- i_len = ucp[3];
- if ((off + i_len + 4) > len) {
- pr2serr(" VPD page error: designator length longer than\n"
- " remaining response length=%d\n", (len - off));
- return SG_LIB_CAT_MALFORMED;
+ for (k = 0, off = -1; true; ++k) {
+ if ((0 == k) && (0 != buff[2])) {
+ /* first already in buff */
+ if (m_assoc != VPD_ASSOC_LU)
+ return 0;
+ ip = buff;
+ c_set = 1;
+ assoc = VPD_ASSOC_LU;
+ is_sas = 0;
+ desig_type = 3;
+ i_len = 16;
+ } else {
+ u = sg_vpd_dev_id_iter(buff, len, &off, m_assoc, m_desig_type,
+ m_code_set);
+ if (0 != u)
+ break;
+ ucp = buff + off;
+ i_len = ucp[3];
+ if ((off + i_len + 4) > len) {
+ pr2serr(" VPD page error: designator length longer than\n"
+ " remaining response length=%d\n", (len - off));
+ return SG_LIB_CAT_MALFORMED;
+ }
+ ip = ucp + 4;
+ p_id = ((ucp[0] >> 4) & 0xf);
+ c_set = (ucp[0] & 0xf);
+ piv = ((ucp[1] & 0x80) ? 1 : 0);
+ is_sas = (piv && (6 == p_id)) ? 1 : 0;
+ assoc = ((ucp[1] >> 4) & 0x3);
+ desig_type = (ucp[1] & 0xf);
}
- ip = ucp + 4;
- p_id = ((ucp[0] >> 4) & 0xf);
- c_set = (ucp[0] & 0xf);
- piv = ((ucp[1] & 0x80) ? 1 : 0);
- is_sas = (piv && (6 == p_id)) ? 1 : 0;
- assoc = ((ucp[1] >> 4) & 0x3);
- desig_type = (ucp[1] & 0xf);
-skip_1st_iter:
switch (desig_type) {
case 0: /* vendor specific */
break;
@@ -3700,7 +3699,7 @@ svpd_decode_all(int sg_fd, struct opts_t * op)
int in_len = op->maxlen;
int prev_pn = -1;
- rp = rsp_buff;
+ res = 0;
for (k = 0, off = 0; off < in_len; ++k, off += bump) {
rp = rsp_buff + off;
pn = rp[1];
@@ -3734,7 +3733,7 @@ svpd_decode_all(int sg_fd, struct opts_t * op)
}
}
}
- return 0;
+ return res;
}
@@ -3747,7 +3746,6 @@ main(int argc, char * argv[])
int inhex_len = 0;
int ret = 0;
int subvalue = 0;
- int page_pdt = -1;
struct opts_t opts;
struct opts_t * op;
@@ -3913,7 +3911,6 @@ main(int argc, char * argv[])
op->num_vpd = vnp->value;
subvalue = vnp->subvalue;
op->vend_prod_num = subvalue;
- page_pdt = vnp->pdt;
} else {
cp = strchr(op->page_str, ',');
if (cp && op->vend_prod) {
@@ -3988,20 +3985,14 @@ main(int argc, char * argv[])
if (op->verbose)
pr2serr("Guessing from --inhex= this is a standard "
"INQUIRY\n");
- if (page_pdt < 0)
- page_pdt = 0x1f & rsp_buff[0];
} else if (rsp_buff[2] <= 2) {
if (op->verbose)
pr2serr("Guessing from --inhex this is VPD page 0x%x\n",
rsp_buff[1]);
op->num_vpd = rsp_buff[1];
- if (page_pdt < 0)
- page_pdt = 0x1f & rsp_buff[0];
} else {
if (op->num_vpd > 0x80) {
op->num_vpd = rsp_buff[1];
- if (page_pdt < 0)
- page_pdt = 0x1f & rsp_buff[0];
if (op->verbose)
pr2serr("Guessing from --inhex this is VPD page "
"0x%x\n", rsp_buff[1]);
diff --git a/src/sg_write_same.c b/src/sg_write_same.c
index 640d1c64..f08f03a7 100644
--- a/src/sg_write_same.c
+++ b/src/sg_write_same.c
@@ -319,7 +319,6 @@ main(int argc, char * argv[])
op->numblocks = DEF_WS_NUMBLOCKS;
op->pref_cdb_size = DEF_WS_CDB_SIZE;
op->timeout = DEF_TIMEOUT_SECS;
- vb = 0;
while (1) {
int option_index = 0;
diff --git a/src/sg_xcopy.c b/src/sg_xcopy.c
index ae0265ab..25c17f24 100644
--- a/src/sg_xcopy.c
+++ b/src/sg_xcopy.c
@@ -37,6 +37,7 @@
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <string.h>
#include <signal.h>
#include <ctype.h>
@@ -412,7 +413,7 @@ dd_filetype_str(int ft, char * buff)
if (FT_OTHER & ft)
off += snprintf(buff + off, 32, "other (perhaps ordinary file) ");
if (FT_ERROR & ft)
- off += snprintf(buff + off, 32, "unable to 'stat' file ");
+ snprintf(buff + off, 32, "unable to 'stat' file ");
return buff;
}
@@ -1304,8 +1305,8 @@ main(int argc, char * argv[])
int src_desc_len;
int dst_desc_len;
int seg_desc_type;
- int on_src = 0;
- int on_dst = 0;
+ bool on_src = false;
+ bool on_src_dst_given = false;
ixcf.fname[0] = '\0';
oxcf.fname[0] = '\0';
@@ -1433,11 +1434,25 @@ main(int argc, char * argv[])
/* look for long options that start with '--' */
else if (0 == strncmp(key, "--help", 6))
++num_help;
- else if (0 == strncmp(key, "--on_dst", 8))
- ++on_dst;
- else if (0 == strncmp(key, "--on_src", 8))
- ++on_src;
- else if (0 == strncmp(key, "--verb", 6))
+ else if (0 == strncmp(key, "--on_dst", 8)) {
+ on_src = false;
+ if (on_src_dst_given) {
+ pr2serr("Syntax error - either specify --on_src OR "
+ "--on_dst\n");
+ pr2serr("For more information use '--help'\n");
+ return SG_LIB_SYNTAX_ERROR;
+ }
+ on_src_dst_given = true;
+ } else if (0 == strncmp(key, "--on_src", 8)) {
+ on_src = true;
+ if (on_src_dst_given) {
+ pr2serr("Syntax error - either specify --on_src OR "
+ "--on_dst\n");
+ pr2serr("For more information use '--help'\n");
+ return SG_LIB_SYNTAX_ERROR;
+ }
+ on_src_dst_given = true;
+ } else if (0 == strncmp(key, "--verb", 6))
verbose += 1;
else if (0 == strncmp(key, "--vers", 6)) {
pr2serr(ME "%s\n", version_str);
@@ -1481,13 +1496,7 @@ main(int argc, char * argv[])
usage(num_help);
return 0;
}
- if (on_src && on_dst) {
- pr2serr("Syntax error - either specify --on_src OR "
- "--on_dst\n");
- pr2serr("For more information use '--help'\n");
- return SG_LIB_SYNTAX_ERROR;
- }
- if ((! on_src) && (! on_dst)) {
+ if (! on_src_dst_given) {
if ((!! ixcf.xcopy_given) == (!! oxcf.xcopy_given)) {
char * csp;
char * cdp;
@@ -1496,18 +1505,18 @@ main(int argc, char * argv[])
cdp = getenv(XCOPY_TO_DST);
if ((!! csp) == (!! cdp)) {
#if DEF_XCOPY_SRC0_DST1 == 0
- on_src = 1;
+ on_src = true;
#else
- on_dst = 1;
+ on_src = false;
#endif
} else if (csp)
- on_src = 1;
+ on_src = true;
else
- on_dst = 1;
+ on_src = false;
} else if (ixcf.xcopy_given)
- on_src = 1;
+ on_src = true;
else
- on_dst = 1;
+ on_src = false;
}
if (verbose > 1)
pr2serr(" >>> Extended Copy(LID1) command will be sent to %s device "
@@ -1559,8 +1568,6 @@ main(int argc, char * argv[])
install_handler(SIGPIPE, interrupt_handler);
install_handler(SIGUSR1, siginfo_handler);
- infd = STDIN_FILENO;
- outfd = STDOUT_FILENO;
ixcf.pdt = -1;
oxcf.pdt = -1;
if (ixcf.fname[0] && ('-' != ixcf.fname[0])) {
diff --git a/src/sginfo.c b/src/sginfo.c
index 60edb666..2d2f78d7 100644
--- a/src/sginfo.c
+++ b/src/sginfo.c
@@ -2633,7 +2633,8 @@ sas_proto_spec_lu(struct mpage_info * mpi, const char * prefix)
static int
common_proto_spec_lu(struct mpage_info * mpi, const char * prefix)
{
- int status, proto_id;
+ int status;
+ int proto_id = 0;
status = get_protocol_id(0, cbuffer, &proto_id, NULL);
if (status)
@@ -2737,7 +2738,8 @@ sas_proto_spec_port(struct mpage_info * mpi, const char * prefix)
static int
common_proto_spec_port(struct mpage_info * mpi, const char * prefix)
{
- int status, proto_id;
+ int status;
+ int proto_id = 0;
status = get_protocol_id(1, cbuffer, &proto_id, NULL);
if (status)
@@ -2840,7 +2842,8 @@ sas_phy_control_discover(struct mpage_info * mpi, const char * prefix)
static int
common_proto_spec_port_sp1(struct mpage_info * mpi, const char * prefix)
{
- int status, proto_id;
+ int status;
+ int proto_id = 0;
status = get_protocol_id(1, cbuffer, &proto_id, NULL);
if (status)
@@ -2935,7 +2938,8 @@ sas_shared_spec_port(struct mpage_info * mpi, const char * prefix)
static int
common_proto_spec_port_sp2(struct mpage_info * mpi, const char * prefix)
{
- int status, proto_id;
+ int status;
+ int proto_id = 0;
status = get_protocol_id(1, cbuffer, &proto_id, NULL);
if (status)
diff --git a/src/sgm_dd.c b/src/sgm_dd.c
index 88d32e3a..e4187cce 100644
--- a/src/sgm_dd.c
+++ b/src/sgm_dd.c
@@ -258,7 +258,7 @@ dd_filetype_str(int ft, char * buff)
if (FT_OTHER & ft)
off += snprintf(buff + off, 32, "other (perhaps ordinary file) ");
if (FT_ERROR & ft)
- off += snprintf(buff + off, 32, "unable to 'stat' file ");
+ snprintf(buff + off, 32, "unable to 'stat' file ");
return buff;
}
diff --git a/src/sgp_dd.c b/src/sgp_dd.c
index 5be338b2..3deae82c 100644
--- a/src/sgp_dd.c
+++ b/src/sgp_dd.c
@@ -1059,7 +1059,6 @@ sg_prepare(int fd, int bs, int bpt)
pr2serr(ME "sg driver prior to 3.x.y\n");
return 1;
}
- res = 0;
t = bs * bpt;
res = ioctl(fd, SG_SET_RESERVED_SIZE, &t);
if (res < 0)