lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250315141640564lv7R0CwIRPsmittXXjLbB@zte.com.cn>
Date: Sat, 15 Mar 2025 14:16:40 +0800 (CST)
From: <xie.ludan@....com.cn>
To: <mark@...heh.com>
Cc: <jlbec@...lplan.org>, <joseph.qi@...ux.alibaba.com>,
        <akpm@...ux-foundation.org>, <viro@...iv.linux.org.uk>,
        <brauner@...nel.org>, <danielyangkang@...il.com>,
        <dmantipov@...dex.ru>, <ocfs2-devel@...ts.linux.dev>,
        <linux-kernel@...r.kernel.org>
Subject: [PATCH linux-next] ocfs2: use sysfs_emit() instead of scnprintf().

From: XieLudan <xie.ludan@....com.cn>

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 <xie.ludan@....com.cn>
---
 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);
-- 
2.25.1
<div class="zcontentRow"><p><span style="font-family: Arial, Helvetica, &quot;Microsoft Yahei&quot;, sans-serif; background-color: rgb(255, 255, 255);">From: XieLudan &lt;xie.ludan@....com.cn&gt;</span></p><p><br></p><p>Follow the advice in Documentation/filesystems/sysfs.rst:</p><p>show() should only use sysfs_emit() or sysfs_emit_at() when formatting</p><p>the value to be returned to user space.</p><p><br></p><p>Signed-off-by: XieLudan &lt;xie.ludan@....com.cn&gt;</p><p>---</p><p>&nbsp;fs/ocfs2/cluster/heartbeat.c | 10 +++++-----</p><p>&nbsp;1 file changed, 5 insertions(+), 5 deletions(-)</p><p><br></p><p>diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c</p><p>index 724350925aff..8282fc193906 100644</p><p>--- a/fs/ocfs2/cluster/heartbeat.c</p><p>+++ b/fs/ocfs2/cluster/heartbeat.c</p><p>@@ -1308,7 +1308,7 @@ static int o2hb_debug_open(struct inode *inode, struct file *file)</p><p>&nbsp;</p><p>&nbsp;<span style="white-space:pre">	</span>case O2HB_DB_TYPE_REGION_NUMBER:</p><p>&nbsp;<span style="white-space:pre">		</span>reg = (struct o2hb_region *)db-&gt;db_data;</p><p>-<span style="white-space:pre">		</span>out += scnprintf(buf + out, PAGE_SIZE - out, "%d\n",</p><p>+<span style="white-space:pre">		</span>out += sysfs_emit(buf + out, "%d\n",</p><p>&nbsp;<span style="white-space:pre">				</span>reg-&gt;hr_region_num);</p><p>&nbsp;<span style="white-space:pre">		</span>goto done;</p><p>&nbsp;</p><p>@@ -1318,12 +1318,12 @@ static int o2hb_debug_open(struct inode *inode, struct file *file)</p><p>&nbsp;<span style="white-space:pre">		</span>/* If 0, it has never been set before */</p><p>&nbsp;<span style="white-space:pre">		</span>if (lts)</p><p>&nbsp;<span style="white-space:pre">			</span>lts = jiffies_to_msecs(jiffies - lts);</p><p>-<span style="white-space:pre">		</span>out += scnprintf(buf + out, PAGE_SIZE - out, "%lu\n", lts);</p><p>+<span style="white-space:pre">		</span>out += sysfs_emit(buf + out, "%lu\n", lts);</p><p>&nbsp;<span style="white-space:pre">		</span>goto done;</p><p>&nbsp;</p><p>&nbsp;<span style="white-space:pre">	</span>case O2HB_DB_TYPE_REGION_PINNED:</p><p>&nbsp;<span style="white-space:pre">		</span>reg = (struct o2hb_region *)db-&gt;db_data;</p><p>-<span style="white-space:pre">		</span>out += scnprintf(buf + out, PAGE_SIZE - out, "%u\n",</p><p>+<span style="white-space:pre">		</span>out += sysfs_emit(buf + out, "%u\n",</p><p>&nbsp;<span style="white-space:pre">				</span>!!reg-&gt;hr_item_pinned);</p><p>&nbsp;<span style="white-space:pre">		</span>goto done;</p><p>&nbsp;</p><p>@@ -1332,8 +1332,8 @@ static int o2hb_debug_open(struct inode *inode, struct file *file)</p><p>&nbsp;<span style="white-space:pre">	</span>}</p><p>&nbsp;</p><p>&nbsp;<span style="white-space:pre">	</span>while ((i = find_next_bit(map, db-&gt;db_len, i + 1)) &lt; db-&gt;db_len)</p><p>-<span style="white-space:pre">		</span>out += scnprintf(buf + out, PAGE_SIZE - out, "%d ", i);</p><p>-<span style="white-space:pre">	</span>out += scnprintf(buf + out, PAGE_SIZE - out, "\n");</p><p>+<span style="white-space:pre">		</span>out += sysfs_emit(buf + out, "%d ", i);</p><p>+<span style="white-space:pre">	</span>out += sysfs_emit(buf + out, "\n");</p><p>&nbsp;</p><p>&nbsp;done:</p><p>&nbsp;<span style="white-space:pre">	</span>i_size_write(inode, out);</p><p>--&nbsp;</p><p>2.25.1</p><p style="font-size:14px;font-family:微软雅黑,Microsoft YaHei;"><br></p><p style="font-size:14px;font-family:微软雅黑,Microsoft YaHei;"><br></p><p style="font-size:14px;font-family:微软雅黑,Microsoft YaHei;"><br></p><p style="font-size:14px;font-family:微软雅黑,Microsoft YaHei;"><br></p></div>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