Luc Perneel

sdphost does not return failure state on all failures

Discussion created by Luc Perneel on Mar 22, 2019
Latest reply on Mar 28, 2019 by Luc Perneel

We found a problem with sdphost: it does not return a non zero value upon all failures.

This is very annoying when using this in scripts... this is the case both for the windows as the linux variant.

The following example illustrates this:

-- under linux --

# ./sdphost -u 0x1fc9,0x0130 -- write-file 0x20000000 non_existing_file
Error: cannot open input data file 'non_existing_file'.
# echo $?
0   ==> this is not expected!
# ./sdphost -u 0x1234,0x1234 -- write-file 0x20000000 non_existing_file
Error: UsbHidPeripheral() cannot open USB HID device (vid=0x1234, pid=0x1234, sn=).
# echo $?
1   ==> this is correct

-- under windows --
> sdphost.exe -u 0x1fc9,0x0130 -- write-file 0x20000000 non_existing_file
Error: cannot open input data file 'non_existing_file'.
> echo %ERRORLEVEL%
0   ==> this is not expected!
> sdphost.exe -u 0x1234,0x1234 -- write-file 0x20000000 non_existing_file
Error: UsbHidPeripheral() cannot open USB HID device (vid=0x1234, pid=0x1234, sn=).
> echo %ERRORLEVEL%
1   ==> this is correct

 

This is a bug:  all tools should return a non zero failure code if anything failed. Only when nothing went wrong at all and thus it was a complete success zero should be returned.

 

Such bugs can cost you hours/days of debug work when suddenly some script start to fail....

Outcomes