From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kay Sievers Date: Thu, 04 Mar 2004 03:09:51 +0000 Subject: Re: [PATCH] fix NAME="foo-%c{N}" gets a truncated name Message-Id: <20040304030951.GC14662@vrfy.org> MIME-Version: 1 Content-Type: multipart/mixed; boundary="4zI0WCX1RcnW9Hbu" List-Id: References: <20040303144334.A20521@beaverton.ibm.com> In-Reply-To: <20040303144334.A20521@beaverton.ibm.com> To: linux-hotplug@vger.kernel.org --4zI0WCX1RcnW9Hbu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Mar 03, 2004 at 04:56:34PM -0800, Greg KH wrote: > On Wed, Mar 03, 2004 at 03:57:04PM -0800, Patrick Mansfield wrote: > > > > Here is a patch for some new tests. > > Applied, thanks. Here is a small improvement, which looks much better. Hey Pat, thanks a lot for finding the recent bug, hope this one will not break it again :) thanks, Kay --4zI0WCX1RcnW9Hbu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="01-better-foreach_strpart.patch" ===== namedev.c 1.123 vs edited ===== --- 1.123/namedev.c Thu Mar 4 01:40:03 2004 +++ edited/namedev.c Thu Mar 4 03:59:52 2004 @@ -220,8 +220,9 @@ char *attr; int len; int i; - int spos, slen; char c; + char *spos; + int slen; struct sysfs_attribute *tmpattr; pos = string; @@ -278,7 +279,6 @@ i = atoi(attr); if (i > 0) { foreach_strpart(udev->program_result, " \n\r", spos, slen) { - strnfieldcpy(temp2, udev->program_result + spos, slen+1); i--; if (i == 0) break; @@ -287,6 +287,7 @@ dbg("requested part of result string not found"); break; } + strnfieldcpy(temp2, spos, slen+1); strnfieldcat(string, temp2, maxsize); dbg("substitute part of result string '%s'", temp2); } else { ===== udev-add.c 1.59 vs edited ===== --- 1.59/udev-add.c Thu Mar 4 01:51:28 2004 +++ edited/udev-add.c Thu Mar 4 03:32:07 2004 @@ -195,7 +195,8 @@ gid_t gid = 0; int i; int tail; - int pos, len; + char *pos; + int len; strfieldcpy(filename, udev_root); strfieldcat(filename, dev->name); @@ -281,7 +282,7 @@ /* create symlink if requested */ foreach_strpart(dev->symlink, " ", pos, len) { - strnfieldcpy(linkname, dev->symlink + pos, len+1); + strnfieldcpy(linkname, pos, len+1); strfieldcpy(filename, udev_root); strfieldcat(filename, linkname); dbg("symlink '%s' to node '%s' requested", filename, dev->name); ===== udev-remove.c 1.23 vs edited ===== --- 1.23/udev-remove.c Wed Mar 3 05:43:18 2004 +++ edited/udev-remove.c Thu Mar 4 03:28:30 2004 @@ -72,7 +72,8 @@ char partitionname[NAME_SIZE]; int retval; int i; - int pos, len; + char *pos; + int len; strfieldcpy(filename, udev_root); strfieldcat(filename, dev->name); @@ -102,7 +103,7 @@ delete_path(filename); foreach_strpart(dev->symlink, " ", pos, len) { - strnfieldcpy(linkname, dev->symlink + pos, len+1); + strnfieldcpy(linkname, pos, len+1); strfieldcpy(filename, udev_root); strfieldcat(filename, linkname); ===== udev.h 1.49 vs edited ===== --- 1.49/udev.h Wed Mar 3 05:39:01 2004 +++ edited/udev.h Thu Mar 4 03:26:20 2004 @@ -98,9 +98,9 @@ } while (0) #define foreach_strpart(str, separator, pos, len) \ - for(pos = 0, len = strcspn(str, separator); \ - (pos) < strlen(str); \ - pos = pos + (len) + 1, len = strcspn((str) + pos, separator)) \ + for(pos = str, len = 0; \ + (pos) < ((str) + strlen(str)); \ + pos = pos + len + strspn(pos, separator), len = strcspn(pos, separator)) \ if (len > 0) static inline char *get_action(void) ===== udevdb.c 1.25 vs edited ===== --- 1.25/udevdb.c Wed Mar 3 06:33:03 2004 +++ edited/udevdb.c Thu Mar 4 03:33:07 2004 @@ -179,7 +179,8 @@ static int find_device_by_name(char *path, struct udevice *dev) { - int pos, len; + char *pos; + int len; if (strncmp(dev->name, find_name, sizeof(dev->name)) == 0) { memcpy(find_dev, dev, sizeof(struct udevice)); @@ -190,7 +191,7 @@ } /* look for matching symlink*/ foreach_strpart(dev->symlink, " ", pos, len) { - if (strncmp(&dev->symlink[pos], find_name, len) != 0) + if (strncmp(pos, find_name, len) != 0) continue; if (len != strlen(find_name)) --4zI0WCX1RcnW9Hbu-- ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel