[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABXOdTeR_91AnhmRoEvVQWMb7_ibWeSuLb=Hwsrnj-swCr7G_w@mail.gmail.com>
Date: Wed, 17 Apr 2019 16:20:09 -0700
From: Guenter Roeck <groeck@...gle.com>
To: Raul Rangel <rrangel@...omium.org>
Cc: Alan Stern <stern@...land.harvard.edu>, linux-usb@...r.kernel.org,
Guenter Roeck <groeck@...omium.org>,
Oliver Neukum <oneukum@...e.com>,
Daniel Kurtz <djkurtz@...omium.org>, zwisler@...omium.org,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Martin Blumenstingl <martin.blumenstingl@...glemail.com>,
Dmitry Torokhov <dtor@...omium.org>,
linux-kernel <linux-kernel@...r.kernel.org>,
"Gustavo A. R. Silva" <gustavo@...eddedor.com>,
Miquel Raynal <miquel.raynal@...tlin.com>,
Johan Hovold <johan@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Mathias Nyman <mathias.nyman@...ux.intel.com>
Subject: Re: [PATCH v3] usb/hcd: Send a uevent signaling that the host
controller had died
On Wed, Apr 17, 2019 at 3:41 PM Raul Rangel <rrangel@...omium.org> wrote:
>
> On Wed, Apr 17, 2019 at 03:23:52PM -0700, Guenter Roeck wrote:
> > On Wed, Apr 17, 2019 at 3:11 PM Raul Rangel <rrangel@...omium.org> wrote:
> > >
> > > On Wed, Apr 17, 2019 at 04:39:23PM -0400, Alan Stern wrote:
> > > >
> > > > This sounds like a golden opportunity! Submit a separate patch making
> > > > the parameter to kobject_uevent_env be const (actually const char *
> > > > const []), then submit this patch on top of that one.
> > > So there are other parts of the code base that dynamically create their
> > > array values. So by making the function take const, it breaks :(
> >
> > Confused. The calling code can still be non-const. I don't see the
> > parameter modified in kobject_uevent_env(), so declaring it const
> > should be possible. Can you give an example of code that no longer
> > works ?
> static int notify_user_space(struct thermal_zone_device *tz, int trip)
> {
> char *thermal_prop[5];
> int i;
>
> mutex_lock(&tz->lock);
> thermal_prop[0] = kasprintf(GFP_KERNEL, "NAME=%s", tz->type);
> thermal_prop[1] = kasprintf(GFP_KERNEL, "TEMP=%d", tz->temperature);
> thermal_prop[2] = kasprintf(GFP_KERNEL, "TRIP=%d", trip);
> thermal_prop[3] = kasprintf(GFP_KERNEL, "EVENT=%d", tz->notify_event);
> thermal_prop[4] = NULL;
> kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, thermal_prop);
> for (i = 0; i < 4; ++i)
> kfree(thermal_prop[i]);
> mutex_unlock(&tz->lock);
> return 0;
> }
>
> drivers/thermal/user_space.c:48:52: error: passing 'char *[5]' to parameter of type 'const char *const *' discards qualifiers in nested pointer types [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
> kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, thermal_prop);
> ^~~~~~~~~~~~
> include/linux/kobject.h:238:22: note: passing argument to parameter 'envp' here
> const char *const envp[]);
> ^
>
> http://c-faq.com/ansi/constmismatch.html explains why it fails.
>
Interesting. One never stops learning. So the best you could do would
be char * const envp[], but I guess that doesn't help much.
Guenter
> Raul
>
> >
> > Thanks,
> > Guenter
> >
> > > >
> > > > Alan Stern
> > > >
Powered by blists - more mailing lists