Return errors on open functions

Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
This commit is contained in:
TheJackiMonster 2023-09-08 13:04:05 +02:00
parent 2bd57ee0dd
commit b074ab72fc
No known key found for this signature in database
GPG key ID: D850A5F772E880F9
8 changed files with 72 additions and 90 deletions

View file

@ -47,20 +47,13 @@ void test3(uint64_t timestamp,
}
int main(int argc, const char** argv) {
device3_type* dev3 = device3_open(test3);
if (!dev3) {
device3_type dev3;
if (DEVICE3_ERROR_NO_ERROR != device3_open(&dev3, test3)) {
return 1;
}
device3_clear(dev3);
while (dev3) {
if (device3_read(dev3, -1) != DEVICE3_ERROR_NO_ERROR) {
break;
}
}
device3_close(dev3);
device3_clear(&dev3);
while (DEVICE3_ERROR_NO_ERROR == device3_read(&dev3, -1));
device3_close(&dev3);
return 0;
}

View file

@ -46,20 +46,13 @@ void test4(uint64_t timestamp,
}
int main(int argc, const char** argv) {
device4_type* dev4 = device4_open(test4);
if (!dev4) {
device4_type dev4;
if (DEVICE4_ERROR_NO_ERROR != device4_open(&dev4, test4)) {
return 1;
}
device4_clear(dev4);
while (dev4) {
if (device4_read(dev4, 1000) != DEVICE4_ERROR_NO_ERROR) {
break;
}
}
device4_close(dev4);
device4_clear(&dev4);
while (DEVICE4_ERROR_NO_ERROR == device4_read(&dev4, -1));
device4_close(&dev4);
return 0;
}

View file

@ -67,14 +67,13 @@ int main(int argc, const char** argv) {
return 0;
}
device4_type* dev4 = device4_open(NULL);
if (!dev4) {
device4_type dev4;
if (DEVICE4_ERROR_NO_ERROR != device4_open(&dev4, NULL)) {
return 1;
}
device4_clear(dev4);
device4_update_mcu_firmware(dev4, path);
device4_close(dev4);
device4_clear(&dev4);
device4_update_mcu_firmware(&dev4, path);
device4_close(&dev4);
return 0;
}