Clean-up: lttng: logging: use ARRAY_SIZE macro
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 16 Feb 2021 20:47:28 +0000 (15:47 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 25 Feb 2021 20:20:27 +0000 (15:20 -0500)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id53ebe9e88bcb78c8f45fbfb38b577686aacd004

src/bin/lttng/loglevel.c

index 9f65df00664cbfb87fde03d551e5aa24dfbf3c49..ec82bfe11aeb85f278ea2d549eb302c0733b8f83 100644 (file)
@@ -11,8 +11,6 @@
 #include <ctype.h>
 #include <assert.h>
 
-#define LOGLEVEL_NAME_VALUE_ARRAY_COUNT(name) (sizeof(name) / sizeof(struct loglevel_name_value))
-
 struct loglevel_name_value {
        const char *name;
        int value;
@@ -150,7 +148,7 @@ LTTNG_HIDDEN
 int loglevel_name_to_value(const char *name, enum lttng_loglevel *loglevel)
 {
        int ret = lookup_value_from_name(loglevel_values,
-                       LOGLEVEL_NAME_VALUE_ARRAY_COUNT(loglevel_values), name);
+                       ARRAY_SIZE(loglevel_values), name);
 
        if (ret >= 0) {
                *loglevel = (typeof(*loglevel)) ret;
@@ -165,7 +163,7 @@ int loglevel_log4j_name_to_value(
                const char *name, enum lttng_loglevel_log4j *loglevel)
 {
        int ret = lookup_value_from_name(loglevel_log4j_values,
-                       LOGLEVEL_NAME_VALUE_ARRAY_COUNT(loglevel_log4j_values),
+                       ARRAY_SIZE(loglevel_log4j_values),
                        name);
 
        if (ret >= 0) {
@@ -181,7 +179,7 @@ int loglevel_jul_name_to_value(
                const char *name, enum lttng_loglevel_jul *loglevel)
 {
        int ret = lookup_value_from_name(loglevel_jul_values,
-                       LOGLEVEL_NAME_VALUE_ARRAY_COUNT(loglevel_jul_values),
+                       ARRAY_SIZE(loglevel_jul_values),
                        name);
 
        if (ret >= 0) {
@@ -197,7 +195,7 @@ int loglevel_python_name_to_value(
                const char *name, enum lttng_loglevel_python *loglevel)
 {
        int ret = lookup_value_from_name(loglevel_python_values,
-                       LOGLEVEL_NAME_VALUE_ARRAY_COUNT(loglevel_python_values),
+                       ARRAY_SIZE(loglevel_python_values),
                        name);
 
        if (ret >= 0) {
@@ -206,4 +204,4 @@ int loglevel_python_name_to_value(
        }
 
        return ret;
-}
\ No newline at end of file
+}
This page took 0.029282 seconds and 4 git commands to generate.