From 3d753e35f0f63255e5f5857e7633f90fda1f4946 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Mon, 27 Nov 2023 18:16:50 +0100 Subject: [PATCH] iio_info: Attempt to please Codacy Signed-off-by: Paul Cercueil --- utils/iio_info.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/utils/iio_info.c b/utils/iio_info.c index 0dfc17cee..740355df2 100644 --- a/utils/iio_info.c +++ b/utils/iio_info.c @@ -65,6 +65,8 @@ static bool colors; #define FMT_CHN "\e[0;33m%s\e[0m" #define FMT_ATTR "\e[1;34m%s\e[0m" +#define print_fmt(fmt, ...) printf(fmt, __VA_ARGS__) /* Flawfinder: ignore */ + static void print_attr(const struct iio_attr *attr, unsigned int level, unsigned int idx) { @@ -88,7 +90,7 @@ static void print_attr(const struct iio_attr *attr, fn = iio_attr_get_filename(attr); if (colors) - printf(FMT_ATTR, name); + print_fmt(FMT_ATTR, name); else printf("%s", name); @@ -98,7 +100,7 @@ static void print_attr(const struct iio_attr *attr, if (ret >= 0) printf(" value: %s\n", value); else if (colors) - printf(" value: " FMT_ERR "\n", value); + print_fmt(" value: " FMT_ERR "\n", value); else printf(" value: ERROR: %s\n", value); } @@ -116,9 +118,9 @@ static void print_channel(const struct iio_channel *chn) name = iio_channel_get_name(chn); if (colors) { - printf("\t\t\t" FMT_CHN ": " FMT_CHN " (" FMT_CHN, - iio_channel_get_id(chn), - name ? name : "", type_name); + print_fmt("\t\t\t" FMT_CHN ": " FMT_CHN " (" FMT_CHN, + iio_channel_get_id(chn), + name ? name : "", type_name); } else { printf("\t\t\t%s: %s (%s", iio_channel_get_id(chn), @@ -127,7 +129,7 @@ static void print_channel(const struct iio_channel *chn) if (iio_channel_get_type(chn) == IIO_CHAN_TYPE_UNKNOWN) { if (colors) - printf(", " FMT_ERR, "iio_channel_get_type() = UNKNOWN"); + print_fmt(", " FMT_ERR, "iio_channel_get_type() = UNKNOWN"); else printf(", ERROR: iio_channel_get_type() = UNKNOWN"); } @@ -245,12 +247,12 @@ int main(int argc, char **argv) stream = iio_device_create_event_stream(dev); if (colors) - printf("\t" FMT_DEV ":", iio_device_get_id(dev)); + print_fmt("\t" FMT_DEV ":", iio_device_get_id(dev)); else printf("\t%s:", iio_device_get_id(dev)); if (name) { if (colors) - printf(" " FMT_DEV, name); + print_fmt(" " FMT_DEV, name); else printf(" %s", name); }