[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-mdb] 01/02: improve uncrustify rules
From: |
gnunet |
Subject: |
[taler-taler-mdb] 01/02: improve uncrustify rules |
Date: |
Thu, 31 Oct 2019 12:55:28 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository taler-mdb.
commit 376c44387c968924403618bd2e594a3332ceafe7
Author: Christian Grothoff <address@hidden>
AuthorDate: Thu Oct 31 12:54:59 2019 +0100
improve uncrustify rules
---
contrib/uncrustify.cfg | 19 +++++++++++++++++++
src/nfc.c | 37 +++++++++++++++++++++----------------
2 files changed, 40 insertions(+), 16 deletions(-)
diff --git a/contrib/uncrustify.cfg b/contrib/uncrustify.cfg
index f56c8e7..12dd62c 100644
--- a/contrib/uncrustify.cfg
+++ b/contrib/uncrustify.cfg
@@ -49,8 +49,14 @@ nl_assign_brace=remove
# No extra newlines that cause noisy diffs
nl_start_of_file=remove
+nl_before_func_body_proto = 2
+nl_before_func_body_def = 3
+nl_after_func_proto = 2
+nl_after_func_body = 3
# If there's no new line, it's not a text file!
nl_end_of_file=add
+nl_max_blank_in_func = 3
+nl_max = 3
sp_inside_paren = remove
@@ -69,6 +75,7 @@ sp_between_ptr_star = remove
sp_before_sparen = add
sp_inside_fparen = remove
+sp_inside_sparen = remove
# add space before function call and decl: "foo (x)"
sp_func_call_paren = add
@@ -76,3 +83,15 @@ sp_func_proto_paren = add
sp_func_proto_paren_empty = add
sp_func_def_paren = add
sp_func_def_paren_empty = add
+
+# We'd want it for "if ( (foo) || (bar) )", but not for "if (m())",
+# so as uncrustify doesn't give exactly what we want => ignore
+sp_paren_paren = ignore
+sp_inside_paren = remove
+sp_bool = force
+
+nl_func_type_name = force
+#nl_branch_else = add
+nl_else_brace = add
+nl_elseif_brace = add
+nl_for_brace = add
diff --git a/src/nfc.c b/src/nfc.c
index 2be0a11..20cdb01 100644
--- a/src/nfc.c
+++ b/src/nfc.c
@@ -29,25 +29,25 @@ along with
#include "nfc.h"
#include "wallet.h"
-
// upper and lower bounds for mifare targets uid length
#define UID_LEN_UPPER 7
#define UID_LEN_LOWER 4
-int nfc_transmit (nfc_context *context, const char *talerPayUrl, size_t
urlSize)
+int
+nfc_transmit (nfc_context *context, const char *talerPayUrl, size_t urlSize)
{
nfc_device *pnd;
pnd = nfc_open (context, NULL); // NULL could be replaced with connstring
if the correct is known
- if ( ! pnd )
+ if (! pnd)
{
printf ("Unable to open NFC device\n");
return EXIT_FAILURE;
}
// initialize device as reader
- if ( nfc_initiator_init (pnd) < 0 )
+ if (nfc_initiator_init (pnd) < 0)
{
nfc_perror (pnd, "nfc_initiator_init");
nfc_close (pnd);
@@ -60,14 +60,14 @@ int nfc_transmit (nfc_context *context, const char
*talerPayUrl, size_t urlSize)
nfc_target nt;
// connect to a target device
- if ( nfc_connect_target (pnd, &nt) )
+ if (nfc_connect_target (pnd, &nt) )
{
nfc_close (pnd);
return EXIT_FAILURE;
}
// send the message to the wallet
- if ( wallet_transmit (pnd, talerPayUrl, urlSize) )
+ if (wallet_transmit (pnd, talerPayUrl, urlSize) )
{
// the transmition failed, the target has to be reselected when using
MIFARE as defined in libnfc --> exit
nfc_close (pnd);
@@ -81,7 +81,9 @@ int nfc_transmit (nfc_context *context, const char
*talerPayUrl, size_t urlSize)
return EXIT_SUCCESS;
}
-int nfc_connect_target (nfc_device *pnd, nfc_target *nt)
+
+int
+nfc_connect_target (nfc_device *pnd, nfc_target *nt)
{
const nfc_modulation nmMifare[] = { {
.nmt = NMT_ISO14443A,
@@ -90,21 +92,22 @@ int nfc_connect_target (nfc_device *pnd, nfc_target *nt)
printf ("nfc_connect_target: trying to connect to target\n");
int ctr = 2;
- while ( ctr > 0 )
+ while (ctr > 0)
{
// set uid lenght to zero ( in case of second selecting the length still
has the old value )
nt->nti.nai.szUidLen = 0;
- if ( nfc_initiator_select_passive_target (pnd, nmMifare[0], NULL, 0, nt) <=
- 0 )
+ if (nfc_initiator_select_passive_target (pnd, nmMifare[0], NULL, 0, nt) <=
+ 0)
{
printf ("nfc_connect_target: failed to connect\n");
}
- else if ((nt->nti.nai.szUidLen > UID_LEN_UPPER) ||(nt->nti.nai.szUidLen <
- UID_LEN_LOWER) )
+ else if ( (nt->nti.nai.szUidLen > UID_LEN_UPPER) ||
+ (nt->nti.nai.szUidLen < UID_LEN_LOWER) )
{
printf ("nfc_connect_target: failed to connect\n");
}
- else {
+ else
+ {
printf ("nfc_connect_target: Target selected!\n");
nfc_display_target_uid (nt);
return EXIT_SUCCESS;
@@ -112,14 +115,16 @@ int nfc_connect_target (nfc_device *pnd, nfc_target *nt)
sleep (1);
ctr--;
}
-
return EXIT_FAILURE;
}
-void nfc_display_target_uid (nfc_target *nt)
+
+void
+nfc_display_target_uid (nfc_target *nt)
{
printf ("UID: ");
- for ( unsigned int uidPos = 0; uidPos < nt->nti.nai.szUidLen; uidPos++ ) {
+ for (unsigned int uidPos = 0; uidPos < nt->nti.nai.szUidLen; uidPos++)
+ {
printf ("%.2x ", nt->nti.nai.abtUid[uidPos]);
}
printf ("\n\n");
--
To stop receiving notification emails like this one, please contact
address@hidden.