From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Subject: Re: [PATCH for-4.6 1/2] libxl: fix devd removal path Date: Wed, 23 Sep 2015 11:36:04 +0200 Message-ID: <56027284.4080703@citrix.com> References: <1442938993-94328-1-git-send-email-roger.pau@citrix.com> <1442938993-94328-2-git-send-email-roger.pau@citrix.com> <1442998016.10338.211.camel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZegTE-0001Ph-2t for xen-devel@lists.xenproject.org; Wed, 23 Sep 2015 09:36:12 +0000 In-Reply-To: <1442998016.10338.211.camel@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell , xen-devel@lists.xenproject.org Cc: Alex Velazquez , Wei Liu , Ian Jackson List-Id: xen-devel@lists.xenproject.org El 23/09/15 a les 10.46, Ian Campbell ha escrit: > On Tue, 2015-09-22 at 18:23 +0200, Roger Pau Monne wrote: >> >> - /* Check if event_path ends with "state" and truncate it */ >> - if (strlen(event_path) < strlen("state")) >> + /* Check if event_path ends with "state" or "online" and truncate it. */ >> + if (strlen(event_path) < strlen("state") || >> + strlen(event_path) < strlen("online")) > > This is the same as strlen(...) < strlen("state") (or more formaly < > min(strlen("state"),strlen("online")). > > Which is a bit dangerous because one might be tricked into thinking that > path - strlen("online") was safe to do after this check when it's not. (The > new code seems to have avoided this particular pattern which the old code > used though) With the new code this is no longer needed, so I'm tempted to just remove it. > I think I agree with Ian's suggestion to use strrchr. > > Alternatively you could register two watches on the two specific paths you > care about and point them at wrappers which trivially strip the appropriate > trailing text and pass the base onto the current code? > > BTW, what is watch_path passed to this function, is it not the watched path > i.e. the exact truncated event_path that you are looking for? Watch path is /local/domain//backend so we can get an event for any backend that is added to the domain. We could add specific watches once we have identified backends that the driver domain needs to serve, but it's going to make the code more complex and at this point in the release I don't think that's a good idea. Roger.