netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeremy Sowden <jeremy@azazel.net>
To: Netfilter Devel <netfilter-devel@vger.kernel.org>
Subject: [PATCH ulogd2 v2 v2 08/34] src: parenthesize config-entry macro arguments
Date: Tue, 29 Nov 2022 21:47:23 +0000	[thread overview]
Message-ID: <20221129214749.247878-9-jeremy@azazel.net> (raw)
In-Reply-To: <20221129214749.247878-1-jeremy@azazel.net>

It's avoids problems with operator precedence.  For example, with no
parentheses:

  #define blah_ce(x) (x->ces[0])

  blah_ce(&whatever)

yields:

  (&(whatever->ces[0]))

instead of:

  ((&whatever)->ces[0])

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
---
 include/ulogd/db.h                | 14 +++++++-------
 input/flow/ulogd_inpflow_NFCT.c   | 18 +++++++++---------
 input/packet/ulogd_inppkt_NFLOG.c | 24 ++++++++++++------------
 input/sum/ulogd_inpflow_NFACCT.c  |  6 +++---
 output/dbi/ulogd_output_DBI.c     | 14 +++++++-------
 output/ipfix/ulogd_output_IPFIX.c | 12 ++++++------
 output/mysql/ulogd_output_MYSQL.c | 10 +++++-----
 output/pgsql/ulogd_output_PGSQL.c | 14 +++++++-------
 output/ulogd_output_GRAPHITE.c    |  6 +++---
 output/ulogd_output_JSON.c        |  8 ++++----
 10 files changed, 63 insertions(+), 63 deletions(-)

diff --git a/include/ulogd/db.h b/include/ulogd/db.h
index bf62f236d772..50925a69f240 100644
--- a/include/ulogd/db.h
+++ b/include/ulogd/db.h
@@ -103,13 +103,13 @@ struct db_instance {
 		}
 
 #define DB_CE_NUM		7
-#define table_ce(x)		(x->ces[0])
-#define reconnect_ce(x)		(x->ces[1])
-#define timeout_ce(x)		(x->ces[2])
-#define procedure_ce(x)		(x->ces[3])
-#define backlog_memcap_ce(x)	(x->ces[4])
-#define backlog_oneshot_ce(x)	(x->ces[5])
-#define ringsize_ce(x)		(x->ces[6])
+#define table_ce(x)		((x)->ces[0])
+#define reconnect_ce(x)		((x)->ces[1])
+#define timeout_ce(x)		((x)->ces[2])
+#define procedure_ce(x)		((x)->ces[3])
+#define backlog_memcap_ce(x)	((x)->ces[4])
+#define backlog_oneshot_ce(x)	((x)->ces[5])
+#define ringsize_ce(x)		((x)->ces[6])
 
 void ulogd_db_signal(struct ulogd_pluginstance *upi, int signal);
 int ulogd_db_start(struct ulogd_pluginstance *upi);
diff --git a/input/flow/ulogd_inpflow_NFCT.c b/input/flow/ulogd_inpflow_NFCT.c
index 76250f2a9982..04910601fb8c 100644
--- a/input/flow/ulogd_inpflow_NFCT.c
+++ b/input/flow/ulogd_inpflow_NFCT.c
@@ -137,15 +137,15 @@ static struct config_keyset nfct_kset = {
 		},
 	},
 };
-#define pollint_ce(x)	(x->ces[0])
-#define usehash_ce(x)	(x->ces[1])
-#define buckets_ce(x)	(x->ces[2])
-#define maxentries_ce(x) (x->ces[3])
-#define eventmask_ce(x) (x->ces[4])
-#define nlsockbufsize_ce(x) (x->ces[5])
-#define nlsockbufmaxsize_ce(x) (x->ces[6])
-#define nlresynctimeout_ce(x) (x->ces[7])
-#define reliable_ce(x)	(x->ces[8])
+#define pollint_ce(x)		((x)->ces[0])
+#define usehash_ce(x)		((x)->ces[1])
+#define buckets_ce(x)		((x)->ces[2])
+#define maxentries_ce(x)	((x)->ces[3])
+#define eventmask_ce(x)		((x)->ces[4])
+#define nlsockbufsize_ce(x)	((x)->ces[5])
+#define nlsockbufmaxsize_ce(x)	((x)->ces[6])
+#define nlresynctimeout_ce(x)	((x)->ces[7])
+#define reliable_ce(x)		((x)->ces[8])
 #define src_filter_ce(x)	((x)->ces[9])
 #define dst_filter_ce(x)	((x)->ces[10])
 #define proto_filter_ce(x)	((x)->ces[11])
