mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-10-30 23:21:08 +03:00
[PATCH] Patch from Alex Riesen <raa.lkml@gmail.com>
> 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.
This commit is contained in:
parent
8474ff500f
commit
a4f0cc793a
@ -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;
|
||||
|
||||
|
32
udev_sysfs.c
32
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 */
|
||||
|
Loading…
Reference in New Issue
Block a user