[PATCH ulogd2 v2 v2 10/34] src: remove `TIME_ERR` macro

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The `TIME_ERR` macro is used to check the return value of time(2).
However, two of the definitions of it are never used.  The third is used
to check the return value of `time(NULL)`.  However, time(2) with a
`NULL` argument can never fail, so we don't need to perform the check.

Signed-off-by: Jeremy Sowden <jeremy@xxxxxxxxxx>
---
 include/ulogd/db.h                |  2 +-
 output/dbi/ulogd_output_DBI.c     |  1 -
 output/pgsql/ulogd_output_PGSQL.c |  1 -
 util/db.c                         | 14 ++++++--------
 4 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/include/ulogd/db.h b/include/ulogd/db.h
index 50925a69f240..a6fd25b4c043 100644
--- a/include/ulogd/db.h
+++ b/include/ulogd/db.h
@@ -62,7 +62,7 @@ struct db_instance {
 	unsigned char backlog_full;
 	struct llist_head backlog;
 };
-#define TIME_ERR		((time_t)-1)	/* Be paranoid */
+
 #define RECONNECT_DEFAULT	2
 #define MAX_ONESHOT_REQUEST	10
 #define RING_BUFFER_DEFAULT_SIZE	0
diff --git a/output/dbi/ulogd_output_DBI.c b/output/dbi/ulogd_output_DBI.c
index 7f42c08efc2b..88b530ead034 100644
--- a/output/dbi/ulogd_output_DBI.c
+++ b/output/dbi/ulogd_output_DBI.c
@@ -37,7 +37,6 @@ struct dbi_instance {
 	dbi_conn dbh;
 	dbi_result result;
 };
-#define TIME_ERR	((time_t)-1)
 
 /* our configuration directives */
 static struct config_keyset dbi_kset = {
diff --git a/output/pgsql/ulogd_output_PGSQL.c b/output/pgsql/ulogd_output_PGSQL.c
index a508f9cf75a1..b798555b5ade 100644
--- a/output/pgsql/ulogd_output_PGSQL.c
+++ b/output/pgsql/ulogd_output_PGSQL.c
@@ -34,7 +34,6 @@ struct pgsql_instance {
 	PGresult *pgres;
 	unsigned char pgsql_have_schemas;
 };
-#define TIME_ERR	((time_t)-1)
 
 /* our configuration directives */
 static struct config_keyset pgsql_kset = {
diff --git a/util/db.c b/util/db.c
index dab66216e07d..fb41266648d5 100644
--- a/util/db.c
+++ b/util/db.c
@@ -302,14 +302,12 @@ static int _init_reconnect(struct ulogd_pluginstance *upi)
 		if (time(NULL) < di->reconnect)
 			return -1;
 		di->reconnect = time(NULL);
-		if (di->reconnect != TIME_ERR) {
-			ulogd_log(ULOGD_ERROR, "no connection to database, "
-				  "attempting to reconnect after %u seconds\n",
-				  reconnect_ce(upi->config_kset).u.value);
-			di->reconnect += reconnect_ce(upi->config_kset).u.value;
-			di->interp = &_init_db;
-			return -1;
-		}
+		ulogd_log(ULOGD_ERROR,
+			  "no connection to database, attempting to reconnect after %u seconds\n",
+			  reconnect_ce(upi->config_kset).u.value);
+		di->reconnect += reconnect_ce(upi->config_kset).u.value;
+		di->interp = &_init_db;
+		return -1;
 	}
 
 	/* Disable plugin permanently */
-- 
2.35.1




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux