From: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
To: srinivas.pandruvada@linux.intel.com, hansg@kernel.org,
ilpo.jarvinen@linux.intel.com
Cc: platform-driver-x86@vger.kernel.org,
Kaushlendra Kumar <kaushlendra.kumar@intel.com>
Subject: [PATCH 2/2] platform/x86/intel/uncore-freq: Replace sprintf() with sysfs_emit()
Date: Tue, 30 Dec 2025 13:35:45 +0530 [thread overview]
Message-ID: <20251230080545.224954-3-kaushlendra.kumar@intel.com> (raw)
In-Reply-To: <20251230080545.224954-1-kaushlendra.kumar@intel.com>
Replace sprintf() with sysfs_emit() in sysfs show functions. The
sysfs_emit() function is the preferred way to format sysfs output as
it ensures proper buffer bounds checking and correct return values.
Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
---
.../x86/intel/uncore-frequency/uncore-frequency-common.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
index c129dd450360..ff97e3d210ab 100644
--- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
+++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
@@ -26,21 +26,21 @@ static ssize_t show_domain_id(struct kobject *kobj, struct kobj_attribute *attr,
{
struct uncore_data *data = container_of(attr, struct uncore_data, domain_id_kobj_attr);
- return sprintf(buf, "%u\n", data->domain_id);
+ return sysfs_emit(buf, "%u\n", data->domain_id);
}
static ssize_t show_fabric_cluster_id(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
{
struct uncore_data *data = container_of(attr, struct uncore_data, fabric_cluster_id_kobj_attr);
- return sprintf(buf, "%u\n", data->cluster_id);
+ return sysfs_emit(buf, "%u\n", data->cluster_id);
}
static ssize_t show_package_id(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
{
struct uncore_data *data = container_of(attr, struct uncore_data, package_id_kobj_attr);
- return sprintf(buf, "%u\n", data->package_id);
+ return sysfs_emit(buf, "%u\n", data->package_id);
}
#define MAX_UNCORE_AGENT_TYPES 4
@@ -77,7 +77,7 @@ static ssize_t show_attr(struct uncore_data *data, char *buf, enum uncore_index
if (ret)
return ret;
- return sprintf(buf, "%u\n", value);
+ return sysfs_emit(buf, "%u\n", value);
}
static ssize_t store_attr(struct uncore_data *data, const char *buf, ssize_t count,
--
2.34.1
prev parent reply other threads:[~2025-12-30 8:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-30 8:05 [PATCH 0/2] platform/x86/intel/uncore-freq: String handling improvements Kaushlendra Kumar
2025-12-30 8:05 ` [PATCH 1/2] platform/x86/intel/uncore-freq: Replace sprintf() with snprintf() Kaushlendra Kumar
2025-12-30 10:48 ` Ilpo Järvinen
2025-12-30 12:45 ` Kumar, Kaushlendra
2025-12-30 8:05 ` Kaushlendra Kumar [this message]
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=20251230080545.224954-3-kaushlendra.kumar@intel.com \
--to=kaushlendra.kumar@intel.com \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=srinivas.pandruvada@linux.intel.com \
/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