diff --git a/input/packet/ulogd_inppkt_NFLOG.c b/input/packet/ulogd_inppkt_NFLOG.c
index e197a705cb4d..4cbae69fee20 100644
--- a/input/packet/ulogd_inppkt_NFLOG.c
+++ b/input/packet/ulogd_inppkt_NFLOG.c
@@ -99,18 +99,18 @@ static struct config_keyset libulog_kset = {
 	}
 };
 
-#define bufsiz_ce(x)	(x->ces[0])
-#define group_ce(x)	(x->ces[1])
-#define unbind_ce(x)	(x->ces[2])
-#define bind_ce(x)	(x->ces[3])
-#define seq_ce(x)	(x->ces[4])
-#define seq_global_ce(x)	(x->ces[5])
-#define label_ce(x)	(x->ces[6])
-#define nlsockbufsize_ce(x) (x->ces[7])
-#define nlsockbufmaxsize_ce(x) (x->ces[8])
-#define nlthreshold_ce(x) (x->ces[9])
-#define nltimeout_ce(x) (x->ces[10])
-#define attach_conntrack_ce(x) (x->ces[11])
+#define bufsiz_ce(x)		((x)->ces[0])
+#define group_ce(x)		((x)->ces[1])
+#define unbind_ce(x)		((x)->ces[2])
+#define bind_ce(x)		((x)->ces[3])
+#define seq_ce(x)		((x)->ces[4])
+#define seq_global_ce(x)	((x)->ces[5])
+#define label_ce(x)		((x)->ces[6])
+#define nlsockbufsize_ce(x)	((x)->ces[7])
+#define nlsockbufmaxsize_ce(x)	((x)->ces[8])
+#define nlthreshold_ce(x)	((x)->ces[9])
+#define nltimeout_ce(x)		((x)->ces[10])
+#define attach_conntrack_ce(x)	((x)->ces[11])
 
 enum nflog_keys {
 	NFLOG_KEY_RAW_MAC = 0,
diff --git a/input/sum/ulogd_inpflow_NFACCT.c b/input/sum/ulogd_inpflow_NFACCT.c
index 539fb67f5863..c680a52a80e8 100644
--- a/input/sum/ulogd_inpflow_NFACCT.c
+++ b/input/sum/ulogd_inpflow_NFACCT.c
@@ -51,9 +51,9 @@ static struct config_keyset nfacct_kset = {
 	},
 	.num_ces = 3,
 };
-#define pollint_ce(x)	(x->ces[0])
-#define zerocounter_ce(x) (x->ces[1])
-#define timestamp_ce(x) (x->ces[2])
+#define pollint_ce(x)		((x)->ces[0])
+#define zerocounter_ce(x)	((x)->ces[1])
+#define timestamp_ce(x)		((x)->ces[2])
 
 enum ulogd_nfacct_keys {
 	ULOGD_NFACCT_NAME,
diff --git a/output/dbi/ulogd_output_DBI.c b/output/dbi/ulogd_output_DBI.c
index 5639125dde1f..95bd35789c08 100644
--- a/output/dbi/ulogd_output_DBI.c
+++ b/output/dbi/ulogd_output_DBI.c
@@ -78,13 +78,13 @@ static struct config_keyset dbi_kset = {
 		},
 	},
 };
-#define db_ce(x)	(x->ces[DB_CE_NUM+0])
-#define host_ce(x)	(x->ces[DB_CE_NUM+1])
-#define user_ce(x)	(x->ces[DB_CE_NUM+2])
-#define pass_ce(x)	(x->ces[DB_CE_NUM+3])
-#define port_ce(x)	(x->ces[DB_CE_NUM+4])
-#define schema_ce(x)	(x->ces[DB_CE_NUM+5])
-#define dbtype_ce(x)	(x->ces[DB_CE_NUM+6])
+#define db_ce(x)	((x)->ces[DB_CE_NUM + 0])
+#define host_ce(x)	((x)->ces[DB_CE_NUM + 1])
+#define user_ce(x)	((x)->ces[DB_CE_NUM + 2])
+#define pass_ce(x)	((x)->ces[DB_CE_NUM + 3])
+#define port_ce(x)	((x)->ces[DB_CE_NUM + 4])
+#define schema_ce(x)	((x)->ces[DB_CE_NUM + 5])
+#define dbtype_ce(x)	((x)->ces[DB_CE_NUM + 6])
 
 
 /* find out which columns the table has */
diff --git a/output/ipfix/ulogd_output_IPFIX.c b/output/ipfix/ulogd_output_IPFIX.c
index 13d170108375..745d30a163b2 100644
--- a/output/ipfix/ulogd_output_IPFIX.c
+++ b/output/ipfix/ulogd_output_IPFIX.c
@@ -40,12 +40,12 @@ enum {
 	SEND_TEMPLATE_CE
 };
 
-#define oid_ce(x)		(x->ces[OID_CE])
-#define host_ce(x)		(x->ces[HOST_CE])
-#define port_ce(x)		(x->ces[PORT_CE])
-#define proto_ce(x)		(x->ces[PROTO_CE])
-#define mtu_ce(x)		(x->ces[MTU_CE])
-#define send_template_ce(x)	(x->ces[SEND_TEMPLATE_CE])
+#define oid_ce(x)		((x)->ces[OID_CE])
+#define host_ce(x)		((x)->ces[HOST_CE])
+#define port_ce(x)		((x)->ces[PORT_CE])
+#define proto_ce(x)		((x)->ces[PROTO_CE])
+#define mtu_ce(x)		((x)->ces[MTU_CE])
+#define send_template_ce(x)	((x)->ces[SEND_TEMPLATE_CE])
 
 static const struct config_keyset ipfix_kset = {
 	.num_ces = 6,
diff --git a/output/mysql/ulogd_output_MYSQL.c b/output/mysql/ulogd_output_MYSQL.c
index dc49a2ae4e5b..0b79a9cd270c 100644
--- a/output/mysql/ulogd_output_MYSQL.c
+++ b/output/mysql/ulogd_output_MYSQL.c
@@ -89,11 +89,11 @@ static struct config_keyset kset_mysql = {
 		},
 	},
 };
-#define db_ce(x)	(x->ces[DB_CE_NUM+0])
-#define	host_ce(x)	(x->ces[DB_CE_NUM+1])
-#define user_ce(x)	(x->ces[DB_CE_NUM+2])
-#define pass_ce(x)	(x->ces[DB_CE_NUM+3])
-#define port_ce(x)	(x->ces[DB_CE_NUM+4])
+#define db_ce(x)	((x)->ces[DB_CE_NUM + 0])
+#define host_ce(x)	((x)->ces[DB_CE_NUM + 1])
+#define user_ce(x)	((x)->ces[DB_CE_NUM + 2])
+#define pass_ce(x)	((x)->ces[DB_CE_NUM + 3])
+#define port_ce(x)	((x)->ces[DB_CE_NUM + 4])
 /* find out which columns the table has */
 static int get_columns_mysql(struct ulogd_pluginstance *upi)
 {
diff --git a/output/pgsql/ulogd_output_PGSQL.c b/output/pgsql/ulogd_output_PGSQL.c
index 1890cb574a95..7f215f0fee4c 100644
--- a/output/pgsql/ulogd_output_PGSQL.c
+++ b/output/pgsql/ulogd_output_PGSQL.c
@@ -74,13 +74,13 @@ static struct config_keyset pgsql_kset = {
 		},
 	},
 };
-#define db_ce(x)	(x->ces[DB_CE_NUM+0])
-#define host_ce(x)	(x->ces[DB_CE_NUM+1])
-#define user_ce(x)	(x->ces[DB_CE_NUM+2])
-#define pass_ce(x)	(x->ces[DB_CE_NUM+3])
-#define port_ce(x)	(x->ces[DB_CE_NUM+4])
-#define schema_ce(x)	(x->ces[DB_CE_NUM+5])
-#define connstr_ce(x)	(x->ces[DB_CE_NUM+6])
+#define db_ce(x)	((x)->ces[DB_CE_NUM + 0])
+#define host_ce(x)	((x)->ces[DB_CE_NUM + 1])
+#define user_ce(x)	((x)->ces[DB_CE_NUM + 2])
+#define pass_ce(x)	((x)->ces[DB_CE_NUM + 3])
+#define port_ce(x)	((x)->ces[DB_CE_NUM + 4])
+#define schema_ce(x)	((x)->ces[DB_CE_NUM + 5])
+#define connstr_ce(x)	((x)->ces[DB_CE_NUM + 6])
 
 #define PGSQL_HAVE_NAMESPACE_TEMPLATE 			\
 	"SELECT nspname FROM pg_namespace n WHERE n.nspname='%s'"
