aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2022-08-12 02:12:48 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2022-08-12 02:12:48 +0000
commit048bd1272b7256331117b0e7b1ab5d22cf308067 (patch)
tree3f86090e36f01551afc2aa8132ce3660d878d57a /lib
parent4ea97e60c544ad44ee7396c815064d87f0d25874 (diff)
downloadsg3_utils-048bd1272b7256331117b0e7b1ab5d22cf308067.tar.gz
sg_inq+sg_vpd: more JSON work (add SG_C_CPP_ZERO_INIT)
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@966 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.am1
-rw-r--r--lib/Makefile.in1
-rw-r--r--lib/sg_cmds_basic.c8
-rw-r--r--lib/sg_cmds_basic2.c22
-rw-r--r--lib/sg_cmds_extra.c62
-rw-r--r--lib/sg_lib.c6
-rw-r--r--lib/sg_lib_data.c2
-rw-r--r--lib/sg_pr2serr.c78
-rw-r--r--lib/sg_pt_freebsd.c8
-rw-r--r--lib/sg_pt_osf1.c2
10 files changed, 94 insertions, 96 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 77e56408..3f98edfb 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -94,6 +94,7 @@ AM_CFLAGS = -Wall -W $(DBG_CFLAGS)
# AM_CFLAGS = -Wall -W -pedantic -std=c++14
# AM_CFLAGS = -Wall -W -pedantic -std=c++1z
# AM_CFLAGS = -Wall -W -pedantic -std=c++20
+# AM_CFLAGS = -Wall -W -pedantic -std=c++23
lib_LTLIBRARIES = libsgutils2.la
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 406cc024..5f07c745 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -407,6 +407,7 @@ AM_CFLAGS = -Wall -W $(DBG_CFLAGS)
# AM_CFLAGS = -Wall -W -pedantic -std=c++14
# AM_CFLAGS = -Wall -W -pedantic -std=c++1z
# AM_CFLAGS = -Wall -W -pedantic -std=c++20
+# AM_CFLAGS = -Wall -W -pedantic -std=c++23
lib_LTLIBRARIES = libsgutils2.la
libsgutils2_la_LDFLAGS = -version-info 2:0:0 -no-undefined -release ${PACKAGE_VERSION}
libsgutils2_la_LIBADD = @GETOPT_O_FILES@
diff --git a/lib/sg_cmds_basic.c b/lib/sg_cmds_basic.c
index d9970c89..4dffe1ce 100644
--- a/lib/sg_cmds_basic.c
+++ b/lib/sg_cmds_basic.c
@@ -382,7 +382,7 @@ sg_ll_inquiry_com(struct sg_pt_base * ptvp, int sg_fd, bool cmddt, bool evpd,
bool local_cdb = true;
int res, ret, sense_cat, resid;
uint8_t inq_cdb[INQUIRY_CMDLEN] = {INQUIRY_CMD, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
uint8_t * up;
if (resp == NULL) {
@@ -630,7 +630,7 @@ sg_ll_test_unit_ready_com(struct sg_pt_base * ptvp, int sg_fd, int pack_id,
bool local_cdb = true;
int res, ret, sense_cat;
uint8_t tur_cdb[TUR_CMDLEN] = {TUR_CMD, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
if (verbose) {
char b[128];
@@ -741,7 +741,7 @@ sg_ll_request_sense_com(struct sg_pt_base * ptvp, int sg_fd, bool desc,
static const char * const rq_s = "request sense";
uint8_t rs_cdb[REQUEST_SENSE_CMDLEN] =
{REQUEST_SENSE_CMD, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
if (desc)
rs_cdb[1] |= 0x1;
@@ -840,7 +840,7 @@ sg_ll_report_luns_com(struct sg_pt_base * ptvp, int sg_fd, int select_report,
int ret, res, sense_cat;
uint8_t rl_cdb[REPORT_LUNS_CMDLEN] =
{REPORT_LUNS_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
rl_cdb[2] = select_report & 0xff;
sg_put_unaligned_be32((uint32_t)mx_resp_len, rl_cdb + 6);
diff --git a/lib/sg_cmds_basic2.c b/lib/sg_cmds_basic2.c
index 1239bfe5..cbc609a9 100644
--- a/lib/sg_cmds_basic2.c
+++ b/lib/sg_cmds_basic2.c
@@ -93,7 +93,7 @@ sg_ll_sync_cache_10(int sg_fd, bool sync_nv, bool immed, int group,
int res, ret, sense_cat;
uint8_t sc_cdb[SYNCHRONIZE_CACHE_CMDLEN] =
{SYNCHRONIZE_CACHE_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
if (sync_nv)
@@ -154,7 +154,7 @@ sg_ll_readcap_16(int sg_fd, bool pmi, uint64_t llba, void * resp,
uint8_t rc_cdb[SERVICE_ACTION_IN_16_CMDLEN] =
{SERVICE_ACTION_IN_16_CMD, READ_CAPACITY_16_SA,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
if (pmi) { /* lbs only valid when pmi set */
@@ -209,7 +209,7 @@ sg_ll_readcap_10(int sg_fd, bool pmi, unsigned int lba, void * resp,
int ret, res, sense_cat;
uint8_t rc_cdb[READ_CAPACITY_10_CMDLEN] =
{READ_CAPACITY_10_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
if (pmi) { /* lbs only valid when pmi set */
@@ -262,7 +262,7 @@ sg_ll_mode_sense6(int sg_fd, bool dbd, int pc, int pg_code, int sub_pg_code,
int res, ret, sense_cat, resid;
uint8_t modes_cdb[MODE_SENSE6_CMDLEN] =
{MODE_SENSE6_CMD, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
modes_cdb[1] = (uint8_t)(dbd ? 0x8 : 0);
@@ -361,7 +361,7 @@ sg_ll_mode_sense10_v2(int sg_fd, bool llbaa, bool dbd, int pc, int pg_code,
struct sg_pt_base * ptvp;
uint8_t modes_cdb[MODE_SENSE10_CMDLEN] =
{MODE_SENSE10_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
modes_cdb[1] = (uint8_t)((dbd ? 0x8 : 0) | (llbaa ? 0x10 : 0));
modes_cdb[2] = (uint8_t)(((pc << 6) & 0xc0) | (pg_code & 0x3f));
@@ -448,7 +448,7 @@ sg_ll_mode_select6_v2(int sg_fd, bool pf, bool rtd, bool sp, void * paramp,
int res, ret, sense_cat;
uint8_t modes_cdb[MODE_SELECT6_CMDLEN] =
{MODE_SELECT6_CMD, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
modes_cdb[1] = (uint8_t)((pf ? 0x10 : 0x0) | (sp ? 0x1 : 0x0));
@@ -519,7 +519,7 @@ sg_ll_mode_select10_v2(int sg_fd, bool pf, bool rtd, bool sp, void * paramp,
int res, ret, sense_cat;
uint8_t modes_cdb[MODE_SELECT10_CMDLEN] =
{MODE_SELECT10_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
modes_cdb[1] = (uint8_t)((pf ? 0x10 : 0x0) | (sp ? 0x1 : 0x0));
@@ -818,7 +818,7 @@ sg_ll_log_sense_v2(int sg_fd, bool ppc, bool sp, int pc, int pg_code,
int res, ret, sense_cat, resid;
uint8_t logs_cdb[LOG_SENSE_CMDLEN] =
{LOG_SENSE_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
if (mx_resp_len > 0xffff) {
@@ -902,7 +902,7 @@ sg_ll_log_select(int sg_fd, bool pcr, bool sp, int pc, int pg_code,
int res, ret, sense_cat;
uint8_t logs_cdb[LOG_SELECT_CMDLEN] =
{LOG_SELECT_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
if (param_len > 0xffff) {
@@ -973,7 +973,7 @@ sg_ll_start_stop_unit_com(struct sg_pt_base * ptvp, int sg_fd, bool immed,
bool local_cdb = true;
int res, ret, sense_cat;
uint8_t ssuBlk[START_STOP_CMDLEN] = {START_STOP_CMD, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
if (immed)
ssuBlk[1] = 0x1;
@@ -1073,7 +1073,7 @@ sg_ll_prevent_allow(int sg_fd, int prevent, bool noisy, int verbose)
int res, ret, sense_cat;
uint8_t p_cdb[PREVENT_ALLOW_CMDLEN] =
{PREVENT_ALLOW_CMD, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
if ((prevent < 0) || (prevent > 3)) {
diff --git a/lib/sg_cmds_extra.c b/lib/sg_cmds_extra.c
index cb42b32c..9cbb0295 100644
--- a/lib/sg_cmds_extra.c
+++ b/lib/sg_cmds_extra.c
@@ -125,7 +125,7 @@ sg_ll_get_lba_status16(int sg_fd, uint64_t start_llba, uint8_t rt,
static const char * const cdb_s = "Get LBA status(16)";
int res, s_cat, ret;
uint8_t getLbaStatCmd[SERVICE_ACTION_IN_16_CMDLEN];
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
memset(getLbaStatCmd, 0, sizeof(getLbaStatCmd));
@@ -202,7 +202,7 @@ sg_ll_get_lba_status32(int sg_fd, uint64_t start_llba, uint32_t scan_len,
static const char * const cdb_s = "Get LBA status(32)";
int res, s_cat, ret;
uint8_t gls32_cmd[GLS32_CMD_LEN];
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
memset(gls32_cmd, 0, sizeof(gls32_cmd));
@@ -281,7 +281,7 @@ sg_ll_report_tgt_prt_grp2(int sg_fd, void * resp, int mx_resp_len,
uint8_t rtpg_cdb[MAINTENANCE_IN_CMDLEN] =
{MAINTENANCE_IN_CMD, REPORT_TGT_PRT_GRP_SA,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
if (extended)
@@ -346,7 +346,7 @@ sg_ll_set_tgt_prt_grp(int sg_fd, void * paramp, int param_len, bool noisy,
uint8_t stpg_cdb[MAINTENANCE_OUT_CMDLEN] =
{MAINTENANCE_OUT_CMD, SET_TGT_PRT_GRP_SA,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
sg_put_unaligned_be32((uint32_t)param_len, stpg_cdb + 6);
@@ -402,7 +402,7 @@ sg_ll_report_referrals(int sg_fd, uint64_t start_llba, bool one_seg,
uint8_t repRef_cdb[SERVICE_ACTION_IN_16_CMDLEN] =
{SERVICE_ACTION_IN_16_CMD, REPORT_REFERRALS_SA,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
sg_put_unaligned_be64(start_llba, repRef_cdb + 2);
@@ -475,7 +475,7 @@ sg_ll_send_diag_com(struct sg_pt_base * ptvp, int sg_fd, int st_code,
int res, ret, s_cat, tmout;
uint8_t senddiag_cdb[SEND_DIAGNOSTIC_CMDLEN] =
{SEND_DIAGNOSTIC_CMD, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
senddiag_cdb[1] = (uint8_t)(st_code << 5);
if (pf_bit)
@@ -593,7 +593,7 @@ sg_ll_receive_diag_com(struct sg_pt_base * ptvp, int sg_fd, bool pcv,
static const char * const cdb_s = "Receive diagnostic results";
uint8_t rcvdiag_cdb[RECEIVE_DIAGNOSTICS_CMDLEN] =
{RECEIVE_DIAGNOSTICS_CMD, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
if (pcv)
rcvdiag_cdb[1] = 0x1;
@@ -715,7 +715,7 @@ sg_ll_read_defect10(int sg_fd, bool req_plist, bool req_glist, int dl_format,
int res, ret, s_cat;
uint8_t rdef_cdb[READ_DEFECT10_CMDLEN] =
{READ_DEFECT10_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
rdef_cdb[2] = (dl_format & 0x7);
@@ -787,7 +787,7 @@ sg_ll_read_media_serial_num(int sg_fd, void * resp, int mx_resp_len,
uint8_t rmsn_cdb[SERVICE_ACTION_IN_12_CMDLEN] =
{SERVICE_ACTION_IN_12_CMD, READ_MEDIA_SERIAL_NUM_SA,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
sg_put_unaligned_be32((uint32_t)mx_resp_len, rmsn_cdb + 6);
@@ -851,7 +851,7 @@ sg_ll_report_id_info(int sg_fd, int itype, void * resp, int max_resp_len,
uint8_t rii_cdb[MAINTENANCE_IN_CMDLEN] = {MAINTENANCE_IN_CMD,
REPORT_IDENTIFYING_INFORMATION_SA,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
sg_put_unaligned_be32((uint32_t)max_resp_len, rii_cdb + 6);
@@ -917,7 +917,7 @@ sg_ll_set_id_info(int sg_fd, int itype, void * paramp, int param_len,
uint8_t sii_cdb[MAINTENANCE_OUT_CMDLEN] = {MAINTENANCE_OUT_CMD,
SET_IDENTIFYING_INFORMATION_SA,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
sg_put_unaligned_be32((uint32_t)param_len, sii_cdb + 6);
@@ -1000,7 +1000,7 @@ sg_ll_format_unit_v2(int sg_fd, int fmtpinfo, bool longlist, bool fmtdata,
int res, ret, s_cat, tmout;
uint8_t fu_cdb[FORMAT_UNIT_CMDLEN] =
{FORMAT_UNIT_CMD, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
if (fmtpinfo)
@@ -1069,7 +1069,7 @@ sg_ll_reassign_blocks(int sg_fd, bool longlba, bool longlist, void * paramp,
int res, ret, s_cat;
uint8_t reass_cdb[REASSIGN_BLKS_CMDLEN] =
{REASSIGN_BLKS_CMD, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
if (longlba)
@@ -1128,7 +1128,7 @@ sg_ll_persistent_reserve_in(int sg_fd, int rq_servact, void * resp,
int res, ret, s_cat;
uint8_t prin_cdb[PERSISTENT_RESERVE_IN_CMDLEN] =
{PERSISTENT_RESERVE_IN_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
if (rq_servact > 0)
@@ -1195,7 +1195,7 @@ sg_ll_persistent_reserve_out(int sg_fd, int rq_servact, int rq_scope,
int res, ret, s_cat;
uint8_t prout_cdb[PERSISTENT_RESERVE_OUT_CMDLEN] =
{PERSISTENT_RESERVE_OUT_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
if (rq_servact > 0)
@@ -1274,7 +1274,7 @@ sg_ll_read_long10(int sg_fd, bool pblock, bool correct, unsigned int lba,
static const char * const cdb_s = "read long(10)";
int res, s_cat, ret;
uint8_t readLong_cdb[READ_LONG10_CMDLEN];
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
memset(readLong_cdb, 0, READ_LONG10_CMDLEN);
@@ -1366,7 +1366,7 @@ sg_ll_read_long16(int sg_fd, bool pblock, bool correct, uint64_t llba,
static const char * const cdb_s = "read long(16)";
int res, s_cat, ret;
uint8_t readLong_cdb[SERVICE_ACTION_IN_16_CMDLEN];
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
memset(readLong_cdb, 0, sizeof(readLong_cdb));
@@ -1459,7 +1459,7 @@ sg_ll_write_long10(int sg_fd, bool cor_dis, bool wr_uncor, bool pblock,
static const char * const cdb_s = "write long(10)";
int res, s_cat, ret;
uint8_t writeLong_cdb[WRITE_LONG10_CMDLEN];
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
memset(writeLong_cdb, 0, WRITE_LONG10_CMDLEN);
@@ -1541,7 +1541,7 @@ sg_ll_write_long16(int sg_fd, bool cor_dis, bool wr_uncor, bool pblock,
static const char * const cdb_s = "write long(16)";
int res, s_cat, ret;
uint8_t writeLong_cdb[SERVICE_ACTION_OUT_16_CMDLEN];
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
memset(writeLong_cdb, 0, sizeof(writeLong_cdb));
@@ -1628,7 +1628,7 @@ sg_ll_verify10(int sg_fd, int vrprotect, bool dpo, int bytchk,
int res, ret, s_cat, slen;
uint8_t v_cdb[VERIFY10_CMDLEN] =
{VERIFY10_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
/* N.B. BYTCHK field expanded to 2 bits sbc3r34 */
@@ -1709,7 +1709,7 @@ sg_ll_verify16(int sg_fd, int vrprotect, bool dpo, int bytchk, uint64_t llba,
int res, ret, s_cat, slen;
uint8_t v_cdb[VERIFY16_CMDLEN] =
{VERIFY16_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
/* N.B. BYTCHK field expanded to 2 bits sbc3r34 */
@@ -1808,7 +1808,7 @@ sg_ll_ata_pt(int sg_fd, const uint8_t * cdbp, int cdb_len,
int ret = -1;
uint8_t apt_cdb[ATA_PT_32_CMDLEN];
uint8_t incoming_apt_cdb[ATA_PT_32_CMDLEN];
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
uint8_t * sp;
const uint8_t * bp;
struct sg_pt_base * ptvp;
@@ -1965,7 +1965,7 @@ sg_ll_read_buffer(int sg_fd, int mode, int buffer_id, int buffer_offset,
int res, ret, s_cat;
uint8_t rbuf_cdb[READ_BUFFER_CMDLEN] =
{READ_BUFFER_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
rbuf_cdb[1] = (uint8_t)(mode & 0x1f);
@@ -2030,7 +2030,7 @@ sg_ll_write_buffer(int sg_fd, int mode, int buffer_id, int buffer_offset,
int res, ret, s_cat;
uint8_t wbuf_cdb[WRITE_BUFFER_CMDLEN] =
{WRITE_BUFFER_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
wbuf_cdb[1] = (uint8_t)(mode & 0x1f);
@@ -2101,7 +2101,7 @@ sg_ll_write_buffer_v2(int sg_fd, int mode, int m_specific, int buffer_id,
int res, ret, s_cat;
uint8_t wbuf_cdb[WRITE_BUFFER_CMDLEN] =
{WRITE_BUFFER_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
if (buffer_offset > 0xffffff) {
@@ -2185,7 +2185,7 @@ sg_ll_unmap_v2(int sg_fd, bool anchor, int group_num, int timeout_secs,
int res, ret, s_cat, tmout;
uint8_t u_cdb[UNMAP_CMDLEN] =
{UNMAP_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
if (anchor)
@@ -2243,7 +2243,7 @@ sg_ll_read_block_limits(int sg_fd, void * resp, int mx_resp_len,
int ret, res, s_cat;
uint8_t rl_cdb[READ_BLOCK_LIMITS_CMDLEN] =
{READ_BLOCK_LIMITS_CMD, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
if (vb) {
@@ -2304,7 +2304,7 @@ sg_ll_receive_copy_results(int sg_fd, int sa, int list_id, void * resp,
int res, ret, s_cat;
uint8_t rcvcopyres_cdb[THIRD_PARTY_COPY_IN_CMDLEN] =
{THIRD_PARTY_COPY_IN_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
char b[64];
@@ -2367,7 +2367,7 @@ sg_ll_extended_copy(int sg_fd, void * paramp, int param_len, bool noisy,
int res, ret, s_cat;
uint8_t xcopy_cdb[THIRD_PARTY_COPY_OUT_CMDLEN] =
{THIRD_PARTY_COPY_OUT_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
const char * cdb_s = "Extended copy (LID1)";
@@ -2427,7 +2427,7 @@ sg_ll_3party_copy_out(int sg_fd, int sa, unsigned int list_id, int group_num,
int res, ret, s_cat, tmout;
uint8_t xcopy_cdb[THIRD_PARTY_COPY_OUT_CMDLEN] =
{THIRD_PARTY_COPY_OUT_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
char cname[80];
@@ -2514,7 +2514,7 @@ sg_ll_pre_fetch_x(int sg_fd, bool do_seek10, bool cdb16, bool immed,
int res, s_cat, ret, cdb_len, tmout;
const char *cdb_s;
uint8_t preFetchCdb[PRE_FETCH16_CMDLEN]; /* all use longest cdb */
- uint8_t sense_b[SENSE_BUFF_LEN] = {0};
+ uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
memset(preFetchCdb, 0, sizeof(preFetchCdb));
diff --git a/lib/sg_lib.c b/lib/sg_lib.c
index b1c9792a..827a96b3 100644
--- a/lib/sg_lib.c
+++ b/lib/sg_lib.c
@@ -3887,12 +3887,12 @@ void
sg_warn_and_wait(const char * cmd_name, const char * dev_name,
bool stress_all)
{
- int k;
+ int k, j;
const char * stressp = stress_all ? "ALL d" : "D";
const char * will_mayp = stress_all ? "will" : "may";
- for (k = 0; k < 3; ++k) {
- printf("\nA %s command will commence in 15 seconds\n", cmd_name);
+ for (k = 0, j = 15; k < 3; ++k, j -= 5) {
+ printf("\nA %s command will commence in %d seconds\n", cmd_name, j);
printf(" %sata on %s %s be DESTROYED%s\n", stressp, dev_name,
will_mayp, (stress_all ? "" : " or modified"));
printf(" Press control-C to abort\n");
diff --git a/lib/sg_lib_data.c b/lib/sg_lib_data.c
index 4906bb60..92884b38 100644
--- a/lib/sg_lib_data.c
+++ b/lib/sg_lib_data.c
@@ -19,7 +19,7 @@
#include "sg_lib_data.h"
-const char * sg_lib_version_str = "2.91 20220730";
+const char * sg_lib_version_str = "2.92 20220809";
/* spc6r06, sbc5r03, zbc2r13 */
diff --git a/lib/sg_pr2serr.c b/lib/sg_pr2serr.c
index 88e71b02..52a4d000 100644
--- a/lib/sg_pr2serr.c
+++ b/lib/sg_pr2serr.c
@@ -464,7 +464,7 @@ sgj_snake_named_subobject_r(sgj_state * jsp, sgj_opaque_p jop,
{
if (jsp && jsp->pr_as_json && conv2sname) {
int olen = strlen(conv2sname);
- char * sname = malloc(olen + 8);
+ char * sname = (char *)malloc(olen + 8);
int nlen = sgj_name_to_snake(conv2sname, sname, olen + 8);
if (nlen > 0)
@@ -492,7 +492,7 @@ sgj_snake_named_subarray_r(sgj_state * jsp, sgj_opaque_p jop,
{
if (jsp && jsp->pr_as_json && conv2sname) {
int olen = strlen(conv2sname);
- char * sname = malloc(olen + 8);
+ char * sname = (char *)malloc(olen + 8);
int nlen = sgj_name_to_snake(conv2sname, sname, olen + 8);
if (nlen > 0)
@@ -866,9 +866,9 @@ sgj_jtype_to_s(char * b, int blen_max, json_value * jvp)
}
static int
-sgj_hr_js_helper(char * b, int blen_max, const char * name,
- enum sgj_separator_t sep, bool use_jvp,
- json_value * jvp, int64_t val_instead)
+sgj_haj_helper(char * b, int blen_max, const char * name,
+ enum sgj_separator_t sep, bool use_jvp,
+ json_value * jvp, int64_t val_instead)
{
int n = 0;
@@ -913,10 +913,9 @@ sgj_hr_js_helper(char * b, int blen_max, const char * name,
}
static void
-sgj_hr_js_xx(sgj_state * jsp, sgj_opaque_p jop, int leadin_sp,
- const char * name, enum sgj_separator_t sep,
- json_value * jvp, bool hex_as_well, const char * val_s,
- const char * nex_s)
+sgj_haj_xx(sgj_state * jsp, sgj_opaque_p jop, int leadin_sp,
+ const char * name, enum sgj_separator_t sep, json_value * jvp,
+ bool hex_as_well, const char * val_s, const char * nex_s)
{
bool eaten = false;
bool as_json = (jsp && jsp->pr_as_json);
@@ -1002,7 +1001,7 @@ sgj_hr_js_xx(sgj_state * jsp, sgj_opaque_p jop, int leadin_sp,
}
}
if (jvp && ((as_json && jsp->pr_out_hr) || (! as_json)))
- n += sgj_hr_js_helper(b + n, blen - n, name, sep, true, jvp, 0);
+ n += sgj_haj_helper(b + n, blen - n, name, sep, true, jvp, 0);
if (as_json && jsp->pr_out_hr)
json_array_push((json_value *)jsp->out_hrp, json_string_new(b));
@@ -1014,80 +1013,77 @@ fini:
}
void
-sgj_hr_js_vs(sgj_state * jsp, sgj_opaque_p jop, int leadin_sp,
- const char * name, enum sgj_separator_t sep,
- const char * value)
+sgj_haj_vs(sgj_state * jsp, sgj_opaque_p jop, int leadin_sp,
+ const char * name, enum sgj_separator_t sep, const char * value)
{
json_value * jvp;
/* make json_value even if jsp->pr_as_json is false */
jvp = value ? json_string_new(value) : NULL;
- sgj_hr_js_xx(jsp, jop, leadin_sp, name, sep, jvp, false, NULL, NULL);
+ sgj_haj_xx(jsp, jop, leadin_sp, name, sep, jvp, false, NULL, NULL);
}
void
-sgj_hr_js_vi(sgj_state * jsp, sgj_opaque_p jop, int leadin_sp,
- const char * name, enum sgj_separator_t sep, int64_t value,
- bool hex_as_well)
+sgj_haj_vi(sgj_state * jsp, sgj_opaque_p jop, int leadin_sp,
+ const char * name, enum sgj_separator_t sep, int64_t value,
+ bool hex_as_well)
{
json_value * jvp;
jvp = json_integer_new(value);
- sgj_hr_js_xx(jsp, jop, leadin_sp, name, sep, jvp, hex_as_well, NULL,
- NULL);
+ sgj_haj_xx(jsp, jop, leadin_sp, name, sep, jvp, hex_as_well, NULL, NULL);
}
void
-sgj_hr_js_vistr(sgj_state * jsp, sgj_opaque_p jop, int leadin_sp,
- const char * name, enum sgj_separator_t sep, int64_t value,
- bool hex_as_well, const char * val_s)
+sgj_haj_vistr(sgj_state * jsp, sgj_opaque_p jop, int leadin_sp,
+ const char * name, enum sgj_separator_t sep, int64_t value,
+ bool hex_as_well, const char * val_s)
{
json_value * jvp;
jvp = json_integer_new(value);
- sgj_hr_js_xx(jsp, jop, leadin_sp, name, sep, jvp, hex_as_well, val_s,
+ sgj_haj_xx(jsp, jop, leadin_sp, name, sep, jvp, hex_as_well, val_s,
NULL);
}
void
-sgj_hr_js_vi_nex(sgj_state * jsp, sgj_opaque_p jop, int leadin_sp,
- const char * name, enum sgj_separator_t sep,
- int64_t value, bool hex_as_well, const char * nex_s)
+sgj_haj_vi_nex(sgj_state * jsp, sgj_opaque_p jop, int leadin_sp,
+ const char * name, enum sgj_separator_t sep,
+ int64_t value, bool hex_as_well, const char * nex_s)
{
json_value * jvp;
jvp = json_integer_new(value);
- sgj_hr_js_xx(jsp, jop, leadin_sp, name, sep, jvp, hex_as_well, NULL,
- nex_s);
+ sgj_haj_xx(jsp, jop, leadin_sp, name, sep, jvp, hex_as_well, NULL, nex_s);
}
void
-sgj_hr_js_vistr_nex(sgj_state * jsp, sgj_opaque_p jop, int leadin_sp,
- const char * name, enum sgj_separator_t sep,
- int64_t value, bool hex_as_well,
- const char * val_s, const char * nex_s)
+sgj_haj_vistr_nex(sgj_state * jsp, sgj_opaque_p jop, int leadin_sp,
+ const char * name, enum sgj_separator_t sep,
+ int64_t value, bool hex_as_well,
+ const char * val_s, const char * nex_s)
{
json_value * jvp;
jvp = json_integer_new(value);
- sgj_hr_js_xx(jsp, jop, leadin_sp, name, sep, jvp, hex_as_well, val_s,
- nex_s);
+ sgj_haj_xx(jsp, jop, leadin_sp, name, sep, jvp, hex_as_well, val_s,
+ nex_s);
}
void
-sgj_hr_js_vb(sgj_state * jsp, sgj_opaque_p jop, int leadin_sp,
- const char * name, enum sgj_separator_t sep, bool value)
+sgj_haj_vb(sgj_state * jsp, sgj_opaque_p jop, int leadin_sp,
+ const char * name, enum sgj_separator_t sep, bool value)
{
json_value * jvp;
jvp = json_boolean_new(value);
- sgj_hr_js_xx(jsp, jop, leadin_sp, name, sep, jvp, false, NULL, NULL);
+ sgj_haj_xx(jsp, jop, leadin_sp, name, sep, jvp, false, NULL, NULL);
}
sgj_opaque_p
-sgj_hr_js_subo_r(sgj_state * jsp, sgj_opaque_p jop, int leadin_sp,
- const char * name, enum sgj_separator_t sep, int64_t value,
- bool hex_as_well)
+sgj_haj_subo_r(sgj_state * jsp, sgj_opaque_p jop, int leadin_sp,
+ const char * name, enum sgj_separator_t sep, int64_t value,
+ bool hex_as_well)
{
bool as_json = (jsp && jsp->pr_as_json);
int n = 0;
@@ -1101,7 +1097,7 @@ sgj_hr_js_subo_r(sgj_state * jsp, sgj_opaque_p jop, int leadin_sp,
b[n] = ' ';
b[n] = '\0';
if ((! as_json) || (jsp && jsp->pr_out_hr))
- n += sgj_hr_js_helper(b + n, blen - n, name, sep, false, NULL, value);
+ n += sgj_haj_helper(b + n, blen - n, name, sep, false, NULL, value);
if (as_json && jsp->pr_out_hr)
json_array_push((json_value *)jsp->out_hrp, json_string_new(b));
diff --git a/lib/sg_pt_freebsd.c b/lib/sg_pt_freebsd.c
index c18fe6a7..e0cd9575 100644
--- a/lib/sg_pt_freebsd.c
+++ b/lib/sg_pt_freebsd.c
@@ -7,7 +7,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-/* sg_pt_freebsd version 1.47 20220127 */
+/* sg_pt_freebsd version 1.48 20220811 */
#include <stdio.h>
#include <stdlib.h>
@@ -238,7 +238,7 @@ int
scsi_pt_open_flags(const char * device_name, int oflags, int vb)
{
bool maybe_non_cam_nvme = false;
- bool basnam0_n;
+ bool basnam0_n = false;
char first_ch;
int k, err, dev_fd, ret, handle_idx;
ssize_t s;
@@ -378,8 +378,8 @@ scsi_pt_open_flags(const char * device_name, int oflags, int vb)
if (stat(dev_nm, &a_stat) < 0) {
err = errno;
if (vb)
- pr2ws("%s: unable to stat(%s): %s\n", __func__, dev_nm,
- strerror(err));
+ pr2ws("%s: unable to stat(%s): %s; basnam0_n=%d\n",
+ __func__, dev_nm, strerror(err), basnam0_n);
ret = -err;
goto err_out;
}
diff --git a/lib/sg_pt_osf1.c b/lib/sg_pt_osf1.c
index 8fa5e3e3..38e32cfc 100644
--- a/lib/sg_pt_osf1.c
+++ b/lib/sg_pt_osf1.c
@@ -46,7 +46,7 @@ struct osf1_dev_channel {
// Private table of open devices: guaranteed zero on startup since
// part of static data.
-static struct osf1_dev_channel *devicetable[OSF1_MAXDEV] = {0};
+static struct osf1_dev_channel *devicetable[OSF1_MAXDEV] SG_C_CPP_ZERO_INIT;
static char *cam_dev = "/dev/cam";
static int camfd;
static int camopened = 0;