diff options
| author | Jérémy Zurcher <jeremy@asynk.ch> | 2011-02-28 01:05:02 +0100 | 
|---|---|---|
| committer | Jérémy Zurcher <jeremy@asynk.ch> | 2011-02-28 01:05:02 +0100 | 
| commit | b8b9bf4f2944e7f6bc76e98aea1249915943e612 (patch) | |
| tree | 089e607ddcb3f1ecac36da9d739ffeccaba221d1 | |
| parent | 289c8180cbc36fc3566b32e4dd906033ef337547 (diff) | |
| download | k8055-b8b9bf4f2944e7f6bc76e98aea1249915943e612.zip k8055-b8b9bf4f2944e7f6bc76e98aea1249915943e612.tar.gz | |
check SetCurrentDevice
| -rw-r--r-- | libk8055/libk8055.c | 17 | 
1 files changed, 5 insertions, 12 deletions
| diff --git a/libk8055/libk8055.c b/libk8055/libk8055.c index 7489759..ad34212 100644 --- a/libk8055/libk8055.c +++ b/libk8055/libk8055.c @@ -266,18 +266,11 @@ int CloseDevice() {  }  /* New function in version 2 of Velleman DLL, should return deviceno if OK */ -long SetCurrentDevice(long deviceno) -{ -    if (deviceno >= 0 && deviceno < K8055_MAX_DEV) -    { -        if (k8055d[deviceno].dev_no != 0) -        { -            curr_dev  = &k8055d[deviceno]; -            return deviceno; -        } -    } -    return K8055_ERROR; - +long SetCurrentDevice(long deviceno) { +    if (deviceno < 0 || deviceno >= K8055_MAX_DEV) return K8055_ERROR; +    if (k8055d[deviceno].dev_no == 0) return K8055_ERROR; +    curr_dev  = &k8055d[deviceno]; +    return deviceno;  }  /* New function in version 2 of Velleman DLL, should return devices-found bitmask or 0*/ | 
