aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--README15
-rw-r--r--debian/changelog2
-rw-r--r--include/sg_cmds_extra.h8
-rw-r--r--include/sg_cmds_mmc.h2
-rw-r--r--lib/sg_cmds_basic.c4
-rw-r--r--lib/sg_cmds_extra.c10
-rw-r--r--lib/sg_cmds_mmc.c2
-rw-r--r--lib/sg_lib.c2
-rw-r--r--lib/sg_lib_data.c2
-rw-r--r--sg3_utils.spec2
-rw-r--r--src/sg_get_config.c6
-rw-r--r--src/sg_logs.c118
-rw-r--r--src/sg_opcodes.c28
-rw-r--r--src/sg_read_long.c4
-rw-r--r--src/sg_safte.c10
-rw-r--r--src/sg_verify.c10
-rw-r--r--src/sg_write_long.c6
-rw-r--r--src/sgp_dd.c13
19 files changed, 133 insertions, 115 deletions
diff --git a/ChangeLog b/ChangeLog
index 645ea135..c4ca1fda 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.26 [20080326]
+Changelog for sg3_utils-1.26 [20080327]
- sg_ses: sync with ses2r19b
- sg_get_config: sync with mmc6r01
- allow Microcode upgrade and DVD read feature descriptors
@@ -29,6 +29,8 @@ Changelog for sg3_utils-1.26 [20080326]
- sg_request: add a '--progress' option (similar to sg_turs)
- sg_turs: add more to man page about '--progress' indication
- sg_lib: update asc/ascq code to spc4r13
+ - audit of dangerous 'u64 = uch[24] << 24' code, replace most
+ 'unsigned long's
- utils/hxascdmp: add hxascdmp(1) man page
- split sg_lib into sg_lib_data.[hc] and sg_lib.[hc]
- split sg_cmds_extra into sg_cmds_extra and sg_cmds_mmc
diff --git a/README b/README
index 298207f7..d1b2e311 100644
--- a/README
+++ b/README
@@ -324,10 +324,23 @@ The include file path issues are now all addressed in one file called
sg.h header files has not been a problem in the latter lk 2.4 and lk 2.6
series.
+Dangerous code
+==============
+This code:
+ unsigned char uc = 0x80;
+ unsigned long long = ull;
+ ull = (uc << 24);
+Gives an unexpected result because the 'unary conversion' of uc to a (32 bit
+signed) 'int' before the shift. The resultant type from the shift is also
+an int and it has its top bit set so there is sign extension when it is
+assigned into a 64 bit integer. The above will fail in a similar on 64
+bit architectures that use the LP64 data model, if 'unsigned long ul' is used
+instead of ull variable in the above code example.
+
Other SCSI and storage tools
============================
See http://www.torque.net/sg/tools.html
Doug Gilbert
-18th March 2008
+27th March 2008
diff --git a/debian/changelog b/debian/changelog
index 797e46ca..63e755f3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,7 +2,7 @@ sg3-utils (1.26-0.1) unstable; urgency=low
* New upstream version
- -- Doug Gilbert <dgilbert@interlog.com> Wed, 26 Mar 2008 09:00:00 -0400
+ -- Doug Gilbert <dgilbert@interlog.com> Thu, 27 Mar 2008 16:00:00 -0400
sg3-utils (1.25-0.1) unstable; urgency=low
diff --git a/include/sg_cmds_extra.h b/include/sg_cmds_extra.h
index 164c40a1..e686b081 100644
--- a/include/sg_cmds_extra.h
+++ b/include/sg_cmds_extra.h
@@ -113,7 +113,7 @@ extern int sg_ll_read_defect10(int sg_fd, int req_plist, int req_glist,
* SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
* -1 -> other failure */
extern int sg_ll_read_long10(int sg_fd, int pblock, int correct,
- unsigned long lba, void * resp, int xfer_len,
+ unsigned int lba, void * resp, int xfer_len,
int * offsetp, int noisy, int verbose);
/* Invokes a SCSI READ LONG (16) command (SBC). Note that 'xfer_len'
@@ -206,8 +206,8 @@ extern int sg_ll_set_id_info(int sg_fd, int itype, void * paramp,
* SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
* -1 -> other failure */
extern int sg_ll_verify10(int sg_fd, int vrprotect, int dpo, int bytechk,
- unsigned long lba, int veri_len, void * data_out,
- int data_out_len, unsigned long * infop, int noisy,
+ unsigned int lba, int veri_len, void * data_out,
+ int data_out_len, unsigned int * infop, int noisy,
int verbose);
/* Invokes a SCSI WRITE BUFFER command (SPC). Return of 0 ->
@@ -228,7 +228,7 @@ extern int sg_ll_write_buffer(int sg_fd, int mode, int buffer_id,
* SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
* -1 -> other failure */
extern int sg_ll_write_long10(int sg_fd, int cor_dis, int wr_uncor, int pblock,
- unsigned long lba, void * data_out,
+ unsigned int lba, void * data_out,
int xfer_len, int * offsetp, int noisy,
int verbose);
diff --git a/include/sg_cmds_mmc.h b/include/sg_cmds_mmc.h
index 32c59944..3b2475ea 100644
--- a/include/sg_cmds_mmc.h
+++ b/include/sg_cmds_mmc.h
@@ -47,7 +47,7 @@ extern int sg_ll_get_config(int sg_fd, int rt, int starting, void * resp,
* supported, SG_LIB_CAT_ILLEGAL_REQ if field in cdb not supported,
* SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_ABORTED_COMMAND, else -1 */
extern int sg_ll_get_performance(int sg_fd, int data_type,
- unsigned long starting_lba, int max_num_desc,
+ unsigned int starting_lba, int max_num_desc,
int type, void * resp, int mx_resp_len,
int noisy, int verbose);
diff --git a/lib/sg_cmds_basic.c b/lib/sg_cmds_basic.c
index 4baf2f00..8dd10c08 100644
--- a/lib/sg_cmds_basic.c
+++ b/lib/sg_cmds_basic.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999-2007 Douglas Gilbert.
+ * Copyright (c) 1999-2008 Douglas Gilbert.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -45,7 +45,7 @@
#include "sg_pt.h"
-static char * version_str = "1.42 20071120";
+static char * version_str = "1.43 20080327";
#define SENSE_BUFF_LEN 32 /* Arbitrary, could be larger */
diff --git a/lib/sg_cmds_extra.c b/lib/sg_cmds_extra.c
index 2d852338..a721f4a5 100644
--- a/lib/sg_cmds_extra.c
+++ b/lib/sg_cmds_extra.c
@@ -978,7 +978,7 @@ has_blk_ili(unsigned char * sensep, int sb_len)
* field written to 'offsetp', SG_LIB_CAT_ABORTED_COMMAND,
* SG_LIB_CAT_NOT_READY -> device not ready, -1 -> other failure */
int
-sg_ll_read_long10(int sg_fd, int pblock, int correct, unsigned long lba,
+sg_ll_read_long10(int sg_fd, int pblock, int correct, unsigned int lba,
void * resp, int xfer_len, int * offsetp, int noisy,
int verbose)
{
@@ -1173,7 +1173,7 @@ sg_ll_read_long16(int sg_fd, int pblock, int correct, uint64_t llba,
* SG_LIB_CAT_ABORTED_COMMAND, -1 -> other failure */
int
sg_ll_write_long10(int sg_fd, int cor_dis, int wr_uncor, int pblock,
- unsigned long lba, void * data_out, int xfer_len,
+ unsigned int lba, void * data_out, int xfer_len,
int * offsetp, int noisy, int verbose)
{
int k, res, sense_cat, ret;
@@ -1375,8 +1375,8 @@ sg_ll_write_long16(int sg_fd, int cor_dis, int wr_uncor, int pblock,
* -1 -> other failure */
int
sg_ll_verify10(int sg_fd, int vrprotect, int dpo, int bytechk,
- unsigned long lba, int veri_len, void * data_out,
- int data_out_len, unsigned long * infop, int noisy,
+ unsigned int lba, int veri_len, void * data_out,
+ int data_out_len, unsigned int * infop, int noisy,
int verbose)
{
int k, res, ret, sense_cat;
@@ -1437,7 +1437,7 @@ sg_ll_verify10(int sg_fd, int vrprotect, int dpo, int bytechk,
valid = sg_get_sense_info_fld(sense_b, slen, &ull);
if (valid) {
if (infop)
- *infop = (unsigned long)ull;
+ *infop = (unsigned int)ull;
ret = SG_LIB_CAT_MEDIUM_HARD_WITH_INFO;
} else
ret = SG_LIB_CAT_MEDIUM_HARD;
diff --git a/lib/sg_cmds_mmc.c b/lib/sg_cmds_mmc.c
index e1497d7c..43959cb1 100644
--- a/lib/sg_cmds_mmc.c
+++ b/lib/sg_cmds_mmc.c
@@ -217,7 +217,7 @@ sg_ll_get_config(int sg_fd, int rt, int starting, void * resp,
* supported, SG_LIB_CAT_ILLEGAL_REQ if field in cdb not supported,
* SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_ABORTED_COMMAND, else -1 */
int
-sg_ll_get_performance(int sg_fd, int data_type, unsigned long starting_lba,
+sg_ll_get_performance(int sg_fd, int data_type, unsigned int starting_lba,
int max_num_desc, int ttype, void * resp,
int mx_resp_len, int noisy, int verbose)
{
diff --git a/lib/sg_lib.c b/lib/sg_lib.c
index aa0204bf..cf16c540 100644
--- a/lib/sg_lib.c
+++ b/lib/sg_lib.c
@@ -265,7 +265,7 @@ sg_get_sense_info_fld(const unsigned char * sensep, int sb_len,
case 0x70:
case 0x71:
if (info_outp)
- *info_outp = (sensep[3] << 24) + (sensep[4] << 16) +
+ *info_outp = ((unsigned int)sensep[3] << 24) + (sensep[4] << 16) +
(sensep[5] << 8) + sensep[6];
return (sensep[0] & 0x80) ? 1 : 0;
case 0x72:
diff --git a/lib/sg_lib_data.c b/lib/sg_lib_data.c
index 82285ece..caa05a72 100644
--- a/lib/sg_lib_data.c
+++ b/lib/sg_lib_data.c
@@ -33,7 +33,7 @@
#include "sg_lib_data.h"
-const char * sg_lib_version_str = "1.43 20080316"; /* spc-4 rev 13 */
+const char * sg_lib_version_str = "1.44 20080327"; /* spc-4 rev 14 */
struct sg_lib_value_name_t sg_lib_normal_opcodes[] = {
{0, 0, "Test Unit Ready"},
diff --git a/sg3_utils.spec b/sg3_utils.spec
index 28ad9760..4b4aace3 100644
--- a/sg3_utils.spec
+++ b/sg3_utils.spec
@@ -79,7 +79,7 @@ fi
%{_libdir}/*.la
%changelog
-* Wed Mar 26 2008 - dgilbert at interlog dot com
+* Thu Mar 27 2008 - dgilbert at interlog dot com
- sg_get_config sync with mmc6r01, add sg_sat_phy_event
* sg3_utils-1.26
diff --git a/src/sg_get_config.c b/src/sg_get_config.c
index a839b18d..7f10d943 100644
--- a/src/sg_get_config.c
+++ b/src/sg_get_config.c
@@ -49,7 +49,7 @@
*/
-static char * version_str = "0.34 20080318"; /* mmc6r01 */
+static char * version_str = "0.34 20080327"; /* mmc6r01 */
#define MX_ALLOC_LEN 8192
#define NAME_BUFF_SZ 64
@@ -799,8 +799,8 @@ decode_feature(int feature, unsigned char * ucp, int len)
feature);
printf(" Disc control blocks:\n");
for (k = 4; k < len; k += 4) {
- printf(" 0x%x\n", (ucp[k] << 24) + (ucp[k + 1] << 16) +
- (ucp[k + 2] << 8) + ucp[k + 3]);
+ printf(" 0x%x\n", ((unsigned int)ucp[k] << 24) +
+ (ucp[k + 1] << 16) + (ucp[k + 2] << 8) + ucp[k + 3]);
}
break;
case 0x10b: /* DVD CPRM */
diff --git a/src/sg_logs.c b/src/sg_logs.c
index 1159be13..0198a7c7 100644
--- a/src/sg_logs.c
+++ b/src/sg_logs.c
@@ -25,7 +25,7 @@
*/
-static char * version_str = "0.80 20080218"; /* SPC-4 revision 12 */
+static char * version_str = "0.80 20080227"; /* SPC-4 revision 12 */
#define MX_ALLOC_LEN (0xfffc)
#define SHORT_RESP_LEN 128
@@ -1329,118 +1329,118 @@ show_ie_page(unsigned char * resp, int len, int show_pcb, int full)
}
static void
-show_sas_phy_event_info(int peis, unsigned long val, unsigned long thresh_val)
+show_sas_phy_event_info(int peis, unsigned int val, unsigned thresh_val)
{
switch (peis) {
case 0:
printf(" No event\n");
break;
case 0x1:
- printf(" Invalid word count: %lu\n", val);
+ printf(" Invalid word count: %u\n", val);
break;
case 0x2:
- printf(" Running disparity error count: %lu\n", val);
+ printf(" Running disparity error count: %u\n", val);
break;
case 0x3:
- printf(" Loss of dword synchronization count: %lu\n", val);
+ printf(" Loss of dword synchronization count: %u\n", val);
break;
case 0x4:
- printf(" Phy reset problem count: %lu\n", val);
+ printf(" Phy reset problem count: %u\n", val);
break;
case 0x5:
- printf(" Elasticity buffer overflow count: %lu\n", val);
+ printf(" Elasticity buffer overflow count: %u\n", val);
break;
case 0x6:
- printf(" Received ERROR count: %lu\n", val);
+ printf(" Received ERROR count: %u\n", val);
break;
case 0x20:
- printf(" Received address frame error count: %lu\n", val);
+ printf(" Received address frame error count: %u\n", val);
break;
case 0x21:
- printf(" Transmitted OPEN_REJECT abandon count: %lu\n", val);
+ printf(" Transmitted OPEN_REJECT abandon count: %u\n", val);
break;
case 0x22:
- printf(" Received OPEN_REJECT abandon count: %lu\n", val);
+ printf(" Received OPEN_REJECT abandon count: %u\n", val);
break;
case 0x23:
- printf(" Transmitted OPEN_REJECT retry count: %lu\n", val);
+ printf(" Transmitted OPEN_REJECT retry count: %u\n", val);
break;
case 0x24:
- printf(" Received OPEN_REJECT retry count: %lu\n", val);
+ printf(" Received OPEN_REJECT retry count: %u\n", val);
break;
case 0x25:
- printf(" Received AIP (PARTIAL) count: %lu\n", val);
+ printf(" Received AIP (PARTIAL) count: %u\n", val);
break;
case 0x26:
- printf(" Received AIP (CONNECTION) count: %lu\n", val);
+ printf(" Received AIP (CONNECTION) count: %u\n", val);
break;
case 0x27:
- printf(" Transmitted BREAK count: %lu\n", val);
+ printf(" Transmitted BREAK count: %u\n", val);
break;
case 0x28:
- printf(" Received BREAK count: %lu\n", val);
+ printf(" Received BREAK count: %u\n", val);
break;
case 0x29:
- printf(" Break timeout count: %lu\n", val);
+ printf(" Break timeout count: %u\n", val);
break;
case 0x2a:
- printf(" Connection count: %lu\n", val);
+ printf(" Connection count: %u\n", val);
break;
case 0x2b:
- printf(" Peak transmitted pathway blocked count: %lu\n",
+ printf(" Peak transmitted pathway blocked count: %u\n",
val & 0xff);
- printf(" Peak value detector threshold: %lu\n",
+ printf(" Peak value detector threshold: %u\n",
thresh_val & 0xff);
break;
case 0x2c:
printf(" Peak transmitted arbitration wait time (us to 32767): "
- "%lu\n", val & 0xffff);
- printf(" Peak value detector threshold: %lu\n",
+ "%u\n", val & 0xffff);
+ printf(" Peak value detector threshold: %u\n",
thresh_val & 0xffff);
break;
case 0x2d:
- printf(" Peak arbitration time (us): %lu\n", val);
- printf(" Peak value detector threshold: %lu\n", thresh_val);
+ printf(" Peak arbitration time (us): %u\n", val);
+ printf(" Peak value detector threshold: %u\n", thresh_val);
break;
case 0x2e:
- printf(" Peak connection time (us): %lu\n", val);
- printf(" Peak value detector threshold: %lu\n", thresh_val);
+ printf(" Peak connection time (us): %u\n", val);
+ printf(" Peak value detector threshold: %u\n", thresh_val);
break;
case 0x40:
- printf(" Transmitted SSP frame count: %lu\n", val);
+ printf(" Transmitted SSP frame count: %u\n", val);
break;
case 0x41:
- printf(" Received SSP frame count: %lu\n", val);
+ printf(" Received SSP frame count: %u\n", val);
break;
case 0x42:
- printf(" Transmitted SSP frame error count: %lu\n", val);
+ printf(" Transmitted SSP frame error count: %u\n", val);
break;
case 0x43:
- printf(" Received SSP frame error count: %lu\n", val);
+ printf(" Received SSP frame error count: %u\n", val);
break;
case 0x44:
- printf(" Transmitted CREDIT_BLOCKED count: %lu\n", val);
+ printf(" Transmitted CREDIT_BLOCKED count: %u\n", val);
break;
case 0x45:
- printf(" Received CREDIT_BLOCKED count: %lu\n", val);
+ printf(" Received CREDIT_BLOCKED count: %u\n", val);
break;
case 0x50:
- printf(" Transmitted SATA frame count: %lu\n", val);
+ printf(" Transmitted SATA frame count: %u\n", val);
break;
case 0x51:
- printf(" Received SATA frame count: %lu\n", val);
+ printf(" Received SATA frame count: %u\n", val);
break;
case 0x52:
- printf(" SATA flow control buffer overflow count: %lu\n", val);
+ printf(" SATA flow control buffer overflow count: %u\n", val);
break;
case 0x60:
- printf(" Transmitted SMP frame count: %lu\n", val);
+ printf(" Transmitted SMP frame count: %u\n", val);
break;
case 0x61:
- printf(" Received SMP frame count: %lu\n", val);
+ printf(" Received SMP frame count: %u\n", val);
break;
case 0x63:
- printf(" Received SMP frame error count: %lu\n", val);
+ printf(" Received SMP frame error count: %u\n", val);
break;
default:
break;
@@ -1454,7 +1454,7 @@ show_sas_rel_target_port(unsigned char * ucp, int param_len,
int j, m, n, nphys, pcb, t, sz, spld_len;
unsigned char * vcp;
uint64_t ull;
- unsigned long ul;
+ unsigned int ui;
char pcb_str[PCB_STR_LEN];
char s[64];
@@ -1503,15 +1503,15 @@ show_sas_rel_target_port(unsigned char * ucp, int param_len,
}
printf(" att_sas_addr=0x%" PRIx64 "\n", ull);
printf(" att_tport_mask=0x%x\n", vcp[7]);
- ul = (vcp[32] << 24) | (vcp[33] << 16) | (vcp[34] << 8) | vcp[35];
- printf(" inv_dwords=%ld\n", ul);
- ul = (vcp[40] << 24) | (vcp[41] << 16) | (vcp[42] << 8) | vcp[43];
- printf(" loss_dword_sync=%ld\n", ul);
+ ui = (vcp[32] << 24) | (vcp[33] << 16) | (vcp[34] << 8) | vcp[35];
+ printf(" inv_dwords=%u\n", ui);
+ ui = (vcp[40] << 24) | (vcp[41] << 16) | (vcp[42] << 8) | vcp[43];
+ printf(" loss_dword_sync=%u\n", ui);
printf(" neg_log_lrate=%d\n", 0xf & vcp[5]);
- ul = (vcp[44] << 24) | (vcp[45] << 16) | (vcp[46] << 8) | vcp[47];
- printf(" phy_reset_probs=%ld\n", ul);
- ul = (vcp[36] << 24) | (vcp[37] << 16) | (vcp[38] << 8) | vcp[39];
- printf(" running_disparity=%ld\n", ul);
+ ui = (vcp[44] << 24) | (vcp[45] << 16) | (vcp[46] << 8) | vcp[47];
+ printf(" phy_reset_probs=%u\n", ui);
+ ui = (vcp[36] << 24) | (vcp[37] << 16) | (vcp[38] << 8) | vcp[39];
+ printf(" running_disparity=%u\n", ui);
printf(" reason=0x%x\n", (vcp[5] & 0xf0) >> 4);
for (n = 0, ull = vcp[8]; n < 8; ++n) {
ull <<= 8; ull |= vcp[8 + n];
@@ -1595,19 +1595,19 @@ show_sas_rel_target_port(unsigned char * ucp, int param_len,
}
printf(" attached SAS address = 0x%" PRIx64 "\n", ull);
printf(" attached phy identifier = %d\n", vcp[24]);
- ul = (vcp[32] << 24) | (vcp[33] << 16) | (vcp[34] << 8) | vcp[35];
- printf(" Invalid DWORD count = %ld\n", ul);
- ul = (vcp[36] << 24) | (vcp[37] << 16) | (vcp[38] << 8) | vcp[39];
- printf(" Running disparity error count = %ld\n", ul);
- ul = (vcp[40] << 24) | (vcp[41] << 16) | (vcp[42] << 8) | vcp[43];
- printf(" Loss of DWORD synchronization = %ld\n", ul);
- ul = (vcp[44] << 24) | (vcp[45] << 16) | (vcp[46] << 8) | vcp[47];
- printf(" Phy reset problem = %ld\n", ul);
+ ui = (vcp[32] << 24) | (vcp[33] << 16) | (vcp[34] << 8) | vcp[35];
+ printf(" Invalid DWORD count = %u\n", ui);
+ ui = (vcp[36] << 24) | (vcp[37] << 16) | (vcp[38] << 8) | vcp[39];
+ printf(" Running disparity error count = %u\n", ui);
+ ui = (vcp[40] << 24) | (vcp[41] << 16) | (vcp[42] << 8) | vcp[43];
+ printf(" Loss of DWORD synchronization = %u\n", ui);
+ ui = (vcp[44] << 24) | (vcp[45] << 16) | (vcp[46] << 8) | vcp[47];
+ printf(" Phy reset problem = %u\n", ui);
}
if (spld_len > 51) {
int num_ped, peis;
unsigned char * xcp;
- unsigned long pvdt;
+ unsigned int pvdt;
num_ped = vcp[51];
if (num_ped > 0) {
@@ -1620,11 +1620,11 @@ show_sas_rel_target_port(unsigned char * ucp, int param_len,
xcp = vcp + 52;
for (m = 0; m < (num_ped * 12); m += 12, xcp += 12) {
peis = xcp[3];
- ul = (xcp[4] << 24) | (xcp[5] << 16) | (xcp[6] << 8) |
+ ui = (xcp[4] << 24) | (xcp[5] << 16) | (xcp[6] << 8) |
xcp[7];
pvdt = (xcp[8] << 24) | (xcp[9] << 16) | (xcp[10] << 8) |
xcp[11];
- show_sas_phy_event_info(peis, ul, pvdt);
+ show_sas_phy_event_info(peis, ui, pvdt);
}
}
}
diff --git a/src/sg_opcodes.c b/src/sg_opcodes.c
index 95a9aa29..a081c42f 100644
--- a/src/sg_opcodes.c
+++ b/src/sg_opcodes.c
@@ -1,5 +1,5 @@
/* A utility program originally written for the Linux OS SCSI subsystem.
- * Copyright (C) 2004-2007 D. Gilbert
+ * Copyright (C) 2004-2008 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)
@@ -24,7 +24,7 @@
#include "sg_cmds_basic.h"
#include "sg_cmds_extra.h"
-static char * version_str = "0.30 20070714"; /* spc4r11 */
+static char * version_str = "0.31 20080327"; /* spc4r11 */
// #define USE_LINUX_SG_IO_IF 1
@@ -511,7 +511,7 @@ static void list_all_codes(unsigned char * rsoc_buff, int rsoc_len,
int unsorted, int alpha, int rctd)
{
int k, j, cd_len, serv_act, len;
- unsigned long to;
+ unsigned int to;
unsigned char * ucp;
char name_buff[NAME_BUFF_SZ];
char sa_buff[8];
@@ -572,18 +572,18 @@ static void list_all_codes(unsigned char * rsoc_buff, int rsoc_len,
if (ucp[5] & 0x2) {
printf(" %.2x %.4s %3d", ucp[0], sa_buff,
((ucp[6] << 8) | ucp[7]));
- to = (ucp[12] << 24) + (ucp[13] << 16) + (ucp[14] << 8) +
- ucp[15];
+ to = ((unsigned int)ucp[12] << 24) + (ucp[13] << 16) +
+ (ucp[14] << 8) + ucp[15];
if (0 == to)
printf(" -");
else
- printf(" %8lu", to);
- to = (ucp[16] << 24) + (ucp[17] << 16) + (ucp[18] << 8) +
- ucp[19];
+ printf(" %8u", to);
+ to = ((unsigned int)ucp[16] << 24) + (ucp[17] << 16) +
+ (ucp[18] << 8) + ucp[19];
if (0 == to)
printf(" -");
else
- printf(" %8lu", to);
+ printf(" %8u", to);
printf(" %s\n", name_buff);
} else
printf(" %.2x %.4s %3d "
@@ -599,7 +599,7 @@ static void decode_cmd_to_descriptor(unsigned char * dp, int max_b_len,
char * b)
{
int len;
- unsigned long to;
+ unsigned int to;
if ((max_b_len < 2) || (NULL == dp))
return;
@@ -611,19 +611,19 @@ static void decode_cmd_to_descriptor(unsigned char * dp, int max_b_len,
"(expect 10)", len);
return;
}
- to = (dp[4] << 24) + (dp[5] << 16) + (dp[6] << 8) + dp[7];
+ to = ((unsigned int)dp[4] << 24) + (dp[5] << 16) + (dp[6] << 8) + dp[7];
if (0 == to)
snprintf(b, max_b_len, "no nominal timeout, ");
else
- snprintf(b, max_b_len, "nominal timeout: %lu secs, ", to);
+ snprintf(b, max_b_len, "nominal timeout: %u secs, ", to);
len = strlen(b);
max_b_len -= len;
b += len;
- to = (dp[8] << 24) + (dp[9] << 16) + (dp[10] << 8) + dp[11];
+ to = ((unsigned int)dp[8] << 24) + (dp[9] << 16) + (dp[10] << 8) + dp[11];
if (0 == to)
snprintf(b, max_b_len, "no recommended timeout");
else
- snprintf(b, max_b_len, "recommended timeout: %lu secs", to);
+ snprintf(b, max_b_len, "recommended timeout: %u secs", to);
return;
}
diff --git a/src/sg_read_long.c b/src/sg_read_long.c
index fc1f1c5b..1995c141 100644
--- a/src/sg_read_long.c
+++ b/src/sg_read_long.c
@@ -29,7 +29,7 @@
the sector data and the ECC bytes.
*/
-static char * version_str = "1.15 20080319";
+static char * version_str = "1.15 20080327";
#define MAX_XFER_LEN 10000
@@ -91,7 +91,7 @@ process_read_long(int sg_fd, int do_16, int pblock, int correct,
res = sg_ll_read_long16(sg_fd, pblock, correct, llba, data_out,
xfer_len, &offset, 1, verbose);
else
- res = sg_ll_read_long10(sg_fd, pblock, correct, (unsigned long)llba,
+ res = sg_ll_read_long10(sg_fd, pblock, correct, (unsigned int)llba,
data_out, xfer_len, &offset, 1, verbose);
ten_or = do_16 ? "16" : "10";
switch (res) {
diff --git a/src/sg_safte.c b/src/sg_safte.c
index 2b919abb..9f6128e0 100644
--- a/src/sg_safte.c
+++ b/src/sg_safte.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2007 Hannes Reinecke and Douglas Gilbert.
+ * Copyright (c) 2004-2008 Hannes Reinecke and Douglas Gilbert.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -48,7 +48,7 @@
* to the 'SCSI Accessed Fault-Tolerant Enclosures' (SAF-TE) spec.
*/
-static char * version_str = "0.23 20071002";
+static char * version_str = "0.24 20080327";
#define SENSE_BUFF_LEN 32 /* Arbitrary, could be larger */
@@ -287,7 +287,7 @@ do_safte_usage_statistics(int sg_fd, int do_hex, int do_raw, int verbose)
int res;
unsigned int rb_len;
unsigned char *rb_buff;
- unsigned long minutes;
+ unsigned int minutes;
rb_len = 16 + safte_cfg.vendor_specific;
rb_buff = (unsigned char *)malloc(rb_len);
@@ -319,10 +319,10 @@ do_safte_usage_statistics(int sg_fd, int do_hex, int do_raw, int verbose)
printf("Usage Statistics:\n");
minutes = (rb_buff[0] << 24) + (rb_buff[1] << 16) +
(rb_buff[2] << 8) + rb_buff[3];
- printf("\tPower on Minutes: %ld\n", minutes);
+ printf("\tPower on Minutes: %u\n", minutes);
minutes = (rb_buff[4] << 24) + (rb_buff[5] << 16) +
(rb_buff[6] << 8) + rb_buff[7];
- printf("\tPower on Cycles: %ld\n", minutes);
+ printf("\tPower on Cycles: %u\n", minutes);
free(rb_buff);
return 0;
diff --git a/src/sg_verify.c b/src/sg_verify.c
index 4d4da21c..cde03a92 100644
--- a/src/sg_verify.c
+++ b/src/sg_verify.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2007 Douglas Gilbert.
+ * Copyright (c) 2004-2008 Douglas Gilbert.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -48,7 +48,7 @@
* This program issues the SCSI VERIFY command to the given SCSI block device.
*/
-static char * version_str = "1.11 20071219";
+static char * version_str = "1.12 20080327";
#define ME "sg_verify: "
@@ -107,7 +107,7 @@ main(int argc, char * argv[])
int verbose = 0;
const char * device_name = NULL;
int ret = 0;
- unsigned long info = 0;
+ unsigned int info = 0;
while (1) {
int option_index = 0;
@@ -212,7 +212,7 @@ main(int argc, char * argv[])
for (; count > 0; count -= bpc, lba +=bpc) {
num = (count > bpc) ? bpc : count;
res = sg_ll_verify10(sg_fd, vrprotect, dpo, bytechk,
- (unsigned long)lba, num, NULL, 0,
+ (unsigned int)lba, num, NULL, 0,
&info, 1, verbose);
if (0 != res) {
ret = res;
@@ -239,7 +239,7 @@ main(int argc, char * argv[])
break;
case SG_LIB_CAT_MEDIUM_HARD_WITH_INFO:
fprintf(stderr, "medium or hardware error, reported "
- "lba=0x%lx\n", info);
+ "lba=0x%u\n", info);
break;
default:
fprintf(stderr, "Verify(10) failed near lba=%" PRIu64
diff --git a/src/sg_write_long.c b/src/sg_write_long.c
index e32df43a..ff9008dc 100644
--- a/src/sg_write_long.c
+++ b/src/sg_write_long.c
@@ -16,7 +16,7 @@
#include "sg_cmds_extra.h"
/* A utility program for the Linux OS SCSI subsystem.
- * Copyright (C) 2004-2007 D. Gilbert
+ * Copyright (C) 2004-2008 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)
@@ -31,7 +31,7 @@
This code was contributed by Saeed Bishara
*/
-static char * version_str = "1.15 20070919";
+static char * version_str = "1.16 20080327";
#define MAX_XFER_LEN 10000
@@ -250,7 +250,7 @@ int main(int argc, char * argv[])
writeLongBuff, xfer_len, &offset, 1, verbose);
else
res = sg_ll_write_long10(sg_fd, cor_dis, wr_uncor, pblock,
- (unsigned long)llba, writeLongBuff, xfer_len,
+ (unsigned int)llba, writeLongBuff, xfer_len,
&offset, 1, verbose);
ret = res;
switch (res) {
diff --git a/src/sgp_dd.c b/src/sgp_dd.c
index a20d692e..572bfd31 100644
--- a/src/sgp_dd.c
+++ b/src/sgp_dd.c
@@ -501,15 +501,18 @@ static void cleanup_out(void * v_clp)
static void * read_write_thread(void * v_clp)
{
- Rq_coll * clp = (Rq_coll *)v_clp;
+ Rq_coll * clp;
Rq_elem rel;
Rq_elem * rep = &rel;
size_t psz = 0;
- int sz = clp->bpt * clp->bs;
- int stop_after_write = 0;
- int64_t seek_skip = clp->seek - clp->skip;
+ int sz;
+ volatile int stop_after_write = 0;
+ int64_t seek_skip;
int blocks, status;
+ clp = (Rq_coll *)v_clp;
+ sz = clp->bpt * clp->bs;
+ seek_skip = clp->seek - clp->skip;
memset(rep, 0, sizeof(Rq_elem));
psz = getpagesize();
if (NULL == (rep->alloc_bp = (unsigned char *)malloc(sz + psz)))
@@ -615,7 +618,7 @@ static void * read_write_thread(void * v_clp)
status = pthread_mutex_unlock(&clp->in_mutex);
if (0 != status) err_exit(status, "unlock in_mutex");
pthread_cond_broadcast(&clp->out_sync_cv);
- return stop_after_write ? NULL : v_clp;
+ return stop_after_write ? NULL : clp;
}
static int normal_in_operation(Rq_coll * clp, Rq_elem * rep, int blocks)