From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Marco d'Itri" Date: Thu, 04 Mar 2004 01:16:23 +0000 Subject: udev 021 patches 1/2 Message-Id: <20040304011623.GC22285@wonderland.linux.it> MIME-Version: 1 Content-Type: multipart/mixed; boundary="eAbsdosE1cNLO4uF" List-Id: To: linux-hotplug@vger.kernel.org --eAbsdosE1cNLO4uF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline strip_trailing_blanks: makes comparisons on sysfs fields not sensitive to trailing blanks (tested, it works for me). -- ciao, | Marco | [4888 seIurgyHK/uw2] --eAbsdosE1cNLO4uF Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=strip_trailing_blanks diff -ruNp udev-019.orig/namedev.c udev-019/namedev.c --- udev-019.orig/namedev.c 2004-02-28 17:46:22.000000000 +0100 +++ udev-019/namedev.c 2004-02-28 17:46:17.000000000 +0100 @@ -520,6 +520,17 @@ attr_found: return tmpattr; } +static void strip_trailing_blanks(char *s) +{ + char *p; + + for (p = s + strlen(s) - 1; p > s; p--) { + if (!isspace(*p)) + break; + *p = '\0'; + } +} + static int compare_sysfs_attribute(struct sysfs_class_device *class_dev, struct sysfs_device *sysfs_device, struct sysfs_pair *pair) { struct sysfs_attribute *tmpattr; @@ -531,6 +542,8 @@ static int compare_sysfs_attribute(struc if (tmpattr == NULL) return -ENODEV; + strip_trailing_blanks(tmpattr->value); + strip_trailing_blanks(pair->value); dbg("compare attribute '%s' value '%s' with '%s'", pair->file, tmpattr->value, pair->value); if (strcmp_pattern(pair->value, tmpattr->value) != 0) --eAbsdosE1cNLO4uF-- ------------------------------------------------------- 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