From: kay.sievers@vrfy.org Date: Tue, 23 Nov 2004 02:43:37 +0000 (+0100) Subject: [PATCH] Patch from Alex Riesen X-Git-Tag: 047~48 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=a4f0cc793a9a2053f9733c5ebd1445c9a2678445 [PATCH] Patch from Alex Riesen > I just put const's at some places. It cut down data segments, but > increased code size. > Overall still smaller: > > -rwxr-xr-x 1 user users 50420 Nov 19 10:53 ../udev-046/udev > -rwxr-xr-x 1 user users 49556 Nov 19 10:53 udev > text data bss dec hex filename > 47245 968 22480 70693 11425 ../udev-046/udev > 48089 104 22064 70257 11271 udev > > Also, the instance of utsname in udev_lib.c is used only once. --- diff --git a/udev_lib.c b/udev_lib.c index f388d23f3..86a526f7e 100644 --- a/udev_lib.c +++ b/udev_lib.c @@ -62,12 +62,12 @@ void udev_set_values(struct udevice *udev, const char* devpath, int kernel_release_satisfactory(int version, int patchlevel, int sublevel) { - static struct utsname uts; static int kversion = 0; static int kpatchlevel; static int ksublevel; if (kversion == 0) { + struct utsname uts; if (uname(&uts) != 0) return -1; diff --git a/udev_sysfs.c b/udev_sysfs.c index e2c706c6f..a25223ef4 100644 --- a/udev_sysfs.c +++ b/udev_sysfs.c @@ -35,9 +35,9 @@ #include "logging.h" /* list of subsystem specific files, NULL if there is no file to wait for */ -static struct subsystem_file { - char *subsystem; - char *file; +static const struct subsystem_file { + const char *subsystem; + const char *file; } subsystem_files[] = { { .subsystem = "net", .file = "ifindex" }, { .subsystem = "scsi_host", .file = "unique_id" }, @@ -56,7 +56,7 @@ static struct subsystem_file { int subsystem_expect_no_dev(const char *subsystem) { - struct subsystem_file *file; + const struct subsystem_file *file; for (file = subsystem_files; file->subsystem != NULL; file++) if (strcmp(subsystem, file->subsystem) == 0) @@ -66,9 +66,9 @@ int subsystem_expect_no_dev(const char *subsystem) } /* get subsystem specific files, returns "dev" if no other found */ -static char *get_subsystem_specific_file(const char *subsystem) +static const char *get_subsystem_specific_file(const char *subsystem) { - struct subsystem_file *file; + const struct subsystem_file *file; /* look if we want to look for another file instead of "dev" */ for (file = subsystem_files; file->subsystem != NULL; file++) @@ -123,9 +123,9 @@ static int class_device_expect_no_device_link(struct sysfs_class_device *class_d { /* list of devices without a "device" symlink to the physical device * if device is set to NULL, no devices in that subsystem has a link */ - static struct class_device { - char *subsystem; - char *device; + static const struct class_device { + const char *subsystem; + const char *device; } class_device[] = { { .subsystem = "block", .device = "double" }, { .subsystem = "block", .device = "nb" }, @@ -202,7 +202,7 @@ static int class_device_expect_no_device_link(struct sysfs_class_device *class_d { .subsystem = "capi", .device = NULL }, { NULL, NULL } }; - struct class_device *classdevice; + const struct class_device *classdevice; int len; /* the kernel may tell us what to wait for */ @@ -240,13 +240,13 @@ static int class_device_expect_no_device_link(struct sysfs_class_device *class_d /* skip waiting for the bus of the devices device */ static int class_device_expect_no_bus(struct sysfs_class_device *class_dev) { - static char *devices_without_bus[] = { + static const char *devices_without_bus[] = { "scsi_host", "i2c-adapter", "i2c-dev", NULL }; - char **device; + const char **device; for (device = devices_without_bus; *device != NULL; device++) { int len = strlen(*device); @@ -262,9 +262,9 @@ static int class_device_expect_no_bus(struct sysfs_class_device *class_dev) int wait_for_devices_device(struct sysfs_device *devices_dev, const char **error) { - static struct device_file { - char *bus; - char *file; + static const struct device_file { + const char *bus; + const char *file; } device_files[] = { { .bus = "scsi", .file = "vendor" }, { .bus = "usb", .file = "idVendor" }, @@ -302,7 +302,7 @@ int wait_for_devices_device(struct sysfs_device *devices_dev, { .bus = "iucv", .file = "detach_state" }, { NULL, NULL } }; - struct device_file *devicefile; + const struct device_file *devicefile; int loop; /* the kernel may tell us what to wait for */