aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--doc/sg_inq.82
-rw-r--r--lib/sg_lib.c20
-rw-r--r--lib/sg_lib_data.c2
4 files changed, 16 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 70f1ac38..fd6ee553 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@ directory have their own "man" pages. There is also a sg3_utils man page.
Changelog for sg3_utils-1.30 [20100430] [svn: r342]
- sg_inq: update version descriptor list to spc4r24
- sg_lib: sync asc/ascq list to spc4r24
+ - dStrHex(): trim excess trailing spaces
- sg_read_long: add --readonly option (open() is rw)
- sg_raw: add --readonly option (open() is rw)
diff --git a/doc/sg_inq.8 b/doc/sg_inq.8
index b1ce04ea..15d457d0 100644
--- a/doc/sg_inq.8
+++ b/doc/sg_inq.8
@@ -91,7 +91,7 @@ given to the \fI\-\-page=PG\fR option.
rather than decode a standard INQUIRY response, a VPD page or command
support data; print out the response in hex to stdout. Error messages and
warnings are typically output to stderr. When used twice with the ATA
-Information VPD page [0x89] decodes the start of the response then output
+Information VPD page [0x89] decodes the start of the response then outputs
the ATA IDENTIFY (PACKET) DEVICE response in hexadecimal bytes (not 16 bit
words). When used three times with the ATA Information VPD page [0x89] or
the \fI\-\-ata\fR option, this utility outputs the ATA IDENTIFY (PACKET)
diff --git a/lib/sg_lib.c b/lib/sg_lib.c
index f1ecbe94..8d612e4f 100644
--- a/lib/sg_lib.c
+++ b/lib/sg_lib.c
@@ -1111,7 +1111,8 @@ safe_strerror(int errnum)
void
dStrHex(const char* str, int len, int no_ascii)
{
- const char* p = str;
+ const char * p = str;
+ const char * formatstr;
unsigned char c;
char buff[82];
int a = 0;
@@ -1123,6 +1124,7 @@ dStrHex(const char* str, int len, int no_ascii)
if (len <= 0)
return;
+ formatstr = (0 == no_ascii) ? "%.76s\n" : "%.56s\n";
memset(buff, ' ', 80);
buff[80] = '\0';
if (no_ascii < 0) {
@@ -1134,13 +1136,15 @@ dStrHex(const char* str, int len, int no_ascii)
sprintf(&buff[bpos], "%.2x", (int)(unsigned char)c);
buff[bpos + 2] = ' ';
if ((k > 0) && (0 == ((k + 1) % 16))) {
- printf("%.60s\n", buff);
+ printf(formatstr, buff);
bpos = bpstart;
memset(buff, ' ', 80);
}
}
- if (bpos > bpstart)
- printf("%.60s\n", buff);
+ if (bpos > bpstart) {
+ buff[bpos + 2] = '\0';
+ printf("%s\n", buff);
+ }
return;
}
/* no_ascii>=0, start each line with address (offset) */
@@ -1162,7 +1166,7 @@ dStrHex(const char* str, int len, int no_ascii)
buff[cpos++] = c;
}
if (cpos > (cpstart + 15)) {
- printf("%.76s\n", buff);
+ printf(formatstr, buff);
bpos = bpstart;
cpos = cpstart;
a += 16;
@@ -1171,8 +1175,10 @@ dStrHex(const char* str, int len, int no_ascii)
buff[k + 1] = ' ';
}
}
- if (cpos > cpstart)
- printf("%.76s\n", buff);
+ if (cpos > cpstart) {
+ buff[cpos] = '\0';
+ printf("%s\n", buff);
+ }
}
/* Output to ASCII-Hex bytes to 'b' not to exceed 'b_len' characters.
diff --git a/lib/sg_lib_data.c b/lib/sg_lib_data.c
index 70b62350..f2602f85 100644
--- a/lib/sg_lib_data.c
+++ b/lib/sg_lib_data.c
@@ -15,7 +15,7 @@
#endif
-const char * sg_lib_version_str = "1.59 20100415"; /* spc-4 rev 24 */
+const char * sg_lib_version_str = "1.60 20100511"; /* spc-4 rev 24 */
struct sg_lib_value_name_t sg_lib_normal_opcodes[] = {
{0, 0, "Test Unit Ready"},