diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-10-24 22:58:24 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-10-24 23:05:02 +0200 |
commit | 07630cea1f3a845c09309f197ac7c4f11edd3b62 (patch) | |
tree | af80c7221d1466fac79a7f3a57e0d63a96f464d4 /src/udev | |
parent | 4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3 (diff) |
util-lib: split our string related calls from util.[ch] into its own file string-util.[ch]
There are more than enough calls doing string manipulations to deserve
its own files, hence do something about it.
This patch also sorts the #include blocks of all files that needed to be
updated, according to the sorting suggestions from CODING_STYLE. Since
pretty much every file needs our string manipulation functions this
effectively means that most files have sorted #include blocks now.
Also touches a few unrelated include files.
Diffstat (limited to 'src/udev')
29 files changed, 174 insertions, 144 deletions
diff --git a/src/udev/ata_id/ata_id.c b/src/udev/ata_id/ata_id.c index 1d1798dd10..7acd7b4e92 100644 --- a/src/udev/ata_id/ata_id.c +++ b/src/udev/ata_id/ata_id.c @@ -19,28 +19,29 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include <unistd.h> -#include <fcntl.h> #include <ctype.h> -#include <string.h> #include <errno.h> +#include <fcntl.h> #include <getopt.h> +#include <linux/bsg.h> +#include <linux/hdreg.h> #include <scsi/scsi.h> -#include <scsi/sg.h> #include <scsi/scsi_ioctl.h> +#include <scsi/sg.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> #include <sys/ioctl.h> -#include <sys/types.h> #include <sys/stat.h> -#include <linux/hdreg.h> -#include <linux/bsg.h> +#include <sys/types.h> +#include <unistd.h> #include "libudev.h" + #include "libudev-private.h" -#include "udev-util.h" #include "log.h" +#include "udev-util.h" #define COMMAND_TIMEOUT_MSEC (30 * 1000) diff --git a/src/udev/cdrom_id/cdrom_id.c b/src/udev/cdrom_id/cdrom_id.c index 001bae7a24..72f284f710 100644 --- a/src/udev/cdrom_id/cdrom_id.c +++ b/src/udev/cdrom_id/cdrom_id.c @@ -17,24 +17,25 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <stdio.h> -#include <stddef.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <limits.h> -#include <fcntl.h> #include <errno.h> +#include <fcntl.h> #include <getopt.h> -#include <time.h> +#include <limits.h> +#include <linux/cdrom.h> #include <scsi/sg.h> -#include <sys/types.h> +#include <stddef.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/ioctl.h> #include <sys/stat.h> #include <sys/time.h> -#include <sys/ioctl.h> -#include <linux/cdrom.h> +#include <sys/types.h> +#include <time.h> +#include <unistd.h> #include "libudev.h" + #include "libudev-private.h" #include "random-util.h" diff --git a/src/udev/collect/collect.c b/src/udev/collect/collect.c index b3a1f0bca1..b234792e23 100644 --- a/src/udev/collect/collect.c +++ b/src/udev/collect/collect.c @@ -19,13 +19,14 @@ * */ -#include <stdio.h> -#include <stddef.h> #include <errno.h> #include <getopt.h> +#include <stddef.h> +#include <stdio.h> #include "libudev-private.h" #include "macro.h" +#include "string-util.h" #define BUFSIZE 16 #define UDEV_ALARM_TIMEOUT 180 diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c index 4b8c5053a4..c308f898ea 100644 --- a/src/udev/net/link-config.c +++ b/src/udev/net/link-config.c @@ -22,22 +22,22 @@ #include <netinet/ether.h> #include <linux/netdevice.h> +#include "sd-netlink.h" -#include "missing.h" -#include "link-config.h" +#include "conf-files.h" +#include "conf-parser.h" #include "ethtool-util.h" - #include "libudev-private.h" -#include "sd-netlink.h" -#include "util.h" +#include "link-config.h" #include "log.h" -#include "strv.h" -#include "path-util.h" -#include "conf-parser.h" -#include "conf-files.h" +#include "missing.h" #include "netlink-util.h" #include "network-internal.h" +#include "path-util.h" #include "random-util.h" +#include "string-util.h" +#include "strv.h" +#include "util.h" struct link_config_ctx { LIST_HEAD(link_config, links); diff --git a/src/udev/net/link-config.h b/src/udev/net/link-config.h index c52db2ce55..4fcbee8b92 100644 --- a/src/udev/net/link-config.h +++ b/src/udev/net/link-config.h @@ -21,10 +21,11 @@ #pragma once -#include "ethtool-util.h" +#include "libudev.h" + #include "condition.h" +#include "ethtool-util.h" #include "list.h" -#include "libudev.h" typedef struct link_config_ctx link_config_ctx; typedef struct link_config link_config; diff --git a/src/udev/scsi_id/scsi_id.c b/src/udev/scsi_id/scsi_id.c index adb91869df..cbf9478e72 100644 --- a/src/udev/scsi_id/scsi_id.c +++ b/src/udev/scsi_id/scsi_id.c @@ -16,22 +16,24 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <stdio.h> -#include <stdlib.h> +#include <ctype.h> +#include <errno.h> +#include <fcntl.h> +#include <getopt.h> +#include <signal.h> #include <stdarg.h> #include <stdbool.h> -#include <unistd.h> -#include <signal.h> -#include <fcntl.h> -#include <errno.h> +#include <stdio.h> +#include <stdlib.h> #include <string.h> -#include <ctype.h> -#include <getopt.h> #include <sys/stat.h> +#include <unistd.h> #include "libudev.h" + #include "libudev-private.h" #include "scsi_id.h" +#include "string-util.h" #include "udev-util.h" static const struct option options[] = { diff --git a/src/udev/scsi_id/scsi_serial.c b/src/udev/scsi_id/scsi_serial.c index de3b4f7581..c7ef783684 100644 --- a/src/udev/scsi_id/scsi_serial.c +++ b/src/udev/scsi_id/scsi_serial.c @@ -17,27 +17,29 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <sys/types.h> -#include <sys/ioctl.h> -#include <sys/stat.h> -#include <stdio.h> #include <errno.h> -#include <string.h> #include <fcntl.h> -#include <stdlib.h> -#include <unistd.h> -#include <time.h> #include <inttypes.h> +#include <linux/bsg.h> +#include <linux/types.h> #include <scsi/scsi.h> #include <scsi/sg.h> -#include <linux/types.h> -#include <linux/bsg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/ioctl.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <time.h> +#include <unistd.h> #include "libudev.h" + #include "libudev-private.h" +#include "random-util.h" #include "scsi.h" #include "scsi_id.h" -#include "random-util.h" +#include "string-util.h" /* * A priority based list of id, naa, and binary/ascii for the identifier diff --git a/src/udev/udev-builtin-blkid.c b/src/udev/udev-builtin-blkid.c index b8066ea6e9..004ddb023f 100644 --- a/src/udev/udev-builtin-blkid.c +++ b/src/udev/udev-builtin-blkid.c @@ -18,18 +18,20 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include <blkid/blkid.h> #include <errno.h> #include <fcntl.h> #include <getopt.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> #include <sys/stat.h> -#include <blkid/blkid.h> #include "sd-id128.h" -#include "gpt.h" + #include "efivars.h" +#include "gpt.h" +#include "string-util.h" #include "udev.h" static void print_property(struct udev_device *dev, bool test, const char *name, const char *value) { diff --git a/src/udev/udev-builtin-btrfs.c b/src/udev/udev-builtin-btrfs.c index 3352821567..ce1a0c3882 100644 --- a/src/udev/udev-builtin-btrfs.c +++ b/src/udev/udev-builtin-btrfs.c @@ -17,8 +17,8 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include <stdlib.h> #include <fcntl.h> +#include <stdlib.h> #include <sys/ioctl.h> #ifdef HAVE_LINUX_BTRFS_H @@ -26,6 +26,7 @@ #endif #include "missing.h" +#include "string-util.h" #include "udev.h" static int builtin_btrfs(struct udev_device *dev, int argc, char *argv[], bool test) { diff --git a/src/udev/udev-builtin-hwdb.c b/src/udev/udev-builtin-hwdb.c index 72109d93d2..97a5a9c77f 100644 --- a/src/udev/udev-builtin-hwdb.c +++ b/src/udev/udev-builtin-hwdb.c @@ -17,16 +17,17 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include <stdio.h> -#include <stdlib.h> #include <fnmatch.h> #include <getopt.h> +#include <stdio.h> +#include <stdlib.h> -#include "udev.h" #include "sd-hwdb.h" #include "hwdb-util.h" +#include "string-util.h" #include "udev-util.h" +#include "udev.h" static sd_hwdb *hwdb; diff --git a/src/udev/udev-builtin-input_id.c b/src/udev/udev-builtin-input_id.c index e3fa4bc162..f36f719a94 100644 --- a/src/udev/udev-builtin-input_id.c +++ b/src/udev/udev-builtin-input_id.c @@ -21,15 +21,16 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <errno.h> +#include <stdarg.h> #include <stdio.h> #include <stdlib.h> -#include <stdarg.h> -#include <unistd.h> #include <string.h> -#include <errno.h> +#include <unistd.h> #include <linux/limits.h> #include <linux/input.h> +#include "string-util.h" #include "udev.h" #include "util.h" diff --git a/src/udev/udev-builtin-keyboard.c b/src/udev/udev-builtin-keyboard.c index d63a8e2760..ce534ae0f9 100644 --- a/src/udev/udev-builtin-keyboard.c +++ b/src/udev/udev-builtin-keyboard.c @@ -18,11 +18,12 @@ ***/ #include <stdio.h> -#include <string.h> #include <stdlib.h> +#include <string.h> #include <sys/ioctl.h> #include <linux/input.h> +#include "string-util.h" #include "udev.h" static const struct key *keyboard_lookup_key(const char *str, unsigned len); diff --git a/src/udev/udev-builtin-kmod.c b/src/udev/udev-builtin-kmod.c index 81e78a8aa3..9665f678fd 100644 --- a/src/udev/udev-builtin-kmod.c +++ b/src/udev/udev-builtin-kmod.c @@ -18,12 +18,13 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> #include <errno.h> #include <libkmod.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include "string-util.h" #include "udev.h" static struct kmod_ctx *ctx = NULL; diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c index 589f1f7822..bb721d6f0d 100644 --- a/src/udev/udev-builtin-net_id.c +++ b/src/udev/udev-builtin-net_id.c @@ -87,19 +87,20 @@ * ID_NET_NAME_PATH=enp0s29u1u2 */ -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> -#include <unistd.h> -#include <fcntl.h> -#include <string.h> #include <errno.h> +#include <fcntl.h> #include <net/if.h> #include <net/if_arp.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> #include <linux/pci_regs.h> -#include "udev.h" #include "fileio.h" +#include "string-util.h" +#include "udev.h" enum netname_type{ NET_UNDEF, diff --git a/src/udev/udev-builtin-path_id.c b/src/udev/udev-builtin-path_id.c index 01e2c659ae..2c40988c7a 100644 --- a/src/udev/udev-builtin-path_id.c +++ b/src/udev/udev-builtin-path_id.c @@ -19,17 +19,18 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> -#include <unistd.h> -#include <string.h> #include <ctype.h> -#include <fcntl.h> -#include <errno.h> #include <dirent.h> +#include <errno.h> +#include <fcntl.h> #include <getopt.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include "string-util.h" #include "udev.h" _printf_(2,3) diff --git a/src/udev/udev-builtin-usb_id.c b/src/udev/udev-builtin-usb_id.c index d309dc31cb..c7d47891a7 100644 --- a/src/udev/udev-builtin-usb_id.c +++ b/src/udev/udev-builtin-usb_id.c @@ -20,15 +20,16 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <ctype.h> +#include <errno.h> +#include <fcntl.h> +#include <stdarg.h> #include <stdio.h> #include <stdlib.h> -#include <stdarg.h> -#include <unistd.h> #include <string.h> -#include <ctype.h> -#include <fcntl.h> -#include <errno.h> +#include <unistd.h> +#include "string-util.h" #include "udev.h" static void set_usb_iftype(char *to, int if_class_num, size_t len) { diff --git a/src/udev/udev-builtin.c b/src/udev/udev-builtin.c index 4f625251d6..e6b36f124f 100644 --- a/src/udev/udev-builtin.c +++ b/src/udev/udev-builtin.c @@ -17,10 +17,11 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ +#include <getopt.h> #include <stdio.h> #include <string.h> -#include <getopt.h> +#include "string-util.h" #include "udev.h" static bool initialized; diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c index 1e34cbc2f5..49a45811a6 100644 --- a/src/udev/udev-event.c +++ b/src/udev/udev-event.c @@ -15,26 +15,27 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <stdlib.h> -#include <stdio.h> -#include <stddef.h> -#include <unistd.h> -#include <fcntl.h> -#include <errno.h> #include <ctype.h> -#include <string.h> +#include <errno.h> +#include <fcntl.h> #include <net/if.h> -#include <sys/prctl.h> #include <poll.h> +#include <stddef.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> #include <sys/epoll.h> -#include <sys/wait.h> +#include <sys/prctl.h> #include <sys/signalfd.h> +#include <sys/wait.h> +#include <unistd.h> -#include "netlink-util.h" #include "event-util.h" #include "formats-util.h" +#include "netlink-util.h" #include "process-util.h" #include "signal-util.h" +#include "string-util.h" #include "udev.h" typedef struct Spawn { diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c index e730fb45f1..4ed6416ecd 100644 --- a/src/udev/udev-node.c +++ b/src/udev/udev-node.c @@ -15,20 +15,21 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <string.h> -#include <stdio.h> -#include <stddef.h> -#include <stdbool.h> -#include <fcntl.h> -#include <unistd.h> -#include <errno.h> #include <dirent.h> +#include <errno.h> +#include <fcntl.h> +#include <stdbool.h> +#include <stddef.h> +#include <stdio.h> +#include <string.h> #include <sys/stat.h> +#include <unistd.h> -#include "udev.h" -#include "smack-util.h" -#include "selinux-util.h" #include "formats-util.h" +#include "selinux-util.h" +#include "smack-util.h" +#include "string-util.h" +#include "udev.h" static int node_symlink(struct udev_device *dev, const char *node, const char *slink) { struct stat stats; diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index 62db0016eb..c8abac7fef 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -33,10 +33,11 @@ #include "escape.h" #include "path-util.h" #include "strbuf.h" +#include "string-util.h" #include "strv.h" #include "sysctl-util.h" -#include "util.h" #include "udev.h" +#include "util.h" #define PREALLOC_TOKEN 2048 diff --git a/src/udev/udev.h b/src/udev/udev.h index d17fc8c1ea..1f9c8120c0 100644 --- a/src/udev/udev.h +++ b/src/udev/udev.h @@ -18,16 +18,17 @@ #pragma once -#include <sys/types.h> #include <sys/param.h> +#include <sys/types.h> -#include "macro.h" -#include "sd-netlink.h" #include "libudev.h" -#include "libudev-private.h" -#include "util.h" +#include "sd-netlink.h" + #include "label.h" +#include "libudev-private.h" +#include "macro.h" #include "strv.h" +#include "util.h" struct udev_event { struct udev *udev; diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c index 00609e31b5..f9509ad640 100644 --- a/src/udev/udevadm-hwdb.c +++ b/src/udev/udevadm-hwdb.c @@ -17,18 +17,18 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include <stdlib.h> +#include <ctype.h> #include <getopt.h> +#include <stdlib.h> #include <string.h> -#include <ctype.h> -#include "util.h" -#include "strbuf.h" #include "conf-files.h" - -#include "udev.h" #include "hwdb-internal.h" #include "hwdb-util.h" +#include "strbuf.h" +#include "string-util.h" +#include "udev.h" +#include "util.h" /* * Generic udev properties, key/value database based on modalias strings. diff --git a/src/udev/udevadm-info.c b/src/udev/udevadm-info.c index b3d5565c48..911818eb00 100644 --- a/src/udev/udevadm-info.c +++ b/src/udev/udevadm-info.c @@ -15,19 +15,20 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <string.h> -#include <stdio.h> -#include <stddef.h> #include <ctype.h> -#include <unistd.h> #include <dirent.h> #include <errno.h> -#include <getopt.h> #include <fcntl.h> +#include <getopt.h> +#include <stddef.h> +#include <stdio.h> +#include <string.h> #include <sys/stat.h> +#include <unistd.h> -#include "udev.h" +#include "string-util.h" #include "udev-util.h" +#include "udev.h" #include "udevadm-util.h" static bool skip_attribute(const char *name) { diff --git a/src/udev/udevadm-test-builtin.c b/src/udev/udevadm-test-builtin.c index 35a7349439..0b180d03eb 100644 --- a/src/udev/udevadm-test-builtin.c +++ b/src/udev/udevadm-test-builtin.c @@ -15,12 +15,13 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <stdlib.h> -#include <stddef.h> -#include <stdio.h> #include <errno.h> #include <getopt.h> +#include <stddef.h> +#include <stdio.h> +#include <stdlib.h> +#include "string-util.h" #include "udev.h" static void help(struct udev *udev) { diff --git a/src/udev/udevadm-test.c b/src/udev/udevadm-test.c index d04e618d0d..ff427cf292 100644 --- a/src/udev/udevadm-test.c +++ b/src/udev/udevadm-test.c @@ -16,17 +16,18 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <stdlib.h> -#include <stdio.h> -#include <stddef.h> -#include <unistd.h> #include <errno.h> -#include <signal.h> #include <getopt.h> +#include <signal.h> +#include <stddef.h> +#include <stdio.h> +#include <stdlib.h> #include <sys/signalfd.h> +#include <unistd.h> -#include "udev.h" +#include "string-util.h" #include "udev-util.h" +#include "udev.h" static void help(void) { diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c index 7af9665f8a..9d52345d92 100644 --- a/src/udev/udevadm-trigger.c +++ b/src/udev/udevadm-trigger.c @@ -15,16 +15,17 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <errno.h> +#include <fcntl.h> +#include <getopt.h> #include <stddef.h> -#include <string.h> #include <stdio.h> +#include <string.h> #include <unistd.h> -#include <getopt.h> -#include <errno.h> -#include <fcntl.h> -#include "udev.h" +#include "string-util.h" #include "udev-util.h" +#include "udev.h" #include "udevadm-util.h" #include "util.h" diff --git a/src/udev/udevadm-util.c b/src/udev/udevadm-util.c index 3f0e45e26c..3539c1d6ab 100644 --- a/src/udev/udevadm-util.c +++ b/src/udev/udevadm-util.c @@ -15,6 +15,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "string-util.h" #include "udevadm-util.h" struct udev_device *find_device(struct udev *udev, diff --git a/src/udev/udevadm.c b/src/udev/udevadm.c index b86d8921f3..60f122ebda 100644 --- a/src/udev/udevadm.c +++ b/src/udev/udevadm.c @@ -16,12 +16,13 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <stdio.h> -#include <stddef.h> #include <errno.h> #include <getopt.h> +#include <stddef.h> +#include <stdio.h> #include "selinux-util.h" +#include "string-util.h" #include "udev.h" static int adm_version(struct udev *udev, int argc, char *argv[]) { diff --git a/src/udev/udevd.c b/src/udev/udevd.c index e4d2f47745..a3f0298ae7 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -54,6 +54,7 @@ #include "process-util.h" #include "selinux-util.h" #include "signal-util.h" +#include "string-util.h" #include "terminal-util.h" #include "udev-util.h" #include "udev.h" |