diff options
author | mananth <mananth> | 2003-08-29 09:39:33 +0000 |
---|---|---|
committer | mananth <mananth> | 2003-08-29 09:39:33 +0000 |
commit | a05a8e02235bfcf2ae1d7493fce5a5e31ec108f8 (patch) | |
tree | bafbf9f92ae7bff70835543f8e96e58308f45c20 | |
parent | 8aec625379d5c8f62ed4a3f5810bcae1ae6e94c4 (diff) | |
download | sysfsutils-a05a8e02235bfcf2ae1d7493fce5a5e31ec108f8.tar.gz |
correct dprintf usage
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | lib/sysfs_bus.c | 16 | ||||
-rw-r--r-- | lib/sysfs_class.c | 22 | ||||
-rw-r--r-- | lib/sysfs_device.c | 10 | ||||
-rw-r--r-- | lib/sysfs_dir.c | 33 | ||||
-rw-r--r-- | lib/sysfs_driver.c | 8 | ||||
-rw-r--r-- | lib/sysfs_utils.c | 9 |
7 files changed, 47 insertions, 54 deletions
@@ -1,4 +1,7 @@ +08/06/2003 - Ananth Mavinakayanahalli <ananth@in.ibm.com> + * Patch to correct dprintf usage + 08/01/2003 - Ananth Mavinakayanahalli <ananth@in.ibm.com> * Added autoconf configuration support * Modified IBM Copyright information diff --git a/lib/sysfs_bus.c b/lib/sysfs_bus.c index b3fdbb8..e61b5a8 100644 --- a/lib/sysfs_bus.c +++ b/lib/sysfs_bus.c @@ -74,7 +74,7 @@ static struct sysfs_directory *open_bus_dir(const char *name) memset(buspath, 0, SYSFS_PATH_MAX); if ((sysfs_get_mnt_path(buspath, SYSFS_PATH_MAX)) != 0) { - dprintf(stderr, "Sysfs not supported on this system\n"); + dprintf("Sysfs not supported on this system\n"); return NULL; } @@ -84,12 +84,12 @@ static struct sysfs_directory *open_bus_dir(const char *name) busdir = sysfs_open_directory(buspath); if (busdir == NULL) { errno = EINVAL; - dprintf(stderr,"Bus %s not supported on this system\n", + dprintf("Bus %s not supported on this system\n", name); return NULL; } if ((sysfs_read_directory(busdir)) != 0) { - dprintf(stderr, "Error reading %s bus dir %s\n", name, + dprintf("Error reading %s bus dir %s\n", name, buspath); sysfs_close_directory(busdir); return NULL; @@ -158,7 +158,7 @@ static int get_all_bus_devices(struct sysfs_bus *bus) nextl = curl->next; bdev = sysfs_open_device(curl->target); if (bdev == NULL) { - dprintf(stderr, "Error opening device at %s\n", + dprintf("Error opening device at %s\n", curl->target); continue; } @@ -197,7 +197,7 @@ static int get_all_bus_drivers(struct sysfs_bus *bus) nextsub = cursub->next; driver = sysfs_open_driver(cursub->path); if (driver == NULL) { - dprintf(stderr, "Error opening driver at %s\n", + dprintf("Error opening driver at %s\n", cursub->path); continue; } @@ -279,19 +279,19 @@ struct sysfs_bus *sysfs_open_bus(const char *name) strcpy(bus->name, name); busdir = open_bus_dir(name); if (busdir == NULL) { - dprintf(stderr,"Invalid bus, %s not supported on this system\n", + dprintf("Invalid bus, %s not supported on this system\n", name); sysfs_close_bus(bus); return NULL; } bus->directory = busdir; if ((get_all_bus_devices(bus)) != 0) { - dprintf(stderr, "Error reading %s bus devices\n", name); + dprintf("Error reading %s bus devices\n", name); sysfs_close_bus(bus); return NULL; } if ((get_all_bus_drivers(bus)) != 0) { - dprintf(stderr, "Error reading %s bus drivers\n", name); + dprintf("Error reading %s bus drivers\n", name); sysfs_close_bus(bus); return NULL; } diff --git a/lib/sysfs_class.c b/lib/sysfs_class.c index 129e8b1..704fe44 100644 --- a/lib/sysfs_class.c +++ b/lib/sysfs_class.c @@ -94,7 +94,7 @@ static struct sysfs_directory *open_class_dir(const char *name) memset(classpath, 0, SYSFS_PATH_MAX); if ((sysfs_get_mnt_path(classpath, SYSFS_PATH_MAX)) != 0) { - dprintf(stderr, "Sysfs not supported on this system\n"); + dprintf("Sysfs not supported on this system\n"); return NULL; } @@ -104,13 +104,11 @@ static struct sysfs_directory *open_class_dir(const char *name) classdir = sysfs_open_directory(classpath); if (classdir == NULL) { errno = EINVAL; - dprintf(stderr,"Class %s not supported on this system\n", - name); + dprintf("Class %s not supported on this system\n", name); return NULL; } if ((sysfs_read_directory(classdir)) != 0) { - dprintf(stderr, "Error reading %s class dir %s\n", name, - classpath); + dprintf("Error reading %s class dir %s\n", name, classpath); sysfs_close_directory(classdir); return NULL; } @@ -142,19 +140,19 @@ struct sysfs_class_device *sysfs_open_class_device(const char *path) } if ((sysfs_get_name_from_path(path, cdev->name, SYSFS_NAME_LEN)) != 0) { errno = EINVAL; - dprintf(stderr, "Invalid class device path %s\n", path); + dprintf("Invalid class device path %s\n", path); sysfs_close_class_device(cdev); return NULL; } dir = sysfs_open_directory(path); if (dir == NULL) { - dprintf(stderr, "Error opening class device at %s\n", path); + dprintf("Error opening class device at %s\n", path); sysfs_close_class_device(cdev); return NULL; } if ((sysfs_read_directory(dir)) != 0) { - dprintf(stderr, "Error reading class device at %s\n", path); + dprintf("Error reading class device at %s\n", path); sysfs_close_directory(dir); sysfs_close_class_device(cdev); return NULL; @@ -221,8 +219,7 @@ static int get_all_class_devices(struct sysfs_class *cls) next = cur->next; dev = sysfs_open_class_device(cur->path); if (dev == NULL) { - dprintf(stderr, "Error opening device at %s\n", - cur->path); + dprintf("Error opening device at %s\n", cur->path); continue; } add_dev_to_class(cls, dev); @@ -253,15 +250,14 @@ struct sysfs_class *sysfs_open_class(const char *name) strcpy(cls->name, name); classdir = open_class_dir(name); if (classdir == NULL) { - dprintf(stderr, - "Invalid class, %s not supported on this system\n", + dprintf("Invalid class, %s not supported on this system\n", name); sysfs_close_class(cls); return NULL; } cls->directory = classdir; if ((get_all_class_devices(cls)) != 0) { - dprintf(stderr, "Error reading %s class devices\n", name); + dprintf("Error reading %s class devices\n", name); sysfs_close_class(cls); return NULL; } diff --git a/lib/sysfs_device.c b/lib/sysfs_device.c index 6db6d83..4756c05 100644 --- a/lib/sysfs_device.c +++ b/lib/sysfs_device.c @@ -94,18 +94,18 @@ struct sysfs_device *sysfs_open_device(const char *path) } dev = alloc_device(); if (dev == NULL) { - dprintf(stderr, "Error allocating device at %s\n", path); + dprintf("Error allocating device at %s\n", path); return NULL; } sdir = sysfs_open_directory(path); if (sdir == NULL) { - dprintf(stderr, "Invalid device at %s\n", path); + dprintf("Invalid device at %s\n", path); errno = EINVAL; sysfs_close_device(dev); return NULL; } if ((sysfs_read_directory(sdir)) != 0) { - dprintf(stderr, "Error reading device directory at %s\n", path); + dprintf("Error reading device directory at %s\n", path); sysfs_close_directory(sdir); sysfs_close_device(dev); return NULL; @@ -179,14 +179,14 @@ struct sysfs_device *sysfs_open_device_tree(const char *path) } rootdev = sysfs_open_device(path); if (rootdev == NULL) { - dprintf(stderr, "Error opening root device at %s\n", path); + dprintf("Error opening root device at %s\n", path); return NULL; } cur = rootdev->directory->subdirs; while (cur != NULL) { new = sysfs_open_device_tree(cur->path); if (new == NULL) { - dprintf(stderr, "Error opening device tree at %s\n", + dprintf("Error opening device tree at %s\n", cur->path); sysfs_close_device_tree(rootdev); return NULL; diff --git a/lib/sysfs_dir.c b/lib/sysfs_dir.c index 3919a17..b089d81 100644 --- a/lib/sysfs_dir.c +++ b/lib/sysfs_dir.c @@ -62,7 +62,7 @@ struct sysfs_attribute *sysfs_open_attribute(const char *path) } sysattr = alloc_attribute(); if (sysattr == NULL) { - dprintf(stderr, "Error allocating attribute at %s\n", path); + dprintf("Error allocating attribute at %s\n", path); return NULL; } strncpy(sysattr->path, path, sizeof(sysattr->path)); @@ -97,7 +97,7 @@ int sysfs_read_attribute(struct sysfs_attribute *sysattr) return -1; } if (!(sysattr->method & SYSFS_METHOD_SHOW)) { - dprintf (stderr, "Show method not supported for attribute %s\n", + dprintf("Show method not supported for attribute %s\n", sysattr->path); return -1; } @@ -108,14 +108,13 @@ int sysfs_read_attribute(struct sysfs_attribute *sysattr) return -1; } if ((fd = open(sysattr->path, O_RDONLY)) < 0) { - dprintf (stderr, "Error reading attribute %s\n", sysattr->path); + dprintf("Error reading attribute %s\n", sysattr->path); free(fbuf); return -1; } length = read(fd, fbuf, pgsize); if (length < 0) { - dprintf (stderr, "Error reading from attribute %s\n", - sysattr->path); + dprintf("Error reading from attribute %s\n", sysattr->path); close(fd); free(fbuf); return -1; @@ -154,19 +153,18 @@ int sysfs_read_attribute_value(const char *attrpath, char *value, size_t vsize) attr = sysfs_open_attribute(attrpath); if (attr == NULL) { - dprintf(stderr, "Invalid attribute path %s\n", attrpath); + dprintf("Invalid attribute path %s\n", attrpath); errno = EINVAL; return -1; } if((sysfs_read_attribute(attr)) != 0 || attr->value == NULL) { - dprintf(stderr, "Error reading from attribute %s\n", attrpath); + dprintf("Error reading from attribute %s\n", attrpath); sysfs_close_attribute(attr); return -1; } length = strlen(attr->value); if (length > vsize) - dprintf(stderr, - "Value length %d is larger than supplied buffer %d\n", + dprintf("Value length %d is larger than supplied buffer %d\n", length, vsize); strncpy(value, attr->value, vsize); sysfs_close_attribute(attr); @@ -334,7 +332,7 @@ struct sysfs_directory *sysfs_open_directory(const char *path) } sdir = alloc_directory(); if (sdir == NULL) { - dprintf(stderr, "Error allocating directory %s\n", path); + dprintf("Error allocating directory %s\n", path); return NULL; } strncpy(sdir->path, path, sizeof(sdir->path)); @@ -358,14 +356,13 @@ struct sysfs_link *sysfs_open_link(const char *linkpath) ln = alloc_link(); if (ln == NULL) { - dprintf(stderr, - "Error allocating link %s\n", linkpath); + dprintf("Error allocating link %s\n", linkpath); return NULL; } if ((sysfs_get_name_from_path(linkpath, ln->name, SYSFS_NAME_LEN)) != 0 || (sysfs_get_link(linkpath, ln->target, SYSFS_PATH_MAX)) != 0) { errno = EINVAL; - dprintf(stderr, "Invalid link path %s\n", linkpath); + dprintf("Invalid link path %s\n", linkpath); return NULL; } @@ -413,15 +410,14 @@ int sysfs_read_directory(struct sysfs_directory *sysdir) if (S_ISREG(astats.st_mode)) { attr = sysfs_open_attribute(file_path); if (attr == NULL) { - dprintf (stderr, "Error opening attribute %s\n", + dprintf("Error opening attribute %s\n", file_path); retval = -1; break; } if (attr->method & SYSFS_METHOD_SHOW) { if ((sysfs_read_attribute(attr)) != 0) { - dprintf (stderr, - "Error reading attribute %s\n", + dprintf("Error reading attribute %s\n", file_path); sysfs_close_attribute(attr); continue; @@ -431,7 +427,7 @@ int sysfs_read_directory(struct sysfs_directory *sysdir) } else if (S_ISDIR(astats.st_mode)) { subdir = sysfs_open_directory(file_path); if (subdir == NULL) { - dprintf (stderr, "Error opening directory %s\n", + dprintf("Error opening directory %s\n", file_path); retval = -1; break; @@ -440,8 +436,7 @@ int sysfs_read_directory(struct sysfs_directory *sysdir) } else if (S_ISLNK(astats.st_mode)) { ln = sysfs_open_link(file_path); if (ln == NULL) { - dprintf(stderr, "Error opening link %s\n", - file_path); + dprintf("Error opening link %s\n", file_path); retval = -1; break; } diff --git a/lib/sysfs_driver.c b/lib/sysfs_driver.c index 1a87ef9..5558c03 100644 --- a/lib/sysfs_driver.c +++ b/lib/sysfs_driver.c @@ -62,22 +62,22 @@ struct sysfs_driver *sysfs_open_driver(const char *path) } sdir = sysfs_open_directory(path); if (sdir == NULL) { - dprintf (stderr, "Error opening directory %s\n", path); + dprintf("Error opening directory %s\n", path); return NULL; } if ((sysfs_read_directory(sdir)) != 0) { - dprintf (stderr, "Error reading directory %s\n", path); + dprintf("Error reading directory %s\n", path); sysfs_close_directory(sdir); return NULL; } driver = alloc_driver(); if (driver == NULL) { - dprintf(stderr, "Error allocating driver at %s\n", path); + dprintf("Error allocating driver at %s\n", path); sysfs_close_directory(sdir); return NULL; } if ((sysfs_get_name_from_path(path, devname, SYSFS_NAME_LEN)) != 0) { - dprintf (stderr, "Error reading directory %s\n", path); + dprintf("Error reading directory %s\n", path); sysfs_close_directory(sdir); free(driver); return NULL; diff --git a/lib/sysfs_utils.c b/lib/sysfs_utils.c index a57d854..def955e 100644 --- a/lib/sysfs_utils.c +++ b/lib/sysfs_utils.c @@ -45,7 +45,7 @@ static int sysfs_get_fs_mnt_path(const char *fs_type, char *mnt_path, } if ((mnt = setmntent(SYSFS_PROC_MNTS, "r")) == NULL) { - dprintf(stderr, "Error getting mount information\n"); + dprintf("Error getting mount information\n"); return -1; } while (ret == 0 && dirlen == 0 && (mntent = getmntent(mnt)) != NULL) { @@ -54,15 +54,14 @@ static int sysfs_get_fs_mnt_path(const char *fs_type, char *mnt_path, if (dirlen <= (len - 1)) { strcpy(mnt_path, mntent->mnt_dir); } else { - dprintf(stderr, - "Error - mount path too long\n"); + dprintf("Error - mount path too long\n"); ret = -1; } } } endmntent(mnt); if (dirlen == 0 && ret == 0) { - dprintf(stderr, "Filesystem %s not found!\n", fs_type); + dprintf("Filesystem %s not found!\n", fs_type); errno = EINVAL; ret = -1; } @@ -133,7 +132,7 @@ int sysfs_get_link(const char *path, char *target, size_t len) memset(linkpath, 0, SYSFS_PATH_MAX); if ((sysfs_get_mnt_path(devdir, SYSFS_PATH_MAX)) != 0) { - dprintf(stderr, "Sysfs not supported on this system\n"); + dprintf("Sysfs not supported on this system\n"); return -1; } |