sysfs: make sysfs_emit() return ssize_t

Message ID 33cd8f96-4b4f-4741-ac05-ef1bd267ce6b@p183
State New
Headers
Series sysfs: make sysfs_emit() return ssize_t |

Commit Message

Alexey Dobriyan Feb. 5, 2024, 10:11 a.m. UTC
  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(-)
  

Patch

--- 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;
 }