From: Kay Sievers <kay.sievers@vrfy.org>
To: linux-hotplug@vger.kernel.org
Subject: Re: [PATCH] fix NAME="foo-%c{N}" gets a truncated name
Date: Thu, 04 Mar 2004 03:09:51 +0000 [thread overview]
Message-ID: <20040304030951.GC14662@vrfy.org> (raw)
In-Reply-To: <20040303144334.A20521@beaverton.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 353 bytes --]
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
[-- Attachment #2: 01-better-foreach_strpart.patch --]
[-- Type: text/plain, Size: 3184 bytes --]
===== 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))
next prev parent reply other threads:[~2004-03-04 3:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-03 22:43 [PATCH] fix NAME="foo-%c{N}" gets a truncated name Patrick Mansfield
2004-03-03 22:58 ` Kay Sievers
2004-03-03 23:46 ` Kay Sievers
2004-03-03 23:57 ` Patrick Mansfield
2004-03-04 0:56 ` Greg KH
2004-03-04 0:56 ` Greg KH
2004-03-04 3:09 ` Kay Sievers [this message]
2004-03-04 18:57 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040304030951.GC14662@vrfy.org \
--to=kay.sievers@vrfy.org \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.