]> www.infradead.org Git - users/hch/misc.git/commitdiff
hpfs: Replace simple_strtoul with kstrtoint in hpfs_parse_param
authorSu Hui <suhui@nfschina.com>
Tue, 27 May 2025 09:00:08 +0000 (17:00 +0800)
committerMikulas Patocka <mpatocka@redhat.com>
Mon, 8 Sep 2025 15:23:34 +0000 (17:23 +0200)
kstrtoint() is better because simple_strtoul() ignores overflow and the
type of 'timeshift' is 'int' rather than 'unsigned long'. Using kstrtoint()
is more concise too.

Signed-off-by: Su Hui <suhui@nfschina.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
fs/hpfs/super.c

index 42b779b4d87f870bf44bcb0e13268c4411a5ed01..8ab85e7ac91eb67367017498243f713fa78df7a5 100644 (file)
@@ -404,15 +404,11 @@ static int hpfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
                break;
        case Opt_timeshift:
                {
-                       int m = 1;
                        char *rhs = param->string;
                        int timeshift;
 
-                       if (*rhs == '-') m = -1;
-                       if (*rhs == '+' || *rhs == '-') rhs++;
-                       timeshift = simple_strtoul(rhs, &rhs, 0) * m;
-                       if (*rhs)
-                                       return -EINVAL;
+                       if (kstrtoint(rhs, 0, &timeshift))
+                               return -EINVAL;
                        ctx->timeshift = timeshift;
                        break;
                }