Re: [PATCH] Staging: most: fix coding style issues

From: Joe Perches
Date: Sat Jun 29 2019 - 20:00:36 EST


On Sat, 2019-06-29 at 16:44 -0700, Gabriel Beauchamp wrote:
> This is a patch for the core.[ch] files that fixes up warnings
> found with the checkpatch.pl tool.
[]
> diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
[]
> @@ -303,7 +303,8 @@ static ssize_t set_datatype_show(struct device *dev,
>
> for (i = 0; i < ARRAY_SIZE(ch_data_type); i++) {
> if (c->cfg.data_type & ch_data_type[i].most_ch_data_type)
> - return snprintf(buf, PAGE_SIZE, "%s", ch_data_type[i].name);
> + return snprintf(buf, PAGE_SIZE,
> + "%s", ch_data_type[i].name);
> }
> return snprintf(buf, PAGE_SIZE, "unconfigured\n");
> }

Assuming the newline difference is unintentional,
(if not change "unconfigured" to "unconfigured\n")

How about using a single sprintf and reducing object code size too?

char *type = "unconfigured";

for (...)
if (c-> etc...) {
type = ch_data_type[i].name;
break;
}
}

return snprintf(buf, PAGE_SIZE, "%s", type);