[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200623195520.GA24965@duo.ucw.cz>
Date: Tue, 23 Jun 2020 21:55:20 +0200
From: Pavel Machek <pavel@....cz>
To: Kars Mulder <kerneldev@...smulder.nl>
Cc: linux-kernel@...r.kernel.org
Subject: Re: Writing to a const pointer: is this supposed to happen?
On Mon 2020-06-22 13:35:35, Kars Mulder wrote:
> In the file drivers/usb/core/quirks.c, I noticed a couple of odd things about the function "quirks_param_set", and I'd like to check whether those are ok according to the kernel programming practices. Here are the relevant lines from the function (several lines omitted):
>
> static int quirks_param_set(const char *val, const struct kernel_param *kp) {
> char *p, *field;
> for (i = 0, p = (char *)val; p && *p;) {
> field = strsep(&p, ":");
> if (!field)
> break;
>
> In here a const pointer *val is cast into a non-const pointer and then written to by the function strsep, which replaces the first occurrence of the ':' token by a null-byte. Is this allowed?
>
Odd, indeed... but not likely to cause immediate problems.
You may want to cc relevant maintainers, or even run git
blame and contact author.
You may also want to wrap your lines at 72 characters or so.
Best regards,
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Download attachment "signature.asc" of type "application/pgp-signature" (196 bytes)
Powered by blists - more mailing lists