From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Guo, Jia" Subject: Re: [PATCH v6 1/2] eal: add uevent monitor for hot plug Date: Wed, 8 Nov 2017 05:39:54 +0000 Message-ID: <01BA8470C017D6468C8290E4B9C5E1E83B2A7073@shsmsx102.ccr.corp.intel.com> References: <1505880732-16539-3-git-send-email-jia.guo@intel.com> <1509567405-27439-1-git-send-email-jia.guo@intel.com> <1509567405-27439-2-git-send-email-jia.guo@intel.com> <20171101224144.7e0854bf@shemminger-XPS-13-9360> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: "Richardson, Bruce" , "Yigit, Ferruh" , "gaetan.rivet@6wind.com" , "thomas@monjalon.net" , "Ananyev, Konstantin" , "jblunck@infradead.org" , "shreyansh.jain@nxp.com" , "Wu, Jingjing" , "dev@dpdk.org" , "Zhang, Helin" To: Stephen Hemminger Return-path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 8CA681B395 for ; Wed, 8 Nov 2017 06:40:00 +0100 (CET) In-Reply-To: <20171101224144.7e0854bf@shemminger-XPS-13-9360> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Thanks Stephen for your eye on review, would collect other comment and refi= ne it better in next version. Best regards, Jeff Guo -----Original Message----- From: Stephen Hemminger [mailto:stephen@networkplumber.org]=20 Sent: Thursday, November 2, 2017 5:42 AM To: Guo, Jia Cc: Richardson, Bruce ; Yigit, Ferruh ; gaetan.rivet@6wind.com; thomas@monjalon.net; Ananyev, Kons= tantin ; jblunck@infradead.org; shreyansh.jai= n@nxp.com; Wu, Jingjing ; dev@dpdk.org; Zhang, Helin= Subject: Re: [PATCH v6 1/2] eal: add uevent monitor for hot plug On Thu, 2 Nov 2017 04:16:44 +0800 Jeff Guo wrote: > + > +static int > +dev_uev_parse(const char *buf, struct rte_eal_uevent *event) { > + char action[RTE_EAL_UEVENT_MSG_LEN]; > + char subsystem[RTE_EAL_UEVENT_MSG_LEN]; > + char dev_path[RTE_EAL_UEVENT_MSG_LEN]; > + char pci_slot_name[RTE_EAL_UEVENT_MSG_LEN]; > + int i =3D 0; > + > + memset(action, 0, RTE_EAL_UEVENT_MSG_LEN); > + memset(subsystem, 0, RTE_EAL_UEVENT_MSG_LEN); > + memset(dev_path, 0, RTE_EAL_UEVENT_MSG_LEN); > + memset(pci_slot_name, 0, RTE_EAL_UEVENT_MSG_LEN); > + > + while (i < RTE_EAL_UEVENT_MSG_LEN) { Might be simpler, safer, clearer to use rte_strsplit here. And then have a table of fields rather than open coding the parsing. > + for (; i < RTE_EAL_UEVENT_MSG_LEN; i++) { > + if (*buf) > + break; > + buf++; > + } > + if (!strncmp(buf, "libudev", 7)) { > + buf +=3D 7; > + i +=3D 7; > + event->group =3D UEV_MONITOR_UDEV; > + } > + if (!strncmp(buf, "ACTION=3D", 7)) { > + buf +=3D 7; > + i +=3D 7; > + snprintf(action, sizeof(action), "%s", buf); > + } else if (!strncmp(buf, "DEVPATH=3D", 8)) { > + buf +=3D 8; > + i +=3D 8; > + snprintf(dev_path, sizeof(dev_path), "%s", buf); > + } else if (!strncmp(buf, "SUBSYSTEM=3D", 10)) { > + buf +=3D 10; > + i +=3D 10; > + snprintf(subsystem, sizeof(subsystem), "%s", buf); > + } else if (!strncmp(buf, "PCI_SLOT_NAME=3D", 14)) { > + buf +=3D 14; > + i +=3D 14; > + snprintf(pci_slot_name, sizeof(subsystem), "%s", buf); > + } > + for (; i < RTE_EAL_UEVENT_MSG_LEN; i++) { > + if (*buf =3D=3D '\0') > + break; > + buf++; > + } > + } > + > + if (!strncmp(subsystem, "pci", 3)) > + event->subsystem =3D UEV_SUBSYSTEM_PCI; > + if (!strncmp(action, "add", 3)) > + event->type =3D RTE_EAL_DEV_EVENT_ADD; > + if (!strncmp(action, "remove", 6)) > + event->type =3D RTE_EAL_DEV_EVENT_REMOVE; > + event->devname =3D pci_slot_name; > + > + return 0; Function always returns 0, why is it not void?