Skip to content

Commit 67d0a07

Browse files
JoePerchestorvalds
authored andcommitted
kernel.h/checkpatch: mark strict_strto<foo> and simple_strto<foo> as obsolete
Mark obsolete/deprecated strict_strto<foo> and simple_strto<foo> functions and macros as obsolete. Update checkpatch to warn about their use. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent fc23af3 commit 67d0a07

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

include/linux/kernel.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ static inline int __must_check kstrtos32_from_user(const char __user *s, size_t
287287
return kstrtoint_from_user(s, count, base, res);
288288
}
289289

290+
/* Obsolete, do not use. Use kstrto<foo> instead */
291+
290292
extern unsigned long simple_strtoul(const char *,char **,unsigned int);
291293
extern long simple_strtol(const char *,char **,unsigned int);
292294
extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
@@ -296,6 +298,8 @@ extern long long simple_strtoll(const char *,char **,unsigned int);
296298
#define strict_strtoull kstrtoull
297299
#define strict_strtoll kstrtoll
298300

301+
/* lib/printf utilities */
302+
299303
extern __printf(2, 3) int sprintf(char *buf, const char * fmt, ...);
300304
extern __printf(2, 0) int vsprintf(char *buf, const char *, va_list);
301305
extern __printf(3, 4)

scripts/checkpatch.pl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3151,10 +3151,10 @@ sub process {
31513151
"consider using a completion\n" . $herecurr);
31523152

31533153
}
3154-
# recommend kstrto* over simple_strto*
3155-
if ($line =~ /\bsimple_(strto.*?)\s*\(/) {
3154+
# recommend kstrto* over simple_strto* and strict_strto*
3155+
if ($line =~ /\b((simple|strict)_(strto(l|ll|ul|ull)))\s*\(/) {
31563156
WARN("CONSIDER_KSTRTO",
3157-
"consider using kstrto* in preference to simple_$1\n" . $herecurr);
3157+
"$1 is obsolete, use k$3 instead\n" . $herecurr);
31583158
}
31593159
# check for __initcall(), use device_initcall() explicitly please
31603160
if ($line =~ /^.\s*__initcall\s*\(/) {

0 commit comments

Comments
 (0)