Skip to content

Commit 313bf5b

Browse files
Shankari02hubcapsc
authored andcommitted
fs: orangefs: replace scnprintf() with sysfs_emit()
Documentation/filesystems/sysfs.rst mentions that show() should only use sysfs_emit() or sysfs_emit_at() when formating the value to be returned to user space. So replace scnprintf() with sysfs_emit(). Signed-off-by: Shankari Anand <[email protected]> Signed-off-by: Mike Marshall <[email protected]>
1 parent cdfa130 commit 313bf5b

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

fs/orangefs/orangefs-sysfs.c

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -217,36 +217,31 @@ static ssize_t sysfs_int_show(struct kobject *kobj,
217217

218218
if (!strcmp(kobj->name, ORANGEFS_KOBJ_ID)) {
219219
if (!strcmp(attr->attr.name, "op_timeout_secs")) {
220-
rc = scnprintf(buf,
221-
PAGE_SIZE,
220+
rc = sysfs_emit(buf,
222221
"%d\n",
223222
op_timeout_secs);
224223
goto out;
225224
} else if (!strcmp(attr->attr.name,
226225
"slot_timeout_secs")) {
227-
rc = scnprintf(buf,
228-
PAGE_SIZE,
226+
rc = sysfs_emit(buf,
229227
"%d\n",
230228
slot_timeout_secs);
231229
goto out;
232230
} else if (!strcmp(attr->attr.name,
233231
"cache_timeout_msecs")) {
234-
rc = scnprintf(buf,
235-
PAGE_SIZE,
232+
rc = sysfs_emit(buf,
236233
"%d\n",
237234
orangefs_cache_timeout_msecs);
238235
goto out;
239236
} else if (!strcmp(attr->attr.name,
240237
"dcache_timeout_msecs")) {
241-
rc = scnprintf(buf,
242-
PAGE_SIZE,
238+
rc = sysfs_emit(buf,
243239
"%d\n",
244240
orangefs_dcache_timeout_msecs);
245241
goto out;
246242
} else if (!strcmp(attr->attr.name,
247243
"getattr_timeout_msecs")) {
248-
rc = scnprintf(buf,
249-
PAGE_SIZE,
244+
rc = sysfs_emit(buf,
250245
"%d\n",
251246
orangefs_getattr_timeout_msecs);
252247
goto out;
@@ -256,14 +251,12 @@ static ssize_t sysfs_int_show(struct kobject *kobj,
256251

257252
} else if (!strcmp(kobj->name, STATS_KOBJ_ID)) {
258253
if (!strcmp(attr->attr.name, "reads")) {
259-
rc = scnprintf(buf,
260-
PAGE_SIZE,
254+
rc = sysfs_emit(buf,
261255
"%lu\n",
262256
orangefs_stats.reads);
263257
goto out;
264258
} else if (!strcmp(attr->attr.name, "writes")) {
265-
rc = scnprintf(buf,
266-
PAGE_SIZE,
259+
rc = sysfs_emit(buf,
267260
"%lu\n",
268261
orangefs_stats.writes);
269262
goto out;
@@ -497,19 +490,18 @@ static ssize_t sysfs_service_op_show(struct kobject *kobj,
497490
if (strcmp(kobj->name, PC_KOBJ_ID)) {
498491
if (new_op->upcall.req.param.op ==
499492
ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE) {
500-
rc = scnprintf(buf, PAGE_SIZE, "%d %d\n",
493+
rc = sysfs_emit(buf, "%d %d\n",
501494
(int)new_op->downcall.resp.param.u.
502495
value32[0],
503496
(int)new_op->downcall.resp.param.u.
504497
value32[1]);
505498
} else {
506-
rc = scnprintf(buf, PAGE_SIZE, "%d\n",
499+
rc = sysfs_emit(buf, "%d\n",
507500
(int)new_op->downcall.resp.param.u.value64);
508501
}
509502
} else {
510-
rc = scnprintf(
503+
rc = sysfs_emit(
511504
buf,
512-
PAGE_SIZE,
513505
"%s",
514506
new_op->downcall.resp.perf_count.buffer);
515507
}

0 commit comments

Comments
 (0)