From 8b85eae099c9a554538b7051b0a047ddd0528554 Mon Sep 17 00:00:00 2001 From: Douglas Gilbert Date: Fri, 6 Jul 2018 16:48:38 +0000 Subject: sg_pr2serr.h: add sg_scnpr() [like lk scnprintf()]; rescan-scsi-bus.sh code_manpage cleanup git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@780 6180dd3e-e324-4e3e-922d-17de1ae2f315 --- examples/Makefile | 4 ++-- examples/sg_sat_chk_power.c | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'examples') diff --git a/examples/Makefile b/examples/Makefile index 0416a7f8..9c1f64e9 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -29,8 +29,8 @@ MAN_PREF = man8 LARGE_FILE_FLAGS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -##CPPFLAGS = -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS) -CPPFLAGS = -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS) -DDEBUG +CPPFLAGS = -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS) +# CPPFLAGS = -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS) -DDEBUG CFLAGS = -g -O2 -W -Wall # CFLAGS = -g -O2 -Wall -DSG_KERNEL_INCLUDES diff --git a/examples/sg_sat_chk_power.c b/examples/sg_sat_chk_power.c index 6bf2c979..b5ea18ae 100644 --- a/examples/sg_sat_chk_power.c +++ b/examples/sg_sat_chk_power.c @@ -37,7 +37,9 @@ #include #include #include + #include "sg_lib.h" +#include "sg_pr2serr.h" #include "sg_io_linux.h" /* This program performs a ATA PASS-THROUGH (16) SCSI command in order @@ -57,7 +59,7 @@ #define EBUFF_SZ 256 -static const char * version_str = "1.06 20180220"; +static const char * version_str = "1.07 20180706"; #if 0 @@ -77,19 +79,19 @@ sg_sat_decode_fixed_sense(const uint8_t * sp, int slen, char * bp, (SPC_SK_RECOVERED_ERROR != (0xf & sp[2])) || (0 != sp[12]) || (ASCQ_ATA_PT_INFO_AVAILABLE != sp[13])) return 0; - n = snprintf(bp, max_blen, "error=0x%x, status=0x%x, device=0x%x, " + n = sg_scnpr(bp, max_blen, "error=0x%x, status=0x%x, device=0x%x, " "sector_count(7:0)=0x%x%c\n", sp[3], sp[4], sp[5], sp[6], ((0x40 & sp[8]) ? '+' : ' ')); if (n >= max_blen) return max_blen - 1; - n += snprintf(bp + n, max_blen - n, "extend=%d, log_index=0x%x, " + n += sg_scnpr(bp + n, max_blen - n, "extend=%d, log_index=0x%x, " "lba_high,mid,low(7:0)=0x%x,0x%x,0x%x%c\n", (!!(0x80 & sp[8])), (0xf & sp[8]), sp[9], sp[10], sp[11], ((0x20 & sp[8]) ? '+' : ' ')); if (n >= max_blen) return max_blen - 1; if (verbose) - n += snprintf(bp + n, max_blen - n, " sector_count_upper_nonzero=" + n += sg_scnpr(bp + n, max_blen - n, " sector_count_upper_nonzero=" "%d, lba_upper_nonzero=%d\n", !!(0x40 & sp[8]), !!(0x20 & sp[8])); return (n >= max_blen) ? max_blen - 1 : n; -- cgit v1.2.3