diff --git a/output/ulogd_output_GRAPHITE.c b/output/ulogd_output_GRAPHITE.c
index 28280b200544..22434707bcf9 100644
--- a/output/ulogd_output_GRAPHITE.c
+++ b/output/ulogd_output_GRAPHITE.c
@@ -79,9 +79,9 @@ static struct config_keyset graphite_kset = {
 	},
 };
 
-#define host_ce(x)	(x->ces[0])
-#define port_ce(x)	(x->ces[1])
-#define prefix_ce(x)	(x->ces[2])
+#define host_ce(x)	((x)->ces[0])
+#define port_ce(x)	((x)->ces[1])
+#define prefix_ce(x)	((x)->ces[2])
 
 struct graphite_instance {
 	int sck;
diff --git a/output/ulogd_output_JSON.c b/output/ulogd_output_JSON.c
index 59aab305e545..76b51b2afaa7 100644
--- a/output/ulogd_output_JSON.c
+++ b/output/ulogd_output_JSON.c
@@ -45,10 +45,10 @@
 #define ULOGD_JSON_DEFAULT_DEVICE "Netfilter"
 #endif
 
-#define host_ce(x)	(x->ces[JSON_CONF_HOST])
-#define port_ce(x)	(x->ces[JSON_CONF_PORT])
-#define mode_ce(x)	(x->ces[JSON_CONF_MODE])
-#define file_ce(x)	(x->ces[JSON_CONF_FILENAME])
+#define host_ce(x)	((x)->ces[JSON_CONF_HOST])
+#define port_ce(x)	((x)->ces[JSON_CONF_PORT])
+#define mode_ce(x)	((x)->ces[JSON_CONF_MODE])
+#define file_ce(x)	((x)->ces[JSON_CONF_FILENAME])
 #define unlikely(x) __builtin_expect((x),0)
 
 struct json_priv {
-- 
2.35.1


  parent reply	other threads:[~2022-11-29 21:48 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-29 21:47 [PATCH ulogd2 v2 v2 00/34] Refactor of the DB output plug-ins Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 01/34] ulogd: fix parse-error check Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 02/34] filter: fix buffer sizes in filter plug-ins Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 03/34] output: JSON: remove incorrect config value check Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 04/34] db: fix back-log capacity checks Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 05/34] build: add checks to configure.ac Jeremy Sowden
2022-11-30 10:04   ` Jan Engelhardt
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 06/34] src: remove some trailing white space Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 07/34] src: remove zero-valued config-key fields Jeremy Sowden
2022-11-30 10:21   ` Jan Engelhardt
2022-11-29 21:47 ` Jeremy Sowden [this message]
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 09/34] src: define constructors and destructors consistently Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 10/34] src: remove `TIME_ERR` macro Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 11/34] src: remove superfluous casts Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 12/34] conffile: replace malloc+strcpy with strdup Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 13/34] output: remove zero-initialized `struct ulogd_plugin` members Jeremy Sowden
2022-11-30 10:26   ` Jan Engelhardt
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 14/34] output: de-duplicate allocation of input keys Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 15/34] db: reorganize source Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 16/34] db: use consistent integer return values to indicate errors Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 17/34] db: change return type of two functions to `void` Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 18/34] db: open-code `_loop_reconnect_db` Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 19/34] db: improve calculation of sql statement length Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 20/34] db: refactor configuration Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 21/34] db: refactor ring-buffer initialization Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 22/34] db: refactor ring-buffer Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 23/34] db: refactor backlog Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 24/34] db: use `struct db_stmt` objects more widely Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 25/34] db: synchronize access to ring-buffer Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 26/34] db: avoid cancelling ring-buffer thread Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 27/34] db, IP2BIN: defer formatting of raw strings Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 28/34] db: add prep & exec support Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 29/34] output: mysql: " Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 30/34] output: pgsql: remove a couple of struct members Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 31/34] output: pgsql: remove variable-length arrays Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 32/34] output: pgsql: tidy up `open_db_pgsql` and fix memory leak Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 33/34] output: pgsql: add prep & exec support Jeremy Sowden
2022-11-29 21:47 ` [PATCH ulogd2 v2 v2 34/34] output: sqlite3: reimplement using the common DB API Jeremy Sowden
2022-11-30 10:27 ` [PATCH ulogd2 v2 v2 00/34] Refactor of the DB output plug-ins Pablo Neira Ayuso
2022-11-30 16:03   ` Jeremy Sowden

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221129214749.247878-9-jeremy@azazel.net \
    --to=jeremy@azazel.net \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).