Re: [PATCH] mmc: core: convert simple_stroul to kstroul

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 03, 2024 at 02:37:25PM +0200, Ulf Hansson wrote:
> On Sun, 1 Sept 2024 at 20:22, Riyan Dhiman <riyandhiman14@xxxxxxxxx> wrote:
> >
> > simple_strtoul() is obsolete and lacks proper error handling, making it
> > unsafe for converting strings to unsigned long values. Replace it with
> > kstrtoul(), which provides robust error checking and better safety.
> >
> > This change improves the reliability of the string-to-integer conversion
> > and aligns with current kernel coding standards. Error handling is added
> > to catch conversion failures, returning -EINVAL when input is invalid.
> >
> > Issue reported by checkpatch:
> > - WARNING: simple_strtoul is obsolete, use kstrtoul instead

In rare cases this is a false positive, here seems to be okay.

...

> > +       if (kstrtoul(buf, 0, &set)) {
> >                 ret = -EINVAL;
> >                 goto out;
> >         }

Now you shadow the error code of kstrtox(), this has to be as simple as

       ret = kstrtoul(buf, 0, &set);
       if (ret)
               goto out;

-- 
With Best Regards,
Andy Shevchenko






[Index of Archives]     [Linux Memonry Technology]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux