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

ocfs2: replace deprecated simple_strtol with kstrtol

simple_strtol() ignores overflows and has an awkward interface for error
checking. Replace with the recommended kstrtol function leads to clearer
error checking and safer conversions.

Link: https://lkml.kernel.org/r/20241115080018.5372-1-danielyangkang@gmail.com
Signed-off-by: Daniel Yang <danielyangkang@gmail.com>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Jun Piao <piaojun@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Daniel Yang and committed by
Andrew Morton
876a5b25 a0f8a9a9

+3 -2
+3 -2
fs/ocfs2/cluster/heartbeat.c
··· 3 3 * Copyright (C) 2004, 2005 Oracle. All rights reserved. 4 4 */ 5 5 6 + #include "linux/kstrtox.h" 6 7 #include <linux/kernel.h> 7 8 #include <linux/sched.h> 8 9 #include <linux/jiffies.h> ··· 1779 1778 if (o2nm_this_node() == O2NM_MAX_NODES) 1780 1779 return -EINVAL; 1781 1780 1782 - fd = simple_strtol(p, &p, 0); 1783 - if (!p || (*p && (*p != '\n'))) 1781 + ret = kstrtol(p, 0, &fd); 1782 + if (ret < 0) 1784 1783 return -EINVAL; 1785 1784 1786 1785 if (fd < 0 || fd >= INT_MAX)