Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp648447yba; Thu, 18 Apr 2019 07:23:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqztJh3ZT+wwNciobjp7vUUAHMFOIabqeGL3axE0H4hkZ44T8/sHVXJyFn5TwVRBu9TNhJG/ X-Received: by 2002:a62:6504:: with SMTP id z4mr96854509pfb.202.1555597393895; Thu, 18 Apr 2019 07:23:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555597393; cv=none; d=google.com; s=arc-20160816; b=OBMrUjseyxphFDSVLs3/JNPYB8JXKDbmjyN4+/p3budnpQr8cI2ITj4xcG5C/A6AR2 R+GyiTcUKaGzHehuOQLas2XN+6pNBO2V/staILiZ+tRkyyKXcpCfTbYcSvE5itXjdtdB HW9Lc4xGz61xC3bP2x+3OoZM2qBmoCutlwSpk1ChDp34ROVN1ktJkMMH0xU17v8/xOWC aQvPqNm8OLftajURvLIkvDTdwqrZnkUzjq5jDOSL9BYI52SsIgE1Mw6EI0hVgq/9FUx0 qnO05ioxzFlXXQqtbGeYBpAxK46qLP4UdOMwpMiG6442kNN/ccFiys0KMqoyy8Ll4YvH gjqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date; bh=vbjBBEkvhymSO3G+ntvR9gGc/LdK60CS1WUan0WeHoM=; b=rEc3fw4Q6RS6QgfxLVIkL/vTMOXtTspP5a3IH7Z9qQitww79HStrOOoS/xE2w7NBlx D7TS5j3yPsTx72218YHAR7EiPkN06LK1aFhDP5dYzaSx+7qqpemYx43MRaOvrc/aQZHQ KT5bXytkw7WdnAb5m3TBcvYEN/dPeZ0b3FUT9hqj4CIqFWq+mYq0sUjIOCOjcJRjCsbG XXqq82LZCWNWMq6HrxlevTQBkAAzxrpkU5S5eMyJIcQTUQB4Bj4P11W0AkKYrtpVIRtV 5YqCuDDD6/x+ThwsUxNV+bP89XARB8xgKKiBAIrGmwQgh5R1js8DY/Nwo131lkJD+4wR p1QQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 74si1942701pgb.203.2019.04.18.07.22.57; Thu, 18 Apr 2019 07:23:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389284AbfDROVe (ORCPT + 99 others); Thu, 18 Apr 2019 10:21:34 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:50270 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S2389183AbfDROVd (ORCPT ); Thu, 18 Apr 2019 10:21:33 -0400 Received: (qmail 2927 invoked by uid 2102); 18 Apr 2019 10:21:32 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 18 Apr 2019 10:21:32 -0400 Date: Thu, 18 Apr 2019 10:21:32 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Greg Kroah-Hartman cc: Guenter Roeck , Raul Rangel , , Guenter Roeck , Oliver Neukum , Daniel Kurtz , , Sebastian Andrzej Siewior , Martin Blumenstingl , Dmitry Torokhov , linux-kernel , "Gustavo A. R. Silva" , Miquel Raynal , Johan Hovold , Mathias Nyman Subject: Re: [PATCH v3] usb/hcd: Send a uevent signaling that the host controller had died In-Reply-To: <20190418065141.GB12503@kroah.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 18 Apr 2019, Greg Kroah-Hartman wrote: > On Wed, Apr 17, 2019 at 04:20:09PM -0700, Guenter Roeck wrote: > > On Wed, Apr 17, 2019 at 3:41 PM Raul Rangel 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 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. > > Yeah, I went down this path a year or so ago and had to give it up as > well :( Well, the signature could still be changed as Guenter suggests. And the array being added in the new code could still be static. After all, there isn't really any danger that the contents of those strings will be modified, right? It's just that the const modifiers weren't put in until it was too late and there were too many existing callers. Perhaps a comment about this could be included in the kerneldoc for kobject_uevent_env. Alan Stern