summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2003-11-24 22:27:17 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:13:03 -0700
commitf7b4eca455c7dbf850d984892756f22dbd9ddc3d (patch)
tree55488d985521e5b05f47ff4847b52e0fcbae3fa5
parent74894b53f8f9f4de6f269a5c0c0f8ea03baa1587 (diff)
[PATCH] overall whitespace + debug text conditioning
01-overall-whitespace+debug-text-conditioning.diff o cleanup whitespace o clarify a few comments o enclose all printed debug string values in ''
-rw-r--r--logging.c14
-rw-r--r--namedev.c30
-rw-r--r--namedev.h3
-rw-r--r--udev-add.c22
-rw-r--r--udev-remove.c8
-rw-r--r--udev.c11
-rw-r--r--udev.h1
-rw-r--r--udevdb.c14
-rw-r--r--udevdb.h6
9 files changed, 52 insertions, 57 deletions
diff --git a/logging.c b/logging.c
index 1ca3aed1a9..4815f39fdc 100644
--- a/logging.c
+++ b/logging.c
@@ -32,26 +32,26 @@
static int logging_init = 0;
static unsigned char udev_logname[42];
-static void init_logging (void)
+static void init_logging(void)
{
- snprintf(udev_logname,42,"udev[%d]", getpid());
+ snprintf(udev_logname, 42,"udev[%d]", getpid());
- openlog (udev_logname, 0, LOG_DAEMON);
+ openlog(udev_logname, 0, LOG_DAEMON);
logging_init = 1;
}
/**
* log_message - sends a message to the logging facility
*/
-int log_message (int level, const char *format, ...)
+int log_message(int level, const char *format, ...)
{
va_list args;
if (!logging_init)
init_logging();
- va_start (args, format);
- vsyslog (level, format, args);
- va_end (args);
+ va_start(args, format);
+ vsyslog(level, format, args);
+ va_end(args);
return 1;
}
diff --git a/namedev.c b/namedev.c
index e640b93c3d..21815b694a 100644
--- a/namedev.c
+++ b/namedev.c
@@ -216,10 +216,10 @@ static int namedev_init_config(void)
int retval = 0;
struct config_device dev;
- dbg("opening %s to read as config", udev_config_filename);
+ dbg("opening '%s' to read as config", udev_config_filename);
fd = fopen(udev_config_filename, "r");
if (fd == NULL) {
- dbg("can't open %s", udev_config_filename);
+ dbg("can't open '%s'", udev_config_filename);
return -ENODEV;
}
@@ -232,7 +232,7 @@ static int namedev_init_config(void)
goto exit;
lineno++;
- dbg_parse("read %s", temp);
+ dbg_parse("read '%s'", temp);
/* eat the whitespace at the beginning of the line */
while (isspace(*temp))
@@ -413,10 +413,10 @@ static int namedev_init_permissions(void)
int retval = 0;
struct config_device dev;
- dbg("opening %s to read as permissions config", udev_config_permission_filename);
+ dbg("opening '%s' to read as permissions config", udev_config_permission_filename);
fd = fopen(udev_config_permission_filename, "r");
if (fd == NULL) {
- dbg("can't open %s", udev_config_permission_filename);
+ dbg("can't open '%s'", udev_config_permission_filename);
return -ENODEV;
}
@@ -426,7 +426,7 @@ static int namedev_init_permissions(void)
if (temp == NULL)
break;
- dbg_parse("read %s", temp);
+ dbg_parse("read '%s'", temp);
/* eat the whitespace at the beginning of the line */
while (isspace(*temp))
@@ -445,21 +445,21 @@ static int namedev_init_permissions(void)
/* parse the line */
temp2 = strsep(&temp, ":");
if (!temp2) {
- dbg("cannot parse line: %s", line);
+ dbg("cannot parse line '%s'", line);
continue;
}
strncpy(dev.name, temp2, sizeof(dev.name));
temp2 = strsep(&temp, ":");
if (!temp2) {
- dbg("cannot parse line: %s", line);
+ dbg("cannot parse line '%s'", line);
continue;
}
strncpy(dev.owner, temp2, sizeof(dev.owner));
temp2 = strsep(&temp, ":");
if (!temp2) {
- dbg("cannot parse line: %s", line);
+ dbg("cannot parse line '%s'", line);
continue;
}
strncpy(dev.group, temp2, sizeof(dev.owner));
@@ -496,7 +496,7 @@ static void build_kernel_number(struct sysfs_class_device *class_dev, struct ude
while (isdigit(*(dig-1)))
dig--;
strfieldcpy(udev->kernel_number, dig);
- dbg("kernel_number = %s", udev->kernel_number);
+ dbg("kernel_number='%s'", udev->kernel_number);
}
static void apply_format(struct udevice *udev, unsigned char *string)
@@ -608,7 +608,7 @@ static int exec_callout(struct config_device *dev, char *value, int len)
break;
buffer[res] = '\0';
if (res > len) {
- dbg("callout len %d too short\n", len);
+ dbg("callout len %d too short", len);
retval = -1;
}
if (value_set) {
@@ -660,7 +660,7 @@ static int do_callout(struct sysfs_class_device *class_dev, struct udevice *udev
strfieldcpy(udev->group, dev->group);
}
dbg_parse("callout returned matching value '%s', '%s' becomes '%s'"
- " - owner='%s', group='%s', mode =%#o",
+ " - owner='%s', group='%s', mode=%#o",
dev->id, class_dev->name, udev->name,
dev->owner, dev->group, dev->mode);
return 0;
@@ -884,11 +884,11 @@ static int get_attr(struct sysfs_class_device *class_dev, struct udevice *udev)
* up in the kernel...
*/
if (strstr(class_dev->path, "block")) {
- dbg_parse("looking at block device...");
+ dbg_parse("looking at block device");
if (isdigit(class_dev->path[strlen(class_dev->path)-1])) {
char path[SYSFS_PATH_MAX];
- dbg_parse("really is a partition...");
+ dbg_parse("really is a partition");
strfieldcpy(path, class_dev->path);
temp = strrchr(path, '/');
*temp = 0x00;
@@ -897,7 +897,7 @@ static int get_attr(struct sysfs_class_device *class_dev, struct udevice *udev)
if (class_dev_parent == NULL) {
dbg("sysfs_open_class_device at '%s' failed", path);
} else {
- dbg_parse("class_dev_parent->name=%s", class_dev_parent->name);
+ dbg_parse("class_dev_parent->name='%s'", class_dev_parent->name);
if (class_dev_parent->sysdevice)
sysfs_device = class_dev_parent->sysdevice;
}
diff --git a/namedev.h b/namedev.h
index 56e6a96c03..5ea843e9b7 100644
--- a/namedev.h
+++ b/namedev.h
@@ -50,7 +50,6 @@ struct config_device {
struct list_head node;
enum config_type type;
-
char bus[BUS_SIZE];
char sysfs_file[FILE_SIZE];
char sysfs_value[VALUE_SIZE];
@@ -58,7 +57,7 @@ struct config_device {
char place[PLACE_SIZE];
char kernel_name[NAME_SIZE];
char exec_program[FILE_SIZE];
-
+
/* what to set the device to */
char name[NAME_SIZE];
char owner[OWNER_SIZE];
diff --git a/udev-add.c b/udev-add.c
index 068fd46f27..a71d435e32 100644
--- a/udev-add.c
+++ b/udev-add.c
@@ -60,12 +60,12 @@ static int get_major_minor(struct sysfs_class_device *class_dev, struct udevice
if (dev == NULL)
goto exit;
- dbg("dev = %s", dev);
+ dbg("dev='%s'", dev);
if (sscanf(dev, "%u:%u", &udev->major, &udev->minor) != 2)
goto exit;
- dbg("found major = %d, minor = %d", udev->major, udev->minor);
+ dbg("found major=%d, minor=%d", udev->major, udev->minor);
retval = 0;
exit:
@@ -129,7 +129,7 @@ static int create_node(struct udevice *dev)
path, strerror(errno));
return retval;
}
- dbg("created %s", path);
+ dbg("created '%s'", path);
}
*pos = '/';
}
@@ -155,7 +155,7 @@ static int create_node(struct udevice *dev)
else {
struct passwd *pw = getpwnam(dev->owner);
if (!pw)
- dbg("user unknown: %s", dev->owner);
+ dbg("user unknown '%s'", dev->owner);
else
uid = pw->pw_uid;
}
@@ -169,7 +169,7 @@ static int create_node(struct udevice *dev)
else {
struct group *gr = getgrnam(dev->group);
if (!gr)
- dbg("group unknown: %s", dev->group);
+ dbg("group unknown '%s'", dev->group);
else
gid = gr->gr_gid;
}
@@ -194,7 +194,7 @@ static struct sysfs_class_device *get_class_dev(char *device_name)
strcpy(dev_path, sysfs_path);
strcat(dev_path, device_name);
- dbg("looking at %s", dev_path);
+ dbg("looking at '%s'", dev_path);
/* open up the sysfs class device for this thing... */
class_dev = sysfs_open_class_device(dev_path);
@@ -202,7 +202,7 @@ static struct sysfs_class_device *get_class_dev(char *device_name)
dbg ("sysfs_open_class_device failed");
goto exit;
}
- dbg("class_dev->name = %s", class_dev->name);
+ dbg("class_dev->name='%s'", class_dev->name);
exit:
return class_dev;
@@ -225,13 +225,12 @@ static int sleep_for_dev(char *path)
while (loop--) {
struct stat buf;
- dbg("looking for %s", filename);
+ dbg("looking for '%s'", filename);
retval = stat(filename, &buf);
if (!retval)
goto exit;
- /* sleep for a second or two to give the kernel a chance to
- * create the dev file */
+ /* sleep to give the kernel a chance to create the dev file */
sleep(1);
}
retval = -ENODEV;
@@ -276,7 +275,7 @@ int udev_add_device(char *path, char *subsystem)
dbg("udevdb_add_dev failed, but we are going to try to create the node anyway. "
"But remove might not work properly for this device.");
- dbg("name = %s", dev.name);
+ dbg("name='%s'", dev.name);
retval = create_node(&dev);
exit:
@@ -285,4 +284,3 @@ exit:
return retval;
}
-
diff --git a/udev-remove.c b/udev-remove.c
index 1cf5d5134d..0f14a3d685 100644
--- a/udev-remove.c
+++ b/udev-remove.c
@@ -52,14 +52,14 @@ static char *get_name(char *path, int major, int minor)
goto exit;
}
- dbg("%s not found in database, falling back on default name", path);
+ dbg("'%s' not found in database, falling back on default name", path);
temp = strrchr(path, '/');
if (temp == NULL)
return NULL;
strncpy(name, &temp[1], sizeof(name));
exit:
- dbg("name is %s", name);
+ dbg("name is '%s'", name);
return &name[0];
}
@@ -74,7 +74,7 @@ static int delete_node(char *name)
strncpy(filename, udev_root, sizeof(filename));
strncat(filename, name, sizeof(filename));
- dbg("unlinking %s", filename);
+ dbg("unlinking '%s'", filename);
retval = unlink(filename);
if (retval) {
dbg("unlink(%s) failed with error '%s'",
@@ -104,7 +104,7 @@ static int delete_node(char *name)
filename, strerror(errno));
break;
}
- dbg("removed %s", filename);
+ dbg("removed '%s'", filename);
}
}
return retval;
diff --git a/udev.c b/udev.c
index 56dab1f832..a562bc27be 100644
--- a/udev.c
+++ b/udev.c
@@ -105,7 +105,7 @@ static void get_dirs(void)
if (temp)
udev_permission = temp;
}
- dbg("sysfs_path = %s", sysfs_path);
+ dbg("sysfs_path='%s'", sysfs_path);
strncpy(udev_db_filename, udev_config_dir, sizeof(udev_db_filename));
strncat(udev_db_filename, udev_db, sizeof(udev_db_filename));
@@ -141,12 +141,12 @@ int main(int argc, char **argv, char **envp)
dbg ("no devpath?");
goto exit;
}
- dbg("looking at %s", devpath);
+ dbg("looking at '%s'", devpath);
/* we only care about class devices and block stuff */
if (!strstr(devpath, "class") &&
!strstr(devpath, "block")) {
- dbg("not block or class");
+ dbg("not a block or class device");
goto exit;
}
@@ -166,7 +166,7 @@ int main(int argc, char **argv, char **envp)
get_dirs();
retval = udevdb_init(UDEVDB_DEFAULT);
if (retval != 0) {
- dbg("Unable to initialize database.");
+ dbg("unable to initialize database");
goto exit;
}
@@ -180,7 +180,7 @@ int main(int argc, char **argv, char **envp)
retval = udev_remove_device(devpath, subsystem);
else {
- dbg("Unknown action: %s", action);
+ dbg("unknown action '%s'", action);
retval = -EINVAL;
}
udevdb_exit();
@@ -188,4 +188,3 @@ int main(int argc, char **argv, char **envp)
exit:
return retval;
}
-
diff --git a/udev.h b/udev.h
index 6798f13666..8e35cb708f 100644
--- a/udev.h
+++ b/udev.h
@@ -95,4 +95,3 @@ extern char udev_config_permission_filename[PATH_MAX+NAME_MAX];
extern char udev_config_filename[PATH_MAX+NAME_MAX];
#endif
-
diff --git a/udevdb.c b/udevdb.c
index ec67a07962..e0bd39e84b 100644
--- a/udevdb.c
+++ b/udevdb.c
@@ -54,7 +54,7 @@ int udevdb_add_dev(const char *path, const struct udevice *dev)
strcpy(keystr, path);
key.dptr = keystr;
key.dsize = strlen(keystr) + 1;
-
+
data.dptr = (void *)dev;
data.dsize = sizeof(*dev);
@@ -79,7 +79,7 @@ struct udevice *udevdb_get_dev(const char *path)
dev = malloc(sizeof(*dev));
if (dev == NULL)
goto exit;
-
+
memcpy(dev, data.dptr, sizeof(*dev));
exit:
free(data.dptr);
@@ -99,7 +99,7 @@ int udevdb_delete_dev(const char *path)
key.dptr = keystr;
key.dsize = strlen(keystr) + 1;
-
+
return tdb_delete(udevdb, key);
}
@@ -116,8 +116,8 @@ void udevdb_exit(void)
/**
* udevdb_init: initializes database
- * @init_flag: database can either be in memory - UDEVDB_INTERNAL - or
- * written to a file with UDEVDB_DEFAULT.
+ * @init_flag: UDEVDB_INTERNAL - database stays in memory
+ * UDEVDB_DEFAULT - database is written to a file
*/
int udevdb_init(int init_flag)
{
@@ -127,9 +127,9 @@ int udevdb_init(int init_flag)
udevdb = tdb_open(udev_db_filename, 0, init_flag, O_RDWR | O_CREAT, 0644);
if (udevdb == NULL) {
if (init_flag == UDEVDB_INTERNAL)
- dbg("Unable to initialize in-memory database");
+ dbg("unable to initialize in-memory database");
else
- dbg("Unable to initialize database at %s", udev_db_filename);
+ dbg("unable to initialize database at '%s'", udev_db_filename);
return -EINVAL;
}
return 0;
diff --git a/udevdb.h b/udevdb.h
index 9935e80e9c..97e1f9bc40 100644
--- a/udevdb.h
+++ b/udevdb.h
@@ -5,10 +5,10 @@
#define _UDEVDB_H_
/* Udevdb initialization flags */
-#define UDEVDB_DEFAULT 0 /* Defaults database to use file */
-#define UDEVDB_INTERNAL 1 /* Don't store db on disk, use in memory */
+#define UDEVDB_DEFAULT 0 /* defaults database to use file */
+#define UDEVDB_INTERNAL 1 /* don't store db on disk, use in memory */
-/* Function Prototypes */
+/* function prototypes */
extern void udevdb_exit(void);
extern int udevdb_init(int init_flag);