aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2021-06-11 03:57:05 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2021-06-11 03:57:05 +0000
commitbee57c535c29a01cadfaa660d8c0182288960c33 (patch)
tree2a9355f53953526dc12f101d6bf6b26962f5dbbe /src
parent30363466e3580cae5f428c9bf35caa934cef469b (diff)
downloadsg3_utils-bee57c535c29a01cadfaa660d8c0182288960c33.tar.gz
sg_read_buffer: fix --length= problem; pt: new configure option --enable-pt_dummy builds the library with sg_pt_dummy.c instead of OS specific code
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@904 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/Makefile.in32
-rw-r--r--src/sg_decode_sense.c7
-rw-r--r--src/sg_inq.c4
-rw-r--r--src/sg_logs.c10
-rw-r--r--src/sg_luns.c6
-rw-r--r--src/sg_modes.c6
-rw-r--r--src/sg_opcodes.c4
-rw-r--r--src/sg_persist.c8
-rw-r--r--src/sg_read_attr.c8
-rw-r--r--src/sg_read_buffer.c11
-rw-r--r--src/sg_requests.c14
-rw-r--r--src/sg_senddiag.c6
-rw-r--r--src/sg_ses.c16
-rw-r--r--src/sg_ses_microcode.c6
-rw-r--r--src/sg_stpg.c12
-rw-r--r--src/sg_vpd.c14
-rw-r--r--src/sg_wr_mode.c6
-rw-r--r--src/sg_write_buffer.c6
-rw-r--r--src/sg_write_x.c10
20 files changed, 99 insertions, 89 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 47293fe5..1b0a44a2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -15,11 +15,13 @@ sg_scan_SOURCES =
if OS_LINUX
+if !PT_DUMMY
bin_PROGRAMS += \
sg_copy_results sg_dd sg_emc_trespass sg_map sg_map26 sg_rbuf \
sg_read sg_reset sg_scan sg_test_rwbuf sg_xcopy sginfo sgm_dd sgp_dd
sg_scan_SOURCES += sg_scan_linux.c
endif
+endif
if OS_WIN32_MINGW
diff --git a/src/Makefile.in b/src/Makefile.in
index cd146ae6..f0fffb05 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -111,11 +111,11 @@ bin_PROGRAMS = sg_bg_ctl$(EXEEXT) sg_compare_and_write$(EXEEXT) \
sg_write_long$(EXEEXT) sg_write_same$(EXEEXT) \
sg_write_verify$(EXEEXT) sg_write_x$(EXEEXT) sg_zone$(EXEEXT) \
$(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3)
-@OS_LINUX_TRUE@am__append_1 = \
-@OS_LINUX_TRUE@ sg_copy_results sg_dd sg_emc_trespass sg_map sg_map26 sg_rbuf \
-@OS_LINUX_TRUE@ sg_read sg_reset sg_scan sg_test_rwbuf sg_xcopy sginfo sgm_dd sgp_dd
+@OS_LINUX_TRUE@@PT_DUMMY_FALSE@am__append_1 = \
+@OS_LINUX_TRUE@@PT_DUMMY_FALSE@ sg_copy_results sg_dd sg_emc_trespass sg_map sg_map26 sg_rbuf \
+@OS_LINUX_TRUE@@PT_DUMMY_FALSE@ sg_read sg_reset sg_scan sg_test_rwbuf sg_xcopy sginfo sgm_dd sgp_dd
-@OS_LINUX_TRUE@am__append_2 = sg_scan_linux.c
+@OS_LINUX_TRUE@@PT_DUMMY_FALSE@am__append_2 = sg_scan_linux.c
@OS_WIN32_MINGW_TRUE@am__append_3 = sg_scan
@OS_WIN32_MINGW_TRUE@am__append_4 = sg_scan_win32.c
@OS_WIN32_CYGWIN_TRUE@am__append_5 = sg_scan
@@ -130,13 +130,20 @@ mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
-@OS_LINUX_TRUE@am__EXEEXT_1 = sg_copy_results$(EXEEXT) sg_dd$(EXEEXT) \
-@OS_LINUX_TRUE@ sg_emc_trespass$(EXEEXT) sg_map$(EXEEXT) \
-@OS_LINUX_TRUE@ sg_map26$(EXEEXT) sg_rbuf$(EXEEXT) \
-@OS_LINUX_TRUE@ sg_read$(EXEEXT) sg_reset$(EXEEXT) \
-@OS_LINUX_TRUE@ sg_scan$(EXEEXT) sg_test_rwbuf$(EXEEXT) \
-@OS_LINUX_TRUE@ sg_xcopy$(EXEEXT) sginfo$(EXEEXT) \
-@OS_LINUX_TRUE@ sgm_dd$(EXEEXT) sgp_dd$(EXEEXT)
+@OS_LINUX_TRUE@@PT_DUMMY_FALSE@am__EXEEXT_1 = \
+@OS_LINUX_TRUE@@PT_DUMMY_FALSE@ sg_copy_results$(EXEEXT) \
+@OS_LINUX_TRUE@@PT_DUMMY_FALSE@ sg_dd$(EXEEXT) \
+@OS_LINUX_TRUE@@PT_DUMMY_FALSE@ sg_emc_trespass$(EXEEXT) \
+@OS_LINUX_TRUE@@PT_DUMMY_FALSE@ sg_map$(EXEEXT) \
+@OS_LINUX_TRUE@@PT_DUMMY_FALSE@ sg_map26$(EXEEXT) \
+@OS_LINUX_TRUE@@PT_DUMMY_FALSE@ sg_rbuf$(EXEEXT) \
+@OS_LINUX_TRUE@@PT_DUMMY_FALSE@ sg_read$(EXEEXT) \
+@OS_LINUX_TRUE@@PT_DUMMY_FALSE@ sg_reset$(EXEEXT) \
+@OS_LINUX_TRUE@@PT_DUMMY_FALSE@ sg_scan$(EXEEXT) \
+@OS_LINUX_TRUE@@PT_DUMMY_FALSE@ sg_test_rwbuf$(EXEEXT) \
+@OS_LINUX_TRUE@@PT_DUMMY_FALSE@ sg_xcopy$(EXEEXT) \
+@OS_LINUX_TRUE@@PT_DUMMY_FALSE@ sginfo$(EXEEXT) sgm_dd$(EXEEXT) \
+@OS_LINUX_TRUE@@PT_DUMMY_FALSE@ sgp_dd$(EXEEXT)
@OS_WIN32_MINGW_TRUE@am__EXEEXT_2 = sg_scan$(EXEEXT)
@OS_WIN32_CYGWIN_TRUE@am__EXEEXT_3 = sg_scan$(EXEEXT)
am__installdirs = "$(DESTDIR)$(bindir)"
@@ -278,7 +285,8 @@ sg_sat_set_features_SOURCES = sg_sat_set_features.c
sg_sat_set_features_OBJECTS = sg_sat_set_features.$(OBJEXT)
sg_sat_set_features_DEPENDENCIES = ../lib/libsgutils2.la
am__sg_scan_SOURCES_DIST = sg_scan_linux.c sg_scan_win32.c
-@OS_LINUX_TRUE@am__objects_1 = sg_scan_linux.$(OBJEXT)
+@OS_LINUX_TRUE@@PT_DUMMY_FALSE@am__objects_1 = \
+@OS_LINUX_TRUE@@PT_DUMMY_FALSE@ sg_scan_linux.$(OBJEXT)
@OS_WIN32_MINGW_TRUE@am__objects_2 = sg_scan_win32.$(OBJEXT)
@OS_WIN32_CYGWIN_TRUE@am__objects_3 = sg_scan_win32.$(OBJEXT)
am_sg_scan_OBJECTS = $(am__objects_1) $(am__objects_2) \
diff --git a/src/sg_decode_sense.c b/src/sg_decode_sense.c
index a71de325..18b4ef6e 100644
--- a/src/sg_decode_sense.c
+++ b/src/sg_decode_sense.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2019 Douglas Gilbert.
+ * Copyright (c) 2010-2021 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.
@@ -30,7 +30,7 @@
#include "sg_unaligned.h"
-static const char * version_str = "1.21 20190602";
+static const char * version_str = "1.22 20210610";
#define MAX_SENSE_LEN 1024 /* max descriptor format actually: 255+8 */
@@ -347,7 +347,8 @@ main(int argc, char *argv[])
if (op->verbose > 2)
pr2serr("no_space str: %s\n", op->no_space_str);
cp = op->no_space_str;
- for (k = 0; isxdigit(cp[k]) && isxdigit(cp[k + 1]); k += 2) {
+ for (k = 0; isxdigit((uint8_t)cp[k]) &&
+ isxdigit((uint8_t)cp[k + 1]); k += 2) {
if (1 != sscanf(cp + k, "%2x", &ui)) {
pr2serr("bad no_space hex string: %s\n", cp);
return SG_LIB_SYNTAX_ERROR;
diff --git a/src/sg_inq.c b/src/sg_inq.c
index 6bbeb991..17c0730c 100644
--- a/src/sg_inq.c
+++ b/src/sg_inq.c
@@ -51,7 +51,7 @@
#include "sg_pt_nvme.h"
#endif
-static const char * version_str = "2.11 20210430"; /* spc6r05 */
+static const char * version_str = "2.12 20210610"; /* spc6r05 */
/* INQUIRY notes:
* It is recommended that the initial allocation length given to a
@@ -4130,7 +4130,7 @@ main(int argc, char * argv[])
"implies a page\n");
return SG_LIB_CONTRADICT;
}
- if (isalpha(op->page_arg[0])) {
+ if (isalpha((uint8_t)op->page_arg[0])) {
vnp = sdp_find_vpd_by_acron(op->page_arg);
if (NULL == vnp) {
#ifdef SG_SCSI_STRINGS
diff --git a/src/sg_logs.c b/src/sg_logs.c
index 409d0614..91a46181 100644
--- a/src/sg_logs.c
+++ b/src/sg_logs.c
@@ -36,7 +36,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "1.82 20210503"; /* spc6r01 + sbc4r17 */
+static const char * version_str = "1.83 20210610"; /* spc6r05 + sbc5r01 */
#define MX_ALLOC_LEN (0xfffc)
#define SHORT_RESP_LEN 128
@@ -800,7 +800,7 @@ find_vpn_by_acron(const char * vp_ap)
for (vpp = vp_arr; vpp->acron; ++vpp) {
len = strlen(vpp->acron);
for (k = 0; k < len; ++k) {
- if (tolower(vp_ap[k]) != vpp->acron[k])
+ if (tolower((uint8_t)vp_ap[k]) != (uint8_t)vpp->acron[k])
break;
}
if (k < len)
@@ -1216,7 +1216,7 @@ old_parse_cmd_line(struct opts_t * op, int argc, char * argv[])
const struct log_elem * lep;
char b[80];
- if (isalpha(ccp[0])) {
+ if (isalpha((uint8_t)ccp[0])) {
if (strlen(ccp) >= (sizeof(b) - 1)) {
pr2serr("argument to '-p=' is too long\n");
return SG_LIB_SYNTAX_ERROR;
@@ -6773,7 +6773,7 @@ decode_pg_arg(struct opts_t * op)
char * cp;
char b[80];
- if (isalpha(op->pg_arg[0])) {
+ if (isalpha((uint8_t)op->pg_arg[0])) {
if (strlen(op->pg_arg) >= (sizeof(b) - 1)) {
pr2serr("argument to '--page=' is too long\n");
return SG_LIB_SYNTAX_ERROR;
@@ -6876,7 +6876,7 @@ main(int argc, char * argv[])
}
vb = op->verbose;
if (op->vend_prod) {
- if (isdigit(op->vend_prod[0]))
+ if (isdigit((uint8_t)op->vend_prod[0]))
k = sg_get_num_nomult(op->vend_prod);
else
k = find_vpn_by_acron(op->vend_prod);
diff --git a/src/sg_luns.c b/src/sg_luns.c
index 62a2e6ca..c538956c 100644
--- a/src/sg_luns.c
+++ b/src/sg_luns.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2020 Douglas Gilbert.
+ * Copyright (c) 2004-2021 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.
@@ -34,7 +34,7 @@
* and decodes the response.
*/
-static const char * version_str = "1.45 20200708"; /* spc6r02 */
+static const char * version_str = "1.46 20210610"; /* spc6r05 */
#define MAX_RLUNS_BUFF_LEN (1024 * 1024)
#define DEF_RLUNS_BUFF_LEN (1024 * 8)
@@ -503,7 +503,7 @@ main(int argc, char * argv[])
if ('L' == toupper(cp[0])) {
uint64_t ull;
- if (('0' == cp[1]) && ('X' == toupper(cp[2])))
+ if (('0' == cp[1]) && ('X' == toupper((uint8_t)cp[2])))
k = sscanf(cp + 3, " %" SCNx64, &ull);
else
k = sscanf(cp + 1, " %" SCNu64, &ull);
diff --git a/src/sg_modes.c b/src/sg_modes.c
index 3e6c9b85..16ea142c 100644
--- a/src/sg_modes.c
+++ b/src/sg_modes.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2000-2020 D. Gilbert
+ * Copyright (C) 2000-2021 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)
@@ -32,7 +32,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "1.72 20200930";
+static const char * version_str = "1.73 20210610";
#define DEF_ALLOC_LEN (1024 * 4)
#define DEF_6_ALLOC_LEN 252
@@ -507,7 +507,7 @@ new_parse_cmd_line(struct opts_t * op, int argc, char * argv[])
op->opt_new = false;
return 0;
case 'p':
- if (isalpha(optarg[0])) {
+ if (isalpha((uint8_t)optarg[0])) {
const struct page_code_desc * pcdp;
op->page_acron = optarg;
diff --git a/src/sg_opcodes.c b/src/sg_opcodes.c
index 57b92968..4abe9f17 100644
--- a/src/sg_opcodes.c
+++ b/src/sg_opcodes.c
@@ -33,7 +33,7 @@
#include "sg_pt.h"
-static const char * version_str = "0.69 20210319"; /* spc6r05 */
+static const char * version_str = "0.70 20210610"; /* spc6r05 */
#define SENSE_BUFF_LEN 64 /* Arbitrary, could be larger */
@@ -382,7 +382,7 @@ new_parse_cmd_line(struct opts_t * op, int argc, char * argv[])
return 0;
case 'p':
n = -2;
- if (isdigit(optarg[0]))
+ if (isdigit((uint8_t)optarg[0]))
n = sg_get_num(optarg);
else if ((2 == strlen(optarg)) && (0 == strcmp("-1", optarg)))
n = -1;
diff --git a/src/sg_persist.c b/src/sg_persist.c
index 59067f2a..e779fe41 100644
--- a/src/sg_persist.c
+++ b/src/sg_persist.c
@@ -1,5 +1,5 @@
/* A utility program originally written for the Linux OS SCSI subsystem.
- * Copyright (C) 2004-2019 D. Gilbert
+ * Copyright (C) 2004-2021 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)
@@ -35,7 +35,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "0.67 20190913";
+static const char * version_str = "0.68 20210610";
#define PRIN_RKEY_SA 0x0
@@ -779,7 +779,7 @@ decode_file_tids(const char * fnp, struct opts_t * op)
continue;
}
if (carry_over[0]) {
- if (isxdigit(line[0])) {
+ if (isxdigit((uint8_t)line[0])) {
carry_over[1] = line[0];
carry_over[2] = '\0';
if (1 == sscanf(carry_over, "%x", &h))
@@ -826,7 +826,7 @@ decode_file_tids(const char * fnp, struct opts_t * op)
pr2serr("%s: array length exceeded\n", __func__);
goto bad;
}
- op->transportid_arr[off + k] = h; /* keep code checker happy */
+ op->transportid_arr[off + k] = h;/* keep code checker happy */
lcp = strpbrk(lcp, " ,\t");
if (NULL == lcp)
break;
diff --git a/src/sg_read_attr.c b/src/sg_read_attr.c
index bf27da1e..3f5d6528 100644
--- a/src/sg_read_attr.c
+++ b/src/sg_read_attr.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016-2019 Douglas Gilbert.
+ * Copyright (c) 2016-2021 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.
@@ -39,7 +39,7 @@
* and decodes the response. Based on spc5r08.pdf
*/
-static const char * version_str = "1.13 20191220";
+static const char * version_str = "1.14 20210610";
#define MAX_RATTR_BUFF_LEN (1024 * 1024)
#define DEF_RATTR_BUFF_LEN (1024 * 8)
@@ -323,7 +323,7 @@ find_sa_acron(const char * cp)
for (mp = cp, k = 0; *mp; ++mp, ++k) {
if (0 == anvp->acron[k])
return anvp->val;
- if (tolower(*mp) != anvp->acron[k])
+ if (tolower((uint8_t)*mp) != (uint8_t)anvp->acron[k])
break;
}
if ((0 == *mp) && (0 == anvp->acron[k]))
@@ -827,7 +827,7 @@ main(int argc, char * argv[])
op->o_readonly = true;
break;
case 's':
- if (isdigit(*optarg)) {
+ if (isdigit((uint8_t)*optarg)) {
op->sa = sg_get_num(optarg);
if ((op->sa < 0) || (op->sa > 63)) {
pr2serr("bad argument to '--sa=SA', expect 0 to 63\n");
diff --git a/src/sg_read_buffer.c b/src/sg_read_buffer.c
index 4eb5da4a..33aa1673 100644
--- a/src/sg_read_buffer.c
+++ b/src/sg_read_buffer.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2019 Luben Tuikov and Douglas Gilbert.
+ * Copyright (c) 2006-2021 Luben Tuikov and 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.
@@ -39,7 +39,7 @@
* device.
*/
-static const char * version_str = "1.30 20191220"; /* spc5r22 */
+static const char * version_str = "1.31 20210608"; /* spc6r05 */
#ifndef SG_READ_BUFFER_10_CMD
@@ -410,7 +410,8 @@ main(int argc, char * argv[])
bool do_raw = false;
bool verbose_given = false;
bool version_given = false;
- int res, c, len, k, inhex_len;
+ int res, c, len, k;
+ int inhex_len = 0;
int sg_fd = -1;
int do_help = 0;
int do_hex = 0;
@@ -476,7 +477,7 @@ main(int argc, char * argv[])
do_long = true;
break;
case 'm':
- if (isdigit(*optarg)) {
+ if (isdigit((uint8_t)*optarg)) {
rb_mode = sg_get_num(optarg);
if ((rb_mode < 0) || (rb_mode > 31)) {
pr2serr("argument to '--mode' should be in the range 0 "
@@ -574,8 +575,6 @@ main(int argc, char * argv[])
return 0;
}
- rb_len = 0;
- inhex_len = 0;
if (device_name && fname) {
pr2serr("Confused: both DEVICE (%s) and --inhex= option given. One "
"only please\n", device_name);
diff --git a/src/sg_requests.c b/src/sg_requests.c
index fbb56cab..f27c60d6 100644
--- a/src/sg_requests.c
+++ b/src/sg_requests.c
@@ -34,7 +34,7 @@
* This program issues the SCSI command REQUEST SENSE to the given SCSI device.
*/
-static const char * version_str = "1.36 20210329";
+static const char * version_str = "1.36 20210610";
#define MAX_REQS_RESP_LEN 255
#define DEF_REQS_RESP_LEN 252
@@ -320,11 +320,11 @@ main(int argc, char * argv[])
n = 0;
} else {
if (verbose && (0 == k)) {
- char b[128];
+ char bb[128];
pr2serr(" cdb: %s\n",
sg_get_command_str(rs_cdb, REQUEST_SENSE_CMDLEN,
- true, sizeof(b), b));
+ true, sizeof(bb), bb));
}
rs = do_scsi_pt(ptvp, -1, DEF_PT_TIMEOUT, verbose);
n = sg_cmds_process_resp(ptvp, "Request sense", rs, (0 == k),
@@ -413,11 +413,11 @@ main(int argc, char * argv[])
n = 0;
} else {
if (verbose && (0 == k)) {
- char b[128];
+ char bb[128];
pr2serr(" cdb: %s\n",
sg_get_command_str(rs_cdb, REQUEST_SENSE_CMDLEN,
- true, sizeof(b), b));
+ true, sizeof(bb), bb));
}
rs = do_scsi_pt(ptvp, -1, DEF_PT_TIMEOUT, verbose);
n = sg_cmds_process_resp(ptvp, "Request sense", rs, (0 == k),
@@ -468,10 +468,10 @@ main(int argc, char * argv[])
most_recent_skey = ssh.sense_key;
}
if (not_raw_hex && ((1 == num_rs) || verbose)) {
- char b[144];
+ char bb[144];
sg_get_sense_str(NULL, rsBuff, act_din_len,
- false, sizeof(b), b);
+ false, sizeof(bb), bb);
pr2serr("data-in decoded as sense:\n%s\n", b);
}
}
diff --git a/src/sg_senddiag.c b/src/sg_senddiag.c
index 38d4e40d..6539d79d 100644
--- a/src/sg_senddiag.c
+++ b/src/sg_senddiag.c
@@ -1,6 +1,6 @@
/*
* A utility program originally written for the Linux OS SCSI subsystem
- * Copyright (C) 2003-2018 D. Gilbert
+ * Copyright (C) 2003-2021 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)
@@ -34,7 +34,7 @@
#include "sg_pr2serr.h"
-static const char * version_str = "0.63 20180628";
+static const char * version_str = "0.64 20210610";
#define ME "sg_senddiag: "
@@ -511,7 +511,7 @@ build_diag_page(const char * inp, uint8_t * mp_arr, int * mp_arr_len,
continue;
}
if (carry_over[0]) {
- if (isxdigit(line[0])) {
+ if (isxdigit((uint8_t)line[0])) {
carry_over[1] = line[0];
carry_over[2] = '\0';
if (1 == sscanf(carry_over, "%x", &h))
diff --git a/src/sg_ses.c b/src/sg_ses.c
index 7280130d..b9ac2e43 100644
--- a/src/sg_ses.c
+++ b/src/sg_ses.c
@@ -38,7 +38,7 @@
* commands tailored for SES (enclosure) devices.
*/
-static const char * version_str = "2.49 20210503"; /* ses4r04 */
+static const char * version_str = "2.50 20210610"; /* ses4r04 */
#define MX_ALLOC_LEN ((64 * 1024) - 4) /* max allowable for big enclosures */
#define MX_ELEM_HDR 1024
@@ -1046,7 +1046,7 @@ parse_index(struct opts_t *op)
}
op->ind_th = 0;
op->ind_indiv = -1;
- } else if (isdigit(b[0])) {
+ } else if (isdigit((uint8_t)b[0])) {
n = sg_get_num_nomult(b);
if ((n < 0) || (n > 255)) {
pr2serr("bad numeric argument to '--index', expect number from 0 "
@@ -1157,7 +1157,7 @@ parse_cmd_line(struct opts_t *op, int argc, char *argv[])
break;
case 'A': /* SAS address, assumed to be hex */
cp = optarg;
- if ((strlen(optarg) > 2) && ('X' == toupper(optarg[1])))
+ if ((strlen(optarg) > 2) && ('X' == toupper((uint8_t)optarg[1])))
cp = optarg + 2;
if (1 != sscanf(cp, "%" SCNx64 "", &saddr)) {
pr2serr("bad argument to '--sas-addr=SA'\n");
@@ -1289,7 +1289,7 @@ parse_cmd_line(struct opts_t *op, int argc, char *argv[])
op->mask_ign = true;
break;
case 'p':
- if (isdigit(optarg[0])) {
+ if (isdigit((uint8_t)optarg[0])) {
op->page_code = sg_get_num_nomult(optarg);
if ((op->page_code < 0) || (op->page_code > 255)) {
pr2serr("bad argument to '--page=PG' (0 to 255 "
@@ -1587,18 +1587,18 @@ parse_cgs_str(char * buff, struct tuple_acronym_val * tavp)
}
}
}
- if (isalpha(buff[0]))
+ if (isalpha((uint8_t)buff[0]))
tavp->acron = buff;
else {
colp = strchr(buff, ':');
if ((NULL == colp) || (buff == colp))
return -1;
*colp = '\0';
- if (('0' == buff[0]) && ('X' == toupper(buff[1]))) {
+ if (('0' == buff[0]) && ('X' == toupper((uint8_t)buff[1]))) {
if (1 != sscanf(buff + 2, "%x", &ui))
return -1;
tavp->start_byte = ui;
- } else if ('H' == toupper(*(colp - 1))) {
+ } else if ('H' == toupper((uint8_t)*(colp - 1))) {
if (1 != sscanf(buff, "%x", &ui))
return -1;
tavp->start_byte = ui;
@@ -4011,7 +4011,7 @@ read_hex(const char * inp, uint8_t * arr, int mx_arr_len, int * arr_len,
continue;
}
if (carry_over[0]) {
- if (isxdigit(line[0])) {
+ if (isxdigit((uint8_t)line[0])) {
carry_over[1] = line[0];
carry_over[2] = '\0';
if (1 == sscanf(carry_over, "%x", &h))
diff --git a/src/sg_ses_microcode.c b/src/sg_ses_microcode.c
index 36f3659e..a00b6d51 100644
--- a/src/sg_ses_microcode.c
+++ b/src/sg_ses_microcode.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2019 Douglas Gilbert.
+ * Copyright (c) 2014-2021 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.
@@ -45,7 +45,7 @@
* RESULTS commands in order to send microcode to the given SES device.
*/
-static const char * version_str = "1.18 20190513"; /* ses4r02 */
+static const char * version_str = "1.19 20210610"; /* ses4r02 */
#define ME "sg_ses_microcode: "
#define MAX_XFER_LEN (128 * 1024 * 1024)
@@ -557,7 +557,7 @@ main(int argc, char * argv[])
op->mc_len_given = true;
break;
case 'm':
- if (isdigit(*optarg)) {
+ if (isdigit((uint8_t)*optarg)) {
op->mc_mode = sg_get_num_nomult(optarg);
if ((op->mc_mode < 0) || (op->mc_mode > 255)) {
pr2serr("argument to '--mode' should be in the range 0 "
diff --git a/src/sg_stpg.c b/src/sg_stpg.c
index 6cb78932..e57b13c5 100644
--- a/src/sg_stpg.c
+++ b/src/sg_stpg.c
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2004-2018 Hannes Reinecke, Christophe Varoqui, Douglas Gilbert
+ * Copyright (c) 2004-2021 Hannes Reinecke, Christophe Varoqui, 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.
@@ -34,7 +34,7 @@
* to the given SCSI device.
*/
-static const char * version_str = "1.19 20180628";
+static const char * version_str = "1.20 20210610";
#define TGT_GRP_BUFF_LEN 1024
#define MX_ALLOC_LEN (0xc000 + 0x80)
@@ -357,13 +357,13 @@ build_state_arr(const char * inp, int * state_arr, int * state_arr_len,
}
for (k = 0; k < max_arr_len; ++k) {
try_num = true;
- if (isalpha(*lcp)) {
+ if (isalpha((uint8_t)*lcp)) {
try_num = false;
- switch (toupper(*lcp)) {
+ switch (toupper((uint8_t)*lcp)) {
case 'A':
- if ('N' == toupper(*(lcp + 1)))
+ if ('N' == toupper((uint8_t)*(lcp + 1)))
state_arr[k] = 1;
- else if ('O' == toupper(*(lcp + 1)))
+ else if ('O' == toupper((uint8_t)*(lcp + 1)))
state_arr[k] = 0;
else
try_num = true;
diff --git a/src/sg_vpd.c b/src/sg_vpd.c
index 4e538d6f..d5b3c3eb 100644
--- a/src/sg_vpd.c
+++ b/src/sg_vpd.c
@@ -40,7 +40,7 @@
*/
-static const char * version_str = "1.64 20210601"; /* spc6r05 + sbc4r22 */
+static const char * version_str = "1.64 20210610"; /* spc6r05 + sbc5r01 */
/* standard VPD pages, in ascending page number order */
#define VPD_SUPPORTED_VPDS 0x0
@@ -3898,7 +3898,7 @@ main(int argc, char * argv[])
pr2serr("Device name %s ignored when --enumerate given\n",
op->device_name);
if (op->vend_prod) {
- if (isdigit(op->vend_prod[0])) {
+ if (isdigit((uint8_t)op->vend_prod[0])) {
op->vend_prod_num = sg_get_num_nomult(op->vend_prod);
if ((op->vend_prod_num < 0) || (op->vend_prod_num > 10)) {
pr2serr("Bad vendor/product number after '--vendor=' "
@@ -3920,7 +3920,7 @@ main(int argc, char * argv[])
if ((0 == strcmp("-1", op->page_str)) ||
(0 == strcmp("-2", op->page_str)))
op->vpd_pn = VPD_NOPE_WANT_STD_INQ;
- else if (isdigit(op->page_str[0])) {
+ else if (isdigit((uint8_t)op->page_str[0])) {
op->vpd_pn = sg_get_num_nomult(op->page_str);
if ((op->vpd_pn < 0) || (op->vpd_pn > 255)) {
pr2serr("Bad page code value after '-p' option\n");
@@ -3948,7 +3948,7 @@ main(int argc, char * argv[])
if ((0 == strcmp("-1", op->page_str)) ||
(0 == strcmp("-2", op->page_str)))
op->vpd_pn = VPD_NOPE_WANT_STD_INQ;
- else if (isalpha(op->page_str[0])) {
+ else if (isalpha((uint8_t)op->page_str[0])) {
vnp = sdp_find_vpd_by_acron(op->page_str);
if (NULL == vnp) {
vnp = svpd_find_vendor_by_acron(op->page_str);
@@ -3977,7 +3977,7 @@ main(int argc, char * argv[])
return SG_LIB_SYNTAX_ERROR;
}
if (cp) {
- if (isdigit(*(cp + 1)))
+ if (isdigit((uint8_t)*(cp + 1)))
op->vend_prod_num = sg_get_num_nomult(cp + 1);
else
op->vend_prod_num = svpd_find_vp_num_by_acron(cp + 1);
@@ -3990,7 +3990,7 @@ main(int argc, char * argv[])
}
subvalue = op->vend_prod_num;
} else if (op->vend_prod) {
- if (isdigit(op->vend_prod[0]))
+ if (isdigit((uint8_t)op->vend_prod[0]))
op->vend_prod_num = sg_get_num_nomult(op->vend_prod);
else
op->vend_prod_num =
@@ -4005,7 +4005,7 @@ main(int argc, char * argv[])
}
}
} else if (op->vend_prod) {
- if (isdigit(op->vend_prod[0]))
+ if (isdigit((uint8_t)op->vend_prod[0]))
op->vend_prod_num = sg_get_num_nomult(op->vend_prod);
else
op->vend_prod_num = svpd_find_vp_num_by_acron(op->vend_prod);
diff --git a/src/sg_wr_mode.c b/src/sg_wr_mode.c
index 9db253b3..2a10fb7c 100644
--- a/src/sg_wr_mode.c
+++ b/src/sg_wr_mode.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2018 Douglas Gilbert.
+ * Copyright (c) 2004-2021 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.
@@ -32,7 +32,7 @@
* mode page on the given device.
*/
-static const char * version_str = "1.26 20180628";
+static const char * version_str = "1.27 20210610";
#define ME "sg_wr_mode: "
@@ -151,7 +151,7 @@ build_mode_page(const char * inp, uint8_t * mp_arr, int * mp_arr_len,
continue;
}
if (carry_over[0]) {
- if (isxdigit(line[0])) {
+ if (isxdigit((uint8_t)line[0])) {
carry_over[1] = line[0];
carry_over[2] = '\0';
if (1 == sscanf(carry_over, "%x", &h))
diff --git a/src/sg_write_buffer.c b/src/sg_write_buffer.c
index 37dcc295..2b84323a 100644
--- a/src/sg_write_buffer.c
+++ b/src/sg_write_buffer.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2018 Luben Tuikov and Douglas Gilbert.
+ * Copyright (c) 2006-2021 Luben Tuikov and 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.
@@ -40,7 +40,7 @@
* This utility issues the SCSI WRITE BUFFER command to the given device.
*/
-static const char * version_str = "1.29 20181112"; /* spc5r19 */
+static const char * version_str = "1.30 20210610"; /* spc6r05 */
#define ME "sg_write_buffer: "
#define DEF_XFER_LEN (8 * 1024 * 1024)
@@ -268,7 +268,7 @@ main(int argc, char * argv[])
wb_len_given = true;
break;
case 'm':
- if (isdigit(*optarg)) {
+ if (isdigit((uint8_t)*optarg)) {
wb_mode = sg_get_num(optarg);
if ((wb_mode < 0) || (wb_mode > 31)) {
pr2serr("argument to '--mode' should be in the range 0 "
diff --git a/src/sg_write_x.c b/src/sg_write_x.c
index 40edc352..2eed844b 100644
--- a/src/sg_write_x.c
+++ b/src/sg_write_x.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020 Douglas Gilbert.
+ * Copyright (c) 2017-2021 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.
@@ -38,7 +38,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "1.24 20200429";
+static const char * version_str = "1.25 20210610";
/* Protection Information refers to 8 bytes of extra information usually
* associated with each logical block and is often abbreviated to PI while
@@ -521,7 +521,7 @@ all_ascii_f_s(const char * cp, int num_of_f_chars)
if (('0' == cp[0]) && (('x' == cp[1]) || ('X' == cp[1])))
cp += 2;
for ( ; num_of_f_chars >= 0 ; --num_of_f_chars, ++cp) {
- if ('F' != toupper(*cp))
+ if ('F' != toupper((uint8_t)*cp))
return false;
}
return true;
@@ -1375,8 +1375,8 @@ do_write_x(int sg_fd, const void * dataoutp, int dout_len,
ret = sense_cat;
break;
case SG_LIB_CAT_ILLEGAL_REQ:
- if (vb)
- sg_print_command_len(x_cdb, cdb_len);
+ if (vb)
+ sg_print_command_len(x_cdb, cdb_len);
ret = sense_cat;
break;
default: