scsitape/stenc

Errors don't display correctly

sunwire opened this issue · 3 comments

When an error appears, version 1.0.8 displays:

Sense Code:              Illegal Request (0x05)
 ASC:                    0x26
 ASCQ:                   0x00
 Additional data:        0x00000000000000000000000000000000

but version 1.0.9 and 1.1.0 displays:

Sense Code:              Illegal Request (0x)
 ASC:                    0x&
 ASCQ:                   0x
 Additional data:        0x

The reason for this are changes made in aa22443
The old code uses HEX() macro

stenc/src/scsiencrypt.h

Lines 39 to 40 in 844306d

#define HEX(x) \
right << setw(2) << setfill('0') << hex << (int)(x) << setfill(' ')
it cast to the appropriate type (int), but a new code doesn't do it. e.g:
old:
cerr<<" (0x"<<HEX(sd->senseKey)<<")"<<endl;
new:
std::cerr<<" (0x"<<std::hex << (sd->senseKey);
it should be std::cerr<<" (0x"<<std::hex << int(sd->senseKey); or std::cerr<<" (0x"<<std::hex << static_cast<int>(sd->senseKey);
At least 7 lines of code are affected.
PS.
The macro also formats in the right way e.g. displays 0x01 not 0x1

I think we should drop that macro and write a proper function with test.

@sunwire ok then lets try to get the tests working. It would make sense to make a new release soon and drop 1.1.0

fixed by revert in f1a36eb