Re: Writing to a const pointer: is this supposed to happen?

Pavel Machek
2020-06-23T19:55:24Z

[-- Attachment #1: Type: text/plain, Size: 1128 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]