mirror of
https://github.com/nfc-tools/libnfc.git
synced 2026-02-19 08:16:35 +00:00
Error conditions in utils & examples: fix leaks, unify style (see details)
* in main(): ** errx()/err()/return -> exit() ** return values -> EXIT_SUCCESS & EXIT_FAILURE * out of main: ** err()/errx()/exit() -> return ** change retval from size_t to int to allow returning errors ** don't use EXIT_SUCCESS / EXIT_FAILURE as retvals * add nfc_close() & nfc_exit() to exit() on errors * add missing fclose() on errors * add missing test if (pnd == NULL) * unify style if (pnd == / != NULL) * remove goto's * few related fixes * remove if(pnd!=NULL) test on nfc_close() calls
This commit is contained in:
@@ -50,7 +50,7 @@ main(int argc, const char *argv[])
|
||||
|
||||
if (pnd == NULL) {
|
||||
warnx("ERROR: %s", "Unable to open NFC device.");
|
||||
return EXIT_FAILURE;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
// Set opened NFC device to initiator mode
|
||||
if (nfc_initiator_init(pnd) < 0) {
|
||||
@@ -82,5 +82,5 @@ main(int argc, const char *argv[])
|
||||
nfc_close(pnd);
|
||||
// Release the context
|
||||
nfc_exit(context);
|
||||
return EXIT_SUCCESS;
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ main(int argc, const char *argv[])
|
||||
|
||||
if (pnd == NULL) {
|
||||
ERR("%s", "Unable to open NFC device.");
|
||||
return EXIT_FAILURE;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
// Set opened NFC device to initiator mode
|
||||
if (nfc_initiator_init(pnd) < 0) {
|
||||
@@ -74,5 +74,5 @@ main(int argc, const char *argv[])
|
||||
nfc_close(pnd);
|
||||
// Release the context
|
||||
nfc_exit(context);
|
||||
return EXIT_SUCCESS;
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user