From dcf9ec030cb8fce9b9f228ac591f587c82ee15a8 Mon Sep 17 00:00:00 2001 From: Christoffer Sandberg Date: Fri, 18 Nov 2022 18:36:40 +0100 Subject: [PATCH] Fix list output whitespace --- src/uniwill_keyboard.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/uniwill_keyboard.h b/src/uniwill_keyboard.h index 95608df..e25c2ec 100644 --- a/src/uniwill_keyboard.h +++ b/src/uniwill_keyboard.h @@ -857,11 +857,17 @@ static ssize_t uw_charging_prios_available_show(struct device *child, struct device_attribute *attr, char *buffer) { - int i; - for (i = 0; i < ARRAY_SIZE(charging_prio_options); ++i) - sprintf(buffer + strlen(buffer), " %s", + int i, n; + n = ARRAY_SIZE(charging_prio_options); + for (i = 0; i < n; ++i) { + sprintf(buffer + strlen(buffer), "%s", charging_prio_options[i].descriptor); - sprintf(buffer + strlen(buffer), "\n"); + if (i < n - 1) + sprintf(buffer + strlen(buffer), " "); + else + sprintf(buffer + strlen(buffer), "\n"); + } + return strlen(buffer); }