aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--debian/changelog2
-rw-r--r--examples/Makefile.freebsd6
-rw-r--r--lib/sg_lib.c7
-rw-r--r--sg3_utils.spec2
-rw-r--r--src/sg_decode_sense.c8
-rw-r--r--testing/Makefile.cplus_fb79
-rw-r--r--testing/Makefile.freebsd12
-rw-r--r--testing/tst_sg_lib.c42
-rw-r--r--utils/Makefile.freebsd4
10 files changed, 123 insertions, 41 deletions
diff --git a/ChangeLog b/ChangeLog
index 6f78c825..5c6b6d43 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 [20180712] [svn: r782]
+Changelog for sg3_utils-1.43 [20180715] [svn: r783]
- sg_write_x: where x can be normal, atomic, or(write),
same, scattered, or stream writes with 16 or 32 byte
cdbs (sbc4r04 for atomic, sbc4r11 for scattered)
diff --git a/debian/changelog b/debian/changelog
index e112aeb6..d56f009c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,7 +2,7 @@ sg3-utils (1.43-0.1) unstable; urgency=low
* New upstream version
- -- Douglas Gilbert <dgilbert@interlog.com> Fri, 06 Jul 2018 12:00:00 -0400
+ -- Douglas Gilbert <dgilbert@interlog.com> Sun, 15 Jul 2018 12:00:00 -0400
sg3-utils (1.42-0.1) unstable; urgency=low
diff --git a/examples/Makefile.freebsd b/examples/Makefile.freebsd
index 86d48cc7..fda94c37 100644
--- a/examples/Makefile.freebsd
+++ b/examples/Makefile.freebsd
@@ -8,10 +8,10 @@ MANDIR=$(DESTDIR)/$(PREFIX)/man
# the default C compiler is clang. Swap the comment marks (lines starting
# with '#') on the next 4 (non-blank) lines.
# CC = gcc
-CC = clang
+# CC = clang
# LD = gcc
-LD = clang
+# LD = clang
EXECS = sg_simple5
@@ -49,7 +49,7 @@ clean:
/bin/rm -f *.o $(EXECS) $(EXTRAS) core .depend
sg_simple5: sg_simple5.o $(D_FILES)
- $(LD) -o $@ $(LDFLAGS) $@.o $(D_FILES)
+ $(CC) -o $@ $(LDFLAGS) $@.o $(D_FILES)
install: $(EXECS)
diff --git a/lib/sg_lib.c b/lib/sg_lib.c
index 9a9c223a..e027f539 100644
--- a/lib/sg_lib.c
+++ b/lib/sg_lib.c
@@ -1910,9 +1910,9 @@ bool sg_exit2str(int exit_status, bool longer, int b_len, char *b)
b[0] = '\0';
if (exit_status < 0)
return false;
- else if ((0 == exit_status) || (SG_LIB_OK_FALSE)) {
+ else if ((0 == exit_status) || (SG_LIB_OK_FALSE == exit_status)) {
if (longer)
- snprintf(b, b_len, "%s", ess->name);
+ goto fini;
return true;
}
@@ -1926,6 +1926,7 @@ bool sg_exit2str(int exit_status, bool longer, int b_len, char *b)
exit_status - 128);
return true;
}
+fini:
for ( ; ess->name; ++ess) {
if (exit_status == ess->value)
break;
@@ -1946,7 +1947,7 @@ sg_if_can2fp(const char * leadin, int exit_status, FILE * fp)
char b[256];
const char * s = leadin ? leadin : "";
- if ((0 == exit_status) || (SG_LIB_OK_FALSE))
+ if ((0 == exit_status) || (SG_LIB_OK_FALSE == exit_status))
return true; /* don't print anything */
else if (sg_exit2str(exit_status, false, sizeof(b), b)) {
fprintf(fp, "%s%s\n", s, b);
diff --git a/sg3_utils.spec b/sg3_utils.spec
index db76d6b3..5bb63a12 100644
--- a/sg3_utils.spec
+++ b/sg3_utils.spec
@@ -80,7 +80,7 @@ fi
%{_libdir}/*.la
%changelog
-* Fri Jul 06 2018 - dgilbert at interlog dot com
+* Sun Jul 15 2018 - dgilbert at interlog dot com
- track t10 changes
* sg3_utils-1.43
diff --git a/src/sg_decode_sense.c b/src/sg_decode_sense.c
index d8784424..6bb08ec8 100644
--- a/src/sg_decode_sense.c
+++ b/src/sg_decode_sense.c
@@ -28,9 +28,9 @@
#include "sg_unaligned.h"
-static const char * version_str = "1.18 20180626";
+static const char * version_str = "1.19 20180714";
-#define MAX_SENSE_LEN 1024 /* max descriptor format actually: 256+8 */
+#define MAX_SENSE_LEN 1024 /* max descriptor format actually: 255+8 */
static struct option long_options[] = {
{"binary", required_argument, 0, 'b'},
@@ -428,7 +428,6 @@ write2wfn(FILE * fp, struct opts_t * op)
int
main(int argc, char *argv[])
{
- bool ok;
int k, err;
int ret = 0;
unsigned int ui;
@@ -476,8 +475,7 @@ main(int argc, char *argv[])
char d[128];
const int dlen = sizeof(d);
- ok = sg_exit2str(op->es_val, op->verbose > 1, dlen, d);
- if (! ok)
+ if (! sg_exit2str(op->es_val, op->verbose > 1, dlen, d))
snprintf(d, dlen, "Unable to decode exit status %d", op->es_val);
if (1 & op->verbose) /* odd values of verbose print to stderr */
pr2serr("%s\n", d);
diff --git a/testing/Makefile.cplus_fb b/testing/Makefile.cplus_fb
new file mode 100644
index 00000000..a41c2346
--- /dev/null
+++ b/testing/Makefile.cplus_fb
@@ -0,0 +1,79 @@
+SHELL = /bin/sh
+
+PREFIX=/usr/local
+INSTDIR=$(DESTDIR)/$(PREFIX)/bin
+MANDIR=$(DESTDIR)/$(PREFIX)/man
+
+## CC = g++
+## LD = g++
+## CC = clang++
+## LD = clang++
+
+## This is just an example FreeBSD Makefile for how to build for clang++
+## All .cpp execs in this directory are Linux specific so there is
+## nothing to do for FreeBSD.
+## Not optimum but it works around 20180715 [dpg]
+
+# EXECS = sg_tst_context
+EXECS =
+
+EXTRAS =
+
+BSG_EXTRAS =
+
+
+MAN_PGS =
+MAN_PREF = man8
+
+LARGE_FILE_FLAGS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
+
+CXXFLAGS = -std=c++11 -pthread -g -O2 -W -Wall -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS)
+# CPPFLAGS = -std=c++11 -pthread -g -O2 -W -Wall -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS) -DDEBUG
+## CFLAGS = -g -O2 -W -Wall -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS)
+# CFLAGS = -g -O2 -Wall -iquote ../include -D_REENTRANT -DSG_KERNEL_INCLUDES $(LARGE_FILE_FLAGS)
+# CFLAGS = -g -O2 -Wall -pedantic -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS)
+
+LDFLAGS = -std=c++11 -pthread
+
+LIBFILESOLD = ../lib/sg_lib.o ../lib/sg_lib_data.o
+LIBFILESNEW = ../lib/sg_lib.o ../lib/sg_lib_data.o ../lib/sg_pt_freebsd.o ../lib/sg_pt_common.o \
+ ../lib/sg_cmds_basic.o
+
+all: $(EXECS)
+
+extras: $(EXTRAS)
+
+
+depend dep:
+ for i in $(EXECS).cpp; do $(CXX) $(INCLUDES) $(CXXFLAGS) -M $$i; \
+ done > .depend
+
+clean:
+ /bin/rm -f *.o $(EXECS) $(EXTRAS) $(BSG_EXTRAS) core .depend
+
+sg_tst_context: sg_tst_async.o $(LIBFILESNEW)
+ $(CXX) -o $@ $(LDFLAGS) $^
+
+install: $(EXECS)
+ install -d $(INSTDIR)
+ for name in $^; \
+ do install -s -o root -g root -m 755 $$name $(INSTDIR); \
+ done
+ install -d $(MANDIR)/$(MAN_PREF)
+ for mp in $(MAN_PGS); \
+ do install -o root -g root -m 644 $$mp $(MANDIR)/$(MAN_PREF); \
+ gzip -9f $(MANDIR)/$(MAN_PREF)/$$mp; \
+ done
+
+uninstall:
+ dists="$(EXECS)"; \
+ for name in $$dists; do \
+ rm -f $(INSTDIR)/$$name; \
+ done
+ for mp in $(MAN_PGS); do \
+ rm -f $(MANDIR)/$(MAN_PREF)/$$mp.gz; \
+ done
+
+## ifeq (.depend,$(wildcard .depend))
+## include .depend
+## endif
diff --git a/testing/Makefile.freebsd b/testing/Makefile.freebsd
index b7dcef27..6cfe7d8f 100644
--- a/testing/Makefile.freebsd
+++ b/testing/Makefile.freebsd
@@ -8,10 +8,10 @@ MANDIR=$(DESTDIR)/$(PREFIX)/man
# the default C compiler is clang. Swap the comment marks (lines starting
# with '#') on the next 4 (non-blank) lines.
# CC = gcc
-CC = clang
+# CC = clang
# LD = gcc
-LD = clang
+# LD = clang
EXECS = sg_sense_test sg_chk_asc sg_tst_nvme tst_sg_lib
@@ -54,17 +54,17 @@ clean:
/bin/rm -f *.o $(EXECS) $(EXTRAS) core .depend
sg_sense_test: sg_sense_test.o $(D_FILES)
- $(LD) -o $@ $(LDFLAGS) $@.o $(D_FILES)
+ $(CC) -o $@ $(LDFLAGS) $@.o $(D_FILES)
# building sg_chk_asc depends on a prior successful make in ../lib
sg_chk_asc: sg_chk_asc.o $(D_FILES)
- $(LD) -o $@ $(LDFLAGS) $@.o $(D_FILES)
+ $(CC) -o $@ $(LDFLAGS) $@.o $(D_FILES)
sg_tst_nvme: sg_tst_nvme.o $(D_FILES)
- $(LD) -o $@ $(LDFLAGS) $@.o $(D_FILES)
+ $(CC) -o $@ $(LDFLAGS) $@.o $(D_FILES)
tst_sg_lib: tst_sg_lib.o $(D_FILES)
- $(LD) -o $@ $(LDFLAGS) $@.o $(D_FILES)
+ $(CC) -o $@ $(LDFLAGS) $@.o $(D_FILES)
install: $(EXECS)
install -d $(INSTDIR)
diff --git a/testing/tst_sg_lib.c b/testing/tst_sg_lib.c
index 5b5725d3..027e6fb2 100644
--- a/testing/tst_sg_lib.c
+++ b/testing/tst_sg_lib.c
@@ -19,7 +19,7 @@
#include <time.h>
-#ifdef __GNUC__
+#if defined(__GNUC__) && ! defined(SG_LIB_FREEBSD)
#include <byteswap.h>
#endif
@@ -42,7 +42,7 @@
* related to snprintf().
*/
-static const char * version_str = "1.11 20180706";
+static const char * version_str = "1.11 20180715";
#define MAX_LINE_LEN 1024
@@ -160,26 +160,27 @@ usage()
"[--printf]\n"
" [--sense] [--unaligned] [--verbose] "
"[--version]\n"
-#ifdef __GNUC__
- " where: --byteswap=B|-b B B is 16, 32 or 64; tests "
- "NUM byteswaps\n"
- " compared to sg_unaligned "
+ " where:\n"
+#if defined(__GNUC__) && ! defined(SG_LIB_FREEBSD)
+ " --byteswap=B|-b B B is 16, 32 or 64; tests NUM "
+ "byteswaps\n"
+ " compared to sg_unaligned "
"equivalent\n"
- " --exit|-e test exit status strings\n"
+ " --exit|-e test exit status strings\n"
#else
- " where: --exit|-e test exit status strings\n"
+ " --exit|-e test exit status strings\n"
#endif
- " --help|-h print out usage message\n"
- " --hex2|-H test hex2* variants\n"
- " --leadin=STR|-l STR every line output by --sense "
+ " --help|-h print out usage message\n"
+ " --hex2|-H test hex2* variants\n"
+ " --leadin=STR|-l STR every line output by --sense "
"should\n"
- " be prefixed by STR\n"
- " --num=NUM|-n NUM number of iterations (def=1)\n"
- " --printf|-p test library printf variants\n"
- " --sense|-s test sense data handling\n"
- " --unaligned|-u test unaligned data handling\n"
- " --verbose|-v increase verbosity\n"
- " --version|-V print version string and exit\n\n"
+ " be prefixed by STR\n"
+ " --num=NUM|-n NUM number of iterations (def=1)\n"
+ " --printf|-p test library printf variants\n"
+ " --sense|-s test sense data handling\n"
+ " --unaligned|-u test unaligned data handling\n"
+ " --verbose|-v increase verbosity\n"
+ " --version|-V print version string and exit\n\n"
"Test various parts of sg_lib, see options. Sense data tests "
"overlap\nsomewhat with examples/sg_sense_test .\n"
);
@@ -297,6 +298,8 @@ main(int argc, char * argv[])
}
if (do_exit_status) {
+ ++did_something;
+
printf("Test Exit Status strings (add -v for long version):\n");
printf(" No error (es=0): %s\n",
sg_get_category_sense_str(0, b_len, b, vb));
@@ -315,6 +318,7 @@ main(int argc, char * argv[])
printf("%s\n", get_exit_status_str(8, (vb > 0), b_len, b));
printf("%s\n", get_exit_status_str(25, (vb > 0), b_len, b));
printf("%s\n", get_exit_status_str(33, (vb > 0), b_len, b));
+ printf("%s\n", get_exit_status_str(36, (vb > 0), b_len, b));
printf("%s\n", get_exit_status_str(48, (vb > 0), b_len, b));
printf("%s\n", get_exit_status_str(50, (vb > 0), b_len, b));
printf("%s\n", get_exit_status_str(51, (vb > 0), b_len, b));
@@ -551,7 +555,7 @@ main(int argc, char * argv[])
printf(" u64r[v=8 bytes]=0x%" PRIx64 "\n\n", u64r);
}
-#ifdef __GNUC__
+#if defined(__GNUC__) && ! defined(SG_LIB_FREEBSD)
if (byteswap_sz > 0) {
uint32_t elapsed_msecs;
uint16_t count16 = 0;
diff --git a/utils/Makefile.freebsd b/utils/Makefile.freebsd
index 62e6cb17..a43a5695 100644
--- a/utils/Makefile.freebsd
+++ b/utils/Makefile.freebsd
@@ -4,8 +4,8 @@ PREFIX=/usr/local
INSTDIR=$(DESTDIR)/$(PREFIX)/bin
MANDIR=$(DESTDIR)/$(PREFIX)/man
-CC = gcc
-LD = gcc
+CC = clang
+LD = clang
EXECS = hxascdmp