From patchwork Sat Mar 15 06:16:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: xie.ludan@zte.com.cn X-Patchwork-Id: 14017738 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45C1D18DF89 for ; Sat, 15 Mar 2025 06:16:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=63.216.63.35 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742019409; cv=none; b=kCRDqHZ2qsgWTBhIF+7iCZSe6WRnL77KFQxXh5tf0Q0lkLAC86kcBM6RWh4Sz1JEuuJ3Ht7shmVcjPwH0eouRM0erELVIUXnsavlUC2EMJlr0lIi0kKLHUjywHZSJ9/EfAqUp0aAp9Qhmx9OnIc/XSlG7T9ABbdpENMhWXK4hAA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742019409; c=relaxed/simple; bh=583kABhI8raiQnwGKga+jZCC+lHUu/5HvgiUa9urVzA=; h=Date:Message-ID:Mime-Version:From:To:Cc:Subject:Content-Type; b=MuoU6ikhXPxbFS2X10xPp5neGqSQxwVkVmyVGuPfubpOFQe5whLepj/6b6ZZcQrjezncTPv1M3wrJXDetZuVyH5fg/wCJxjEne/4rcT5SDCL3JoE+KKB8KOqsFvpXPOXLM2cP52qSMlPXOcqmldRGXtvsoDGtFfW7qUNPfiBW1w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zte.com.cn; spf=pass smtp.mailfrom=zte.com.cn; arc=none smtp.client-ip=63.216.63.35 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zte.com.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zte.com.cn Received: from mse-fl1.zte.com.cn (unknown [10.5.228.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4ZF9xB6sDXz5B1J4; Sat, 15 Mar 2025 14:16:46 +0800 (CST) Received: from xaxapp04.zte.com.cn ([10.99.98.157]) by mse-fl1.zte.com.cn with SMTP id 52F6Gdbn011369; Sat, 15 Mar 2025 14:16:39 +0800 (+08) (envelope-from xie.ludan@zte.com.cn) Received: from mapi (xaxapp04[null]) by mapi (Zmail) with MAPI id mid32; Sat, 15 Mar 2025 14:16:40 +0800 (CST) Date: Sat, 15 Mar 2025 14:16:40 +0800 (CST) X-Zmail-TransId: 2afb67d51b4834b-61146 X-Mailer: Zmail v1.0 Message-ID: <20250315141640564lv7R0CwIRPsmittXXjLbB@zte.com.cn> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 From: To: Cc: , , , , , , , , Subject: =?utf-8?q?=5BPATCH_linux-next=5D_ocfs2=3A_use_sysfs=5Femit=28=29_in?= =?utf-8?q?stead_of_scnprintf=28=29=2E?= X-MAIL: mse-fl1.zte.com.cn 52F6Gdbn011369 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 67D51B4E.002/4ZF9xB6sDXz5B1J4 From: XieLudan Follow the advice in Documentation/filesystems/sysfs.rst: show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. Signed-off-by: XieLudan --- fs/ocfs2/cluster/heartbeat.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index 724350925aff..8282fc193906 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c @@ -1308,7 +1308,7 @@ static int o2hb_debug_open(struct inode *inode, struct file *file) case O2HB_DB_TYPE_REGION_NUMBER: reg = (struct o2hb_region *)db->db_data; - out += scnprintf(buf + out, PAGE_SIZE - out, "%d\n", + out += sysfs_emit(buf + out, "%d\n", reg->hr_region_num); goto done; @@ -1318,12 +1318,12 @@ static int o2hb_debug_open(struct inode *inode, struct file *file) /* If 0, it has never been set before */ if (lts) lts = jiffies_to_msecs(jiffies - lts); - out += scnprintf(buf + out, PAGE_SIZE - out, "%lu\n", lts); + out += sysfs_emit(buf + out, "%lu\n", lts); goto done; case O2HB_DB_TYPE_REGION_PINNED: reg = (struct o2hb_region *)db->db_data; - out += scnprintf(buf + out, PAGE_SIZE - out, "%u\n", + out += sysfs_emit(buf + out, "%u\n", !!reg->hr_item_pinned); goto done; @@ -1332,8 +1332,8 @@ static int o2hb_debug_open(struct inode *inode, struct file *file) } while ((i = find_next_bit(map, db->db_len, i + 1)) < db->db_len) - out += scnprintf(buf + out, PAGE_SIZE - out, "%d ", i); - out += scnprintf(buf + out, PAGE_SIZE - out, "\n"); + out += sysfs_emit(buf + out, "%d ", i); + out += sysfs_emit(buf + out, "\n"); done: i_size_write(inode, out);