Skip to content

Commit

Permalink
iio_info: Attempt to please Codacy
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Cercueil <[email protected]>
  • Loading branch information
pcercuei committed Nov 27, 2023
1 parent 77b9b31 commit 3d753e3
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions utils/iio_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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);

Expand All @@ -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);
}
Expand All @@ -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),
Expand All @@ -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");
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 3d753e3

Please sign in to comment.