From: Alexey Dobriyan <adobriyan@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>, linux-kernel@vger.kernel.org
Subject: [PATCH] sysfs: make sysfs_emit() return ssize_t
Date: Mon, 5 Feb 2024 13:11:36 +0300 [thread overview]
Message-ID: <33cd8f96-4b4f-4741-ac05-ef1bd267ce6b@p183> (raw)
sysfs_emit() is most often found in functions returning ssize_t
not int:
static ssize_t oops_count_show(...)
{
return sysfs_emit(page, ...);
}
This pattern results in sign-extension instruction between
sysfs_emit() return value (int) and caller return value (which is
ssize_t).
But it is better to do sign-extension once inside sysfs_emit()
then duplicate it at nearly every call site on 64-bit.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
fs/sysfs/file.c | 2 +-
include/linux/sysfs.h | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -739,7 +739,7 @@ EXPORT_SYMBOL_GPL(sysfs_change_owner);
*
* Returns number of characters written to @buf.
*/
-int sysfs_emit(char *buf, const char *fmt, ...)
+ssize_t sysfs_emit(char *buf, const char *fmt, ...)
{
va_list args;
int len;
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -356,7 +356,7 @@ int sysfs_group_change_owner(struct kobject *kobj,
const struct attribute_group *groups, kuid_t kuid,
kgid_t kgid);
__printf(2, 3)
-int sysfs_emit(char *buf, const char *fmt, ...);
+ssize_t sysfs_emit(char *buf, const char *fmt, ...);
__printf(3, 4)
int sysfs_emit_at(char *buf, int at, const char *fmt, ...);
@@ -607,7 +607,7 @@ static inline int sysfs_group_change_owner(struct kobject *kobj,
}
__printf(2, 3)
-static inline int sysfs_emit(char *buf, const char *fmt, ...)
+static inline ssize_t sysfs_emit(char *buf, const char *fmt, ...)
{
return 0;
}
next reply other threads:[~2024-02-05 10:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-05 10:11 Alexey Dobriyan [this message]
2024-03-07 22:04 ` Greg Kroah-Hartman
2024-03-08 6:26 ` Alexey Dobriyan
2024-03-08 9:01 ` Greg Kroah-Hartman
2024-03-10 19:21 ` David Laight
2024-03-11 4:55 ` Alexey Dobriyan
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=33cd8f96-4b4f-4741-ac05-ef1bd267ce6b@p183 \
--to=adobriyan@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
/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
all inboxes | Powered by JetHome®