Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <shankari.ak0208@gmail.com>
Signed-off-by: Mike Marshall <hubcap@omnibond.com>

authored by

Shankari Anand and committed by
Mike Marshall
313bf5b7 cdfa1304

+10 -18
+10 -18
fs/orangefs/orangefs-sysfs.c
··· 217 217 218 218 if (!strcmp(kobj->name, ORANGEFS_KOBJ_ID)) { 219 219 if (!strcmp(attr->attr.name, "op_timeout_secs")) { 220 - rc = scnprintf(buf, 221 - PAGE_SIZE, 220 + rc = sysfs_emit(buf, 222 221 "%d\n", 223 222 op_timeout_secs); 224 223 goto out; 225 224 } else if (!strcmp(attr->attr.name, 226 225 "slot_timeout_secs")) { 227 - rc = scnprintf(buf, 228 - PAGE_SIZE, 226 + rc = sysfs_emit(buf, 229 227 "%d\n", 230 228 slot_timeout_secs); 231 229 goto out; 232 230 } else if (!strcmp(attr->attr.name, 233 231 "cache_timeout_msecs")) { 234 - rc = scnprintf(buf, 235 - PAGE_SIZE, 232 + rc = sysfs_emit(buf, 236 233 "%d\n", 237 234 orangefs_cache_timeout_msecs); 238 235 goto out; 239 236 } else if (!strcmp(attr->attr.name, 240 237 "dcache_timeout_msecs")) { 241 - rc = scnprintf(buf, 242 - PAGE_SIZE, 238 + rc = sysfs_emit(buf, 243 239 "%d\n", 244 240 orangefs_dcache_timeout_msecs); 245 241 goto out; 246 242 } else if (!strcmp(attr->attr.name, 247 243 "getattr_timeout_msecs")) { 248 - rc = scnprintf(buf, 249 - PAGE_SIZE, 244 + rc = sysfs_emit(buf, 250 245 "%d\n", 251 246 orangefs_getattr_timeout_msecs); 252 247 goto out; ··· 251 256 252 257 } else if (!strcmp(kobj->name, STATS_KOBJ_ID)) { 253 258 if (!strcmp(attr->attr.name, "reads")) { 254 - rc = scnprintf(buf, 255 - PAGE_SIZE, 259 + rc = sysfs_emit(buf, 256 260 "%lu\n", 257 261 orangefs_stats.reads); 258 262 goto out; 259 263 } else if (!strcmp(attr->attr.name, "writes")) { 260 - rc = scnprintf(buf, 261 - PAGE_SIZE, 264 + rc = sysfs_emit(buf, 262 265 "%lu\n", 263 266 orangefs_stats.writes); 264 267 goto out; ··· 490 497 if (strcmp(kobj->name, PC_KOBJ_ID)) { 491 498 if (new_op->upcall.req.param.op == 492 499 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE) { 493 - rc = scnprintf(buf, PAGE_SIZE, "%d %d\n", 500 + rc = sysfs_emit(buf, "%d %d\n", 494 501 (int)new_op->downcall.resp.param.u. 495 502 value32[0], 496 503 (int)new_op->downcall.resp.param.u. 497 504 value32[1]); 498 505 } else { 499 - rc = scnprintf(buf, PAGE_SIZE, "%d\n", 506 + rc = sysfs_emit(buf, "%d\n", 500 507 (int)new_op->downcall.resp.param.u.value64); 501 508 } 502 509 } else { 503 - rc = scnprintf( 510 + rc = sysfs_emit( 504 511 buf, 505 - PAGE_SIZE, 506 512 "%s", 507 513 new_op->downcall.resp.perf_count.buffer); 508 514 }