yanglint REFACTOR reduce NDEBUG macro usage
diff --git a/tools/lint/cmd.c b/tools/lint/cmd.c
index 344900d..8b2ec5d 100644
--- a/tools/lint/cmd.c
+++ b/tools/lint/cmd.c
@@ -96,12 +96,14 @@
"verb", cmd_verb_opt, cmd_verb_dep, cmd_verb_exec, NULL, cmd_verb_help, NULL,
"Change verbosity", "h"
},
-#ifndef NDEBUG
{
"debug", cmd_debug_opt, cmd_debug_dep, cmd_debug_store, cmd_debug_setlog, cmd_debug_help, NULL,
+#ifndef NDEBUG
"Display specific debug message groups", "h"
- },
+#else
+ "Unsupported for the Release build", "h"
#endif
+ },
{"quit", NULL, NULL, cmd_quit_exec, NULL, NULL, NULL, "Quit the program", "h"},
/* synonyms for previous commands */
{"?", NULL, NULL, cmd_help_exec, NULL, NULL, NULL, "Display commands description", "h"},
diff --git a/tools/lint/cmd.h b/tools/lint/cmd.h
index bd2f2f2..37894cb 100644
--- a/tools/lint/cmd.h
+++ b/tools/lint/cmd.h
@@ -79,9 +79,7 @@
CMD_EXTDATA,
CMD_CLEAR,
CMD_VERB,
-#ifndef NDEBUG
CMD_DEBUG,
-#endif
};
/**
diff --git a/tools/lint/cmd_debug.c b/tools/lint/cmd_debug.c
index 3661bfa..a1a8989 100644
--- a/tools/lint/cmd_debug.c
+++ b/tools/lint/cmd_debug.c
@@ -12,8 +12,6 @@
* https://opensource.org/licenses/BSD-3-Clause
*/
-#ifndef NDEBUG
-
#include "cmd.h"
#include <assert.h>
@@ -130,5 +128,3 @@
(void) ctx;
return ly_log_dbg_groups(yo->dbg_groups);
}
-
-#endif
diff --git a/tools/lint/completion.c b/tools/lint/completion.c
index 67c6b68..59207ca 100644
--- a/tools/lint/completion.c
+++ b/tools/lint/completion.c
@@ -378,7 +378,6 @@
get_arg_completion(hint, args, matches, match_count);
}
-#ifndef NDEBUG
/**
* @copydoc get_print_format_arg
*/
@@ -390,8 +389,6 @@
get_arg_completion(hint, args, matches, match_count);
}
-#endif
-
/**
* @brief Get the string before the hint, which autocompletion is for.
*
@@ -455,9 +452,7 @@
{CMD_LIST, NULL, NULL, get_list_format_arg},
{CMD_FEATURE, NULL, NULL, get_model_completion},
{CMD_VERB, NULL, NULL, get_verb_arg},
-#ifndef NDEBUG
{CMD_DEBUG, NULL, NULL, get_debug_arg},
-#endif
};
size_t name_len;
const char *last, *name, *getoptstr;
diff --git a/tools/lint/main_ni.c b/tools/lint/main_ni.c
index c08acc3..df0d6ff 100644
--- a/tools/lint/main_ni.c
+++ b/tools/lint/main_ni.c
@@ -211,12 +211,15 @@
printf(" -X, --extended-leafref\n"
" Allow usage of deref() XPath function within leafref\n\n");
-#ifndef NDEBUG
printf(" -G GROUPS, --debug=GROUPS\n"
+#ifndef NDEBUG
" Enable printing of specific debugging message group\n"
" (nothing will be printed unless verbosity is set to debug):\n"
- " <group>[,<group>]* (dict, xpath, dep-sets)\n\n");
+ " <group>[,<group>]* (dict, xpath, dep-sets)\n\n"
+#else
+ " Unsupported for the Release build\n\n"
#endif
+ );
}
static void
@@ -381,7 +384,6 @@
return 0;
}
-#ifndef NDEBUG
/**
* @brief Enable specific debugging messages.
*
@@ -417,8 +419,6 @@
return 0;
}
-#endif
-
/**
* @brief Process command line options and store the settings into the context.
*
@@ -459,9 +459,7 @@
{"yang-library", no_argument, NULL, 'y'},
{"yang-library-file", required_argument, NULL, 'Y'},
{"extended-leafref", no_argument, NULL, 'X'},
-#ifndef NDEBUG
- {"debug", required_argument, NULL, 'G'},
-#endif
+ {"debug", required_argument, NULL, 'G'},
{NULL, 0, NULL, 0}
};
uint8_t data_type_set = 0;
@@ -472,12 +470,7 @@
yo->line_length = 0;
opterr = 0;
-#ifndef NDEBUG
- while ((opt = getopt_long(argc, argv, "hvVQf:I:p:DF:iP:qs:neE:t:d:lL:o:O:R:myY:Xx:G:", options, &opt_index)) != -1)
-#else
- while ((opt = getopt_long(argc, argv, "hvVQf:I:p:DF:iP:qs:neE:t:d:lL:o:O:R:myY:Xx:", options, &opt_index)) != -1)
-#endif
- {
+ while ((opt = getopt_long(argc, argv, "hvVQf:I:p:DF:iP:qs:neE:t:d:lL:o:O:R:myY:Xx:G:", options, &opt_index)) != -1) {
switch (opt) {
case 'h': /* --help */
help(0);
@@ -657,14 +650,12 @@
yo->ctx_options |= LY_CTX_LEAFREF_EXTENDED;
break;
-#ifndef NDEBUG
case 'G': /* --debug */
if (set_debug_groups(optarg, yo)) {
return -1;
}
break;
- /* case 'G' */
-#endif
+
default:
YLMSG_E("Invalid option or missing argument: -%c.", optopt);
return -1;