summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2016-11-25 13:23:11 +1100
committerMartin Schwenke <martins@samba.org>2016-12-05 08:09:21 +0100
commit2650f37018e36a9d59046098e519a662d394950e (patch)
treeaecdf125f8c5da249cffc806dc14907e1ce0ebd6
parent9b7308b20295f1670c40d46aa087763698a3c1fa (diff)
downloadsamba-2650f37018e36a9d59046098e519a662d394950e.tar.gz
ctdb-logging: Drop enum debug_level
We are switching to Samba-style integer debug levels. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
-rw-r--r--ctdb/client/client.h4
-rw-r--r--ctdb/client/client_control_sync.c4
-rw-r--r--ctdb/common/logging.c30
-rw-r--r--ctdb/common/logging.h20
-rw-r--r--ctdb/protocol/protocol_api.h4
-rw-r--r--ctdb/protocol/protocol_client.c8
-rw-r--r--ctdb/server/ctdbd.c6
-rw-r--r--ctdb/tests/src/fake_ctdbd.c12
-rw-r--r--ctdb/tests/src/test_options.c4
-rw-r--r--ctdb/tools/ctdb.c6
-rw-r--r--ctdb/tools/ctdb_killtcp.c6
11 files changed, 42 insertions, 62 deletions
diff --git a/ctdb/client/client.h b/ctdb/client/client.h
index 3d6292c88a5..ea41cbece29 100644
--- a/ctdb/client/client.h
+++ b/ctdb/client/client.h
@@ -240,12 +240,12 @@ int ctdb_ctrl_getvnnmap(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
int ctdb_ctrl_getdebug(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
struct ctdb_client_context *client,
int destnode, struct timeval timeout,
- uint32_t *loglevel);
+ int *loglevel);
int ctdb_ctrl_setdebug(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
struct ctdb_client_context *client,
int destnode, struct timeval timeout,
- uint32_t loglevel);
+ int loglevel);
int ctdb_ctrl_get_dbmap(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
struct ctdb_client_context *client,
diff --git a/ctdb/client/client_control_sync.c b/ctdb/client/client_control_sync.c
index 07f23bfb638..ac453b0c608 100644
--- a/ctdb/client/client_control_sync.c
+++ b/ctdb/client/client_control_sync.c
@@ -183,7 +183,7 @@ int ctdb_ctrl_getvnnmap(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
int ctdb_ctrl_getdebug(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
struct ctdb_client_context *client,
int destnode, struct timeval timeout,
- uint32_t *loglevel)
+ int *loglevel)
{
struct ctdb_req_control request;
struct ctdb_reply_control *reply;
@@ -212,7 +212,7 @@ int ctdb_ctrl_getdebug(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
int ctdb_ctrl_setdebug(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
struct ctdb_client_context *client,
int destnode, struct timeval timeout,
- uint32_t loglevel)
+ int loglevel)
{
struct ctdb_req_control request;
struct ctdb_reply_control *reply;
diff --git a/ctdb/common/logging.c b/ctdb/common/logging.c
index 4b7b4e5f67d..921cc236e61 100644
--- a/ctdb/common/logging.c
+++ b/ctdb/common/logging.c
@@ -23,7 +23,7 @@
#include "common/logging.h"
struct {
- enum debug_level log_level;
+ int log_level;
const char *log_string;
} log_string_map[] = {
{ DEBUG_ERR, "ERROR" },
@@ -33,7 +33,7 @@ struct {
{ DEBUG_DEBUG, "DEBUG" },
};
-bool debug_level_parse(const char *log_string, enum debug_level *log_level)
+bool debug_level_parse(const char *log_string, int *log_level)
{
int i;
@@ -45,7 +45,7 @@ bool debug_level_parse(const char *log_string, enum debug_level *log_level)
int level = atoi(log_string);
if (level >= 0 && level < ARRAY_SIZE(log_string_map)) {
- *log_level = debug_level_from_int(level);
+ *log_level = level;
return true;
}
return false;
@@ -62,7 +62,7 @@ bool debug_level_parse(const char *log_string, enum debug_level *log_level)
return false;
}
-const char *debug_level_to_string(enum debug_level log_level)
+const char *debug_level_to_string(int log_level)
{
int i;
@@ -74,10 +74,10 @@ const char *debug_level_to_string(enum debug_level log_level)
return "UNKNOWN";
}
-enum debug_level debug_level_from_string(const char *log_string)
+int debug_level_from_string(const char *log_string)
{
bool found;
- enum debug_level log_level;
+ int log_level;
found = debug_level_parse(log_string, &log_level);
if (found) {
@@ -87,21 +87,3 @@ enum debug_level debug_level_from_string(const char *log_string)
/* Default debug level */
return DEBUG_ERR;
}
-
-int debug_level_to_int(enum debug_level log_level)
-{
- return (int)log_level;
-}
-
-enum debug_level debug_level_from_int(int level)
-{
- enum debug_level log_level;
-
- if (level >= 0 && level < ARRAY_SIZE(log_string_map)) {
- log_level = log_string_map[level].log_level;
- } else {
- log_level = DEBUG_ERR;
- }
-
- return log_level;
-}
diff --git a/ctdb/common/logging.h b/ctdb/common/logging.h
index 64b835c5a18..947edb54a9b 100644
--- a/ctdb/common/logging.h
+++ b/ctdb/common/logging.h
@@ -20,22 +20,18 @@
#ifndef __CTDB_LOGGING_H__
#define __CTDB_LOGGING_H__
-enum debug_level {
- DEBUG_ERR = 0,
- DEBUG_WARNING = 1,
- DEBUG_NOTICE = 2,
- DEBUG_INFO = 3,
- DEBUG_DEBUG = 4,
-};
+#define DEBUG_ERR 0
+#define DEBUG_WARNING 1
+#define DEBUG_NOTICE 2
+#define DEBUG_INFO 3
+#define DEBUG_DEBUG 4
/* These are used in many places, so define them here to avoid churn */
#define DEBUG_ALERT DEBUG_ERR
#define DEBUG_CRIT DEBUG_ERR
-bool debug_level_parse(const char *log_string, enum debug_level *log_level);
-const char *debug_level_to_string(enum debug_level log_level);
-enum debug_level debug_level_from_string(const char *log_string);
-int debug_level_to_int(enum debug_level log_level);
-enum debug_level debug_level_from_int(int log_int);
+bool debug_level_parse(const char *log_string, int *log_level);
+const char *debug_level_to_string(int log_level);
+int debug_level_from_string(const char *log_string);
#endif /* __CTDB_LOGGING_H__ */
diff --git a/ctdb/protocol/protocol_api.h b/ctdb/protocol/protocol_api.h
index d5d00da70f0..e438e1dfc72 100644
--- a/ctdb/protocol/protocol_api.h
+++ b/ctdb/protocol/protocol_api.h
@@ -204,10 +204,10 @@ int ctdb_reply_control_setvnnmap(struct ctdb_reply_control *reply);
void ctdb_req_control_get_debug(struct ctdb_req_control *request);
int ctdb_reply_control_get_debug(struct ctdb_reply_control *reply,
- uint32_t *debug_level);
+ int *debug_level);
void ctdb_req_control_set_debug(struct ctdb_req_control *request,
- uint32_t debug_level);
+ int debug_level);
int ctdb_reply_control_set_debug(struct ctdb_reply_control *reply);
void ctdb_req_control_get_dbmap(struct ctdb_req_control *request);
diff --git a/ctdb/protocol/protocol_client.c b/ctdb/protocol/protocol_client.c
index 14f3accf5ce..6eb6ede42cf 100644
--- a/ctdb/protocol/protocol_client.c
+++ b/ctdb/protocol/protocol_client.c
@@ -222,14 +222,14 @@ void ctdb_req_control_get_debug(struct ctdb_req_control *request)
}
int ctdb_reply_control_get_debug(struct ctdb_reply_control *reply,
- uint32_t *loglevel)
+ int *loglevel)
{
if (reply->rdata.opcode != CTDB_CONTROL_GET_DEBUG) {
return EPROTO;
}
if (reply->status == 0) {
- *loglevel = reply->rdata.data.loglevel;
+ *loglevel = (int)reply->rdata.data.loglevel;
}
return reply->status;
}
@@ -237,7 +237,7 @@ int ctdb_reply_control_get_debug(struct ctdb_reply_control *reply,
/* CTDB_CONTROL_SET_DEBUG */
void ctdb_req_control_set_debug(struct ctdb_req_control *request,
- uint32_t loglevel)
+ int loglevel)
{
request->opcode = CTDB_CONTROL_SET_DEBUG;
request->pad = 0;
@@ -246,7 +246,7 @@ void ctdb_req_control_set_debug(struct ctdb_req_control *request,
request->flags = 0;
request->rdata.opcode = CTDB_CONTROL_SET_DEBUG;
- request->rdata.data.loglevel = loglevel;
+ request->rdata.data.loglevel = (uint32_t)loglevel;
}
int ctdb_reply_control_set_debug(struct ctdb_reply_control *reply)
diff --git a/ctdb/server/ctdbd.c b/ctdb/server/ctdbd.c
index b0cbc8cd4e1..b054b7fb929 100644
--- a/ctdb/server/ctdbd.c
+++ b/ctdb/server/ctdbd.c
@@ -154,7 +154,7 @@ int main(int argc, const char *argv[])
const char **extra_argv;
poptContext pc;
struct tevent_context *ev;
- enum debug_level log_level;
+ int log_level;
pc = poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST);
@@ -200,9 +200,9 @@ int main(int argc, const char *argv[])
/* Set the debug level */
if (debug_level_parse(options.debuglevel, &log_level)) {
- DEBUGLEVEL = debug_level_to_int(log_level);
+ DEBUGLEVEL = log_level;
} else {
- DEBUGLEVEL = debug_level_to_int(DEBUG_NOTICE);
+ DEBUGLEVEL = DEBUG_NOTICE;
}
setenv("CTDB_SOCKET", options.socket, 1);
diff --git a/ctdb/tests/src/fake_ctdbd.c b/ctdb/tests/src/fake_ctdbd.c
index c27af4a4d7a..d1f1f137fc4 100644
--- a/ctdb/tests/src/fake_ctdbd.c
+++ b/ctdb/tests/src/fake_ctdbd.c
@@ -109,7 +109,7 @@ struct ctdbd_context {
struct timeval recovery_start_time;
struct timeval recovery_end_time;
bool takeover_disabled;
- enum debug_level log_level;
+ int log_level;
enum ctdb_runstate runstate;
struct ctdb_tunable_list tun_list;
int monitoring_mode;
@@ -1242,7 +1242,7 @@ static void control_get_debug(TALLOC_CTX *mem_ctx,
struct ctdb_reply_control reply;
reply.rdata.opcode = request->opcode;
- reply.rdata.data.loglevel = debug_level_to_int(ctdb->log_level);
+ reply.rdata.data.loglevel = (uint32_t)ctdb->log_level;
reply.status = 0;
reply.errmsg = NULL;
@@ -1259,7 +1259,7 @@ static void control_set_debug(TALLOC_CTX *mem_ctx,
struct ctdbd_context *ctdb = state->ctdb;
struct ctdb_reply_control reply;
- ctdb->log_level = debug_level_from_int(request->rdata.data.loglevel);
+ ctdb->log_level = (int)request->rdata.data.loglevel;
reply.rdata.opcode = request->opcode;
reply.status = 0;
@@ -3165,7 +3165,7 @@ int main(int argc, const char *argv[])
TALLOC_CTX *mem_ctx;
struct ctdbd_context *ctdb;
struct tevent_context *ev;
- enum debug_level debug_level;
+ int debug_level;
poptContext pc;
int opt, fd, ret, pfd[2];
ssize_t len;
@@ -3192,10 +3192,10 @@ int main(int argc, const char *argv[])
}
if (options.debuglevel == NULL) {
- DEBUGLEVEL = debug_level_to_int(DEBUG_ERR);
+ DEBUGLEVEL = DEBUG_ERR;
} else {
if (debug_level_parse(options.debuglevel, &debug_level)) {
- DEBUGLEVEL = debug_level_to_int(debug_level);
+ DEBUGLEVEL = debug_level;
} else {
fprintf(stderr, "Invalid debug level\n");
poptPrintHelp(pc, stdout, 0);
diff --git a/ctdb/tests/src/test_options.c b/ctdb/tests/src/test_options.c
index e28dcee2cff..847ec95766c 100644
--- a/ctdb/tests/src/test_options.c
+++ b/ctdb/tests/src/test_options.c
@@ -88,7 +88,7 @@ static void set_defaults_database(struct test_options *opts)
static bool verify_options_basic(struct test_options *opts)
{
- enum debug_level log_level;
+ int log_level;
bool status;
status = debug_level_parse(opts->debugstr, &log_level);
@@ -98,7 +98,7 @@ static bool verify_options_basic(struct test_options *opts)
return false;
}
- DEBUGLEVEL = debug_level_to_int(log_level);
+ DEBUGLEVEL = log_level;
return true;
}
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index 59719757df9..1a91d68e29e 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -2278,7 +2278,7 @@ static int control_enable_monitor(TALLOC_CTX *mem_ctx,
static int control_setdebug(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
int argc, const char **argv)
{
- enum debug_level log_level;
+ int log_level;
int ret;
bool found;
@@ -2307,7 +2307,7 @@ static int control_setdebug(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
static int control_getdebug(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
int argc, const char **argv)
{
- enum debug_level loglevel;
+ int loglevel;
const char *log_str;
int ret;
@@ -6468,7 +6468,7 @@ int main(int argc, const char *argv[])
int extra_argc;
const struct ctdb_cmd *cmd;
const char *ctdb_socket;
- enum debug_level loglevel;
+ int loglevel;
int ret;
setlinebuf(stdout);
diff --git a/ctdb/tools/ctdb_killtcp.c b/ctdb/tools/ctdb_killtcp.c
index 9739c2c6294..5db7ec7853b 100644
--- a/ctdb/tools/ctdb_killtcp.c
+++ b/ctdb/tools/ctdb_killtcp.c
@@ -347,7 +347,7 @@ int main(int argc, char **argv)
struct TALLOC_CONTEXT *mem_ctx = NULL;
struct ctdb_connection *conns = NULL;
const char *t;
- enum debug_level debug_level;
+ int debug_level;
bool done;
int num = 0;
int i, ret;
@@ -356,7 +356,9 @@ int main(int argc, char **argv)
t = getenv("CTDB_DEBUGLEVEL");
if (t != NULL) {
if (debug_level_parse(t, &debug_level)) {
- DEBUGLEVEL = debug_level_to_int(debug_level);
+ DEBUGLEVEL = debug_level;
+ } else {
+ DEBUGLEVEL = DEBUG_ERR;
}
}