linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukasz Luba <lukasz.luba@arm.com>
To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	rafael@kernel.org
Cc: daniel.lezcano@linaro.org, rjw@rjwysocki.net, lukasz.luba@arm.com
Subject: [PATCH] powercap: Adjust printing the constraint name with new line
Date: Mon,  9 Nov 2020 17:24:52 +0000	[thread overview]
Message-ID: <20201109172452.6923-1-lukasz.luba@arm.com> (raw)

The constraint name has limit of size 30, which sometimes might be hit.
When this happens the new line might be lost. Prevent this and set the
new line when the name string is too long."

Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
---
 drivers/powercap/powercap_sys.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/powercap/powercap_sys.c b/drivers/powercap/powercap_sys.c
index f808c5fa9838..575f9fdb810e 100644
--- a/drivers/powercap/powercap_sys.c
+++ b/drivers/powercap/powercap_sys.c
@@ -174,6 +174,10 @@ static ssize_t show_constraint_name(struct device *dev,
 								"%s\n", name);
 			buf[POWERCAP_CONSTRAINT_NAME_LEN] = '\0';
 			len = strlen(buf);
+
+			/* When the 'name' is too long, don't lose new line */
+			if (strlen(name) >= POWERCAP_CONSTRAINT_NAME_LEN)
+				buf[POWERCAP_CONSTRAINT_NAME_LEN - 1] = '\n';
 		}
 	}
 
-- 
2.17.1


             reply	other threads:[~2020-11-09 17:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-09 17:24 Lukasz Luba [this message]
2020-11-10 19:19 ` [PATCH] powercap: Adjust printing the constraint name with new line Rafael J. Wysocki
2020-11-17  9:22   ` Lukasz Luba
2020-11-17 12:51     ` Rafael J. Wysocki
2020-11-17 12:57       ` Lukasz Luba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201109172452.6923-1-lukasz.luba@arm.com \
    --to=lukasz.luba@arm.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=rjw@rjwysocki.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).