laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/simtrace2/+/27397 )
Change subject: host: Don't pass -1 (converted to 255) as address ......................................................................
host: Don't pass -1 (converted to 255) as address
We initialize a local variable to -1, and if the user specifies no address from the command line, we use this in the interface match struct, which uses a uint8_t. This means 255 ends up in there, and as a result no usb interface ever matches unless the user explicitly specifies the -A command line argument.
With this patch any absent -A argument will result in ifm.addr == 0, which means "don't match on address", and which is what we want here.
Change-Id: Iffb5fa406ddef00c7c15570ffca2c109b98d7a2d --- M host/src/simtrace2-cardem-pcsc.c M host/src/simtrace2-tool.c 2 files changed, 4 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/97/27397/1
diff --git a/host/src/simtrace2-cardem-pcsc.c b/host/src/simtrace2-cardem-pcsc.c index 0eaf2c3..36fa579 100644 --- a/host/src/simtrace2-cardem-pcsc.c +++ b/host/src/simtrace2-cardem-pcsc.c @@ -529,7 +529,8 @@ altsetting = atoi(optarg); break; case 'A': - addr = atoi(optarg); + if (addr > 0 && addr < 256) + addr = atoi(optarg); break; case 'H': path = optarg; diff --git a/host/src/simtrace2-tool.c b/host/src/simtrace2-tool.c index b0fac6c..bfdc979 100644 --- a/host/src/simtrace2-tool.c +++ b/host/src/simtrace2-tool.c @@ -275,7 +275,8 @@ altsetting = atoi(optarg); break; case 'A': - addr = atoi(optarg); + if (addr > 0 && addr < 256) + addr = atoi(optarg); break; case 'H': path = optarg;