]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: rename UTIL_LINE_SIZE -> UDEV_LINE_SIZE and friends
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 14 Dec 2020 07:45:12 +0000 (16:45 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 15 Dec 2020 17:22:58 +0000 (02:22 +0900)
This also moves them to udev-util.h

src/libudev/libudev-util.h
src/shared/udev-util.h
src/udev/udev-builtin-path_id.c
src/udev/udev-builtin-usb_id.c
src/udev/udev-event.c
src/udev/udev-rules.c
src/udev/udevadm-test.c

index f03e9eb22106c314bdf2d0b5d7b748b183d7d84e..0dc18d44be320b01dd5d922a9b2f2093c9578c75 100644 (file)
@@ -5,11 +5,6 @@
 
 #include "macro.h"
 
-/* libudev-util.c */
-#define UTIL_PATH_SIZE                      1024
-#define UTIL_NAME_SIZE                       512
-#define UTIL_LINE_SIZE                     16384
-
 /* Cleanup functions */
 DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev*, udev_unref);
 DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_device*, udev_device_unref);
index 94ec970c50330d0452aaa262b82c4683e5f3b0a5..61ce4eaac98b4d17acc70ed8997f1a62ecb1a9cc 100644 (file)
@@ -6,6 +6,10 @@
 #include "device-private.h"
 #include "time-util.h"
 
+#define UDEV_NAME_SIZE   512
+#define UDEV_PATH_SIZE  1024
+#define UDEV_LINE_SIZE 16384
+
 typedef enum ResolveNameTiming {
         RESOLVE_NAME_NEVER,
         RESOLVE_NAME_LATE,
index 0da59e2c756e589570aa2431ca0fd87da2ecc810..6552c53ce35af2526f1f65f64242ea976a4fafb9 100644 (file)
@@ -22,6 +22,7 @@
 #include "strv.h"
 #include "sysexits.h"
 #include "udev-builtin.h"
+#include "udev-util.h"
 
 _printf_(2,3)
 static void path_prepend(char **path, const char *fmt, ...) {
@@ -680,7 +681,7 @@ static int builtin_path_id(sd_device *dev, int argc, char *argv[], bool test) {
                 return -ENOENT;
 
         {
-                char tag[UTIL_NAME_SIZE];
+                char tag[UDEV_NAME_SIZE];
                 size_t i;
                 const char *p;
 
index b74f7c057aa364fda92000a13c7bc25df35ceb37..75915ab39c862fbfa05b3a0e2c379b7aea4e284c 100644 (file)
@@ -235,8 +235,8 @@ static int builtin_usb_id(sd_device *dev, int argc, char *argv[], bool test) {
         char model_str[64] = "";
         char model_str_enc[256];
         const char *product_id;
-        char serial_str[UTIL_NAME_SIZE] = "";
-        char packed_if_str[UTIL_NAME_SIZE] = "";
+        char serial_str[UDEV_NAME_SIZE] = "";
+        char packed_if_str[UDEV_NAME_SIZE] = "";
         char revision_str[64] = "";
         char type_str[64] = "";
         char instance_str[64] = "";
index c36f0bb732ecfa273d002ab828dd026b94569000..62816b0852621f8af5631a61642975870a4fa3b5 100644 (file)
@@ -152,7 +152,7 @@ static char format_type_to_char(FormatSubstitutionType t) {
         return '\0';
 }
 
-static int get_subst_type(const char **str, bool strict, FormatSubstitutionType *ret_type, char ret_attr[static UTIL_PATH_SIZE]) {
+static int get_subst_type(const char **str, bool strict, FormatSubstitutionType *ret_type, char ret_attr[static UDEV_PATH_SIZE]) {
         const char *p = *str, *q = NULL;
         size_t i;
 
@@ -198,10 +198,10 @@ static int get_subst_type(const char **str, bool strict, FormatSubstitutionType
                         return -EINVAL;
 
                 len = end - start;
-                if (len == 0 || len >= UTIL_PATH_SIZE)
+                if (len == 0 || len >= UDEV_PATH_SIZE)
                         return -EINVAL;
 
-                strnscpy(ret_attr, UTIL_PATH_SIZE, start, len);
+                strnscpy(ret_attr, UDEV_PATH_SIZE, start, len);
                 q = end + 1;
         } else
                 *ret_attr = '\0';
@@ -339,7 +339,7 @@ static ssize_t udev_event_subst_format(
                 break;
         }
         case FORMAT_SUBST_ATTR: {
-                char vbuf[UTIL_NAME_SIZE];
+                char vbuf[UDEV_NAME_SIZE];
                 int count;
 
                 if (isempty(attr))
@@ -453,7 +453,7 @@ size_t udev_event_apply_format(UdevEvent *event,
 
         while (*s) {
                 FormatSubstitutionType type;
-                char attr[UTIL_PATH_SIZE];
+                char attr[UDEV_PATH_SIZE];
                 ssize_t subst_len;
 
                 r = get_subst_type(&s, false, &type, attr);
@@ -494,7 +494,7 @@ size_t udev_event_apply_format(UdevEvent *event,
 int udev_check_format(const char *value, size_t *offset, const char **hint) {
         FormatSubstitutionType type;
         const char *s = value;
-        char attr[UTIL_PATH_SIZE];
+        char attr[UDEV_PATH_SIZE];
         int r;
 
         while (*s) {
index c050eea56f4557fd7281820402be2c53fbd63da9..e9f00dfd0e67b954310c252350bde578319f6c48 100644 (file)
@@ -1224,7 +1224,7 @@ int udev_rules_parse_file(UdevRules *rules, const char *filename) {
                 size_t len;
                 char *line;
 
-                r = read_line(f, UTIL_LINE_SIZE, &buf);
+                r = read_line(f, UDEV_LINE_SIZE, &buf);
                 if (r < 0)
                         return r;
                 if (r == 0)
@@ -1239,7 +1239,7 @@ int udev_rules_parse_file(UdevRules *rules, const char *filename) {
                 len = strlen(line);
 
                 if (continuation && !ignore_line) {
-                        if (strlen(continuation) + len >= UTIL_LINE_SIZE)
+                        if (strlen(continuation) + len >= UDEV_LINE_SIZE)
                                 ignore_line = true;
 
                         if (!strextend(&continuation, line, NULL))
@@ -1377,7 +1377,7 @@ static bool token_match_string(UdevRuleToken *token, const char *str) {
 }
 
 static bool token_match_attr(UdevRuleToken *token, sd_device *dev, UdevEvent *event) {
-        char nbuf[UTIL_NAME_SIZE], vbuf[UTIL_NAME_SIZE];
+        char nbuf[UDEV_NAME_SIZE], vbuf[UDEV_NAME_SIZE];
         const char *name, *value;
 
         assert(token);
@@ -1487,10 +1487,10 @@ static int import_parent_into_properties(sd_device *dev, const char *filter) {
         return 1;
 }
 
-static int attr_subst_subdir(char attr[static UTIL_PATH_SIZE]) {
+static int attr_subst_subdir(char attr[static UDEV_PATH_SIZE]) {
         _cleanup_closedir_ DIR *dir = NULL;
         struct dirent *dent;
-        char buf[UTIL_PATH_SIZE], *p;
+        char buf[UDEV_PATH_SIZE], *p;
         const char *tail;
         size_t len, size;
 
@@ -1535,7 +1535,7 @@ static int udev_rule_apply_token_to_event(
                 Hashmap *properties_list) {
 
         UdevRuleToken *token;
-        char buf[UTIL_PATH_SIZE];
+        char buf[UDEV_PATH_SIZE];
         const char *val;
         size_t count;
         bool match;
@@ -1642,7 +1642,7 @@ static int udev_rule_apply_token_to_event(
                 (void) udev_event_apply_format(event, token->value, buf, sizeof(buf), false);
                 if (!path_is_absolute(buf) &&
                     udev_resolve_subsys_kernel(buf, buf, sizeof(buf), false) < 0) {
-                        char tmp[UTIL_PATH_SIZE];
+                        char tmp[UDEV_PATH_SIZE];
 
                         r = sd_device_get_syspath(dev, &val);
                         if (r < 0)
@@ -1668,7 +1668,7 @@ static int udev_rule_apply_token_to_event(
                 return token->op == (match ? OP_MATCH : OP_NOMATCH);
         }
         case TK_M_PROGRAM: {
-                char result[UTIL_LINE_SIZE];
+                char result[UDEV_LINE_SIZE];
 
                 event->program_result = mfree(event->program_result);
                 (void) udev_event_apply_format(event, token->value, buf, sizeof(buf), false);
@@ -1739,7 +1739,7 @@ static int udev_rule_apply_token_to_event(
                 return token->op == OP_MATCH;
         }
         case TK_M_IMPORT_PROGRAM: {
-                char result[UTIL_LINE_SIZE], *line, *pos;
+                char result[UDEV_LINE_SIZE], *line, *pos;
 
                 (void) udev_event_apply_format(event, token->value, buf, sizeof(buf), false);
                 log_rule_debug(dev, rules, "Importing properties from results of '%s'", buf);
@@ -1888,7 +1888,7 @@ static int udev_rule_apply_token_to_event(
                 break;
         }
         case TK_A_OWNER: {
-                char owner[UTIL_NAME_SIZE];
+                char owner[UDEV_NAME_SIZE];
                 const char *ow = owner;
 
                 if (event->owner_final)
@@ -1905,7 +1905,7 @@ static int udev_rule_apply_token_to_event(
                 break;
         }
         case TK_A_GROUP: {
-                char group[UTIL_NAME_SIZE];
+                char group[UDEV_NAME_SIZE];
                 const char *gr = group;
 
                 if (event->group_final)
@@ -1922,7 +1922,7 @@ static int udev_rule_apply_token_to_event(
                 break;
         }
         case TK_A_MODE: {
-                char mode_str[UTIL_NAME_SIZE];
+                char mode_str[UDEV_NAME_SIZE];
 
                 if (event->mode_final)
                         break;
@@ -1969,7 +1969,7 @@ static int udev_rule_apply_token_to_event(
                 break;
         case TK_A_SECLABEL: {
                 _cleanup_free_ char *name = NULL, *label = NULL;
-                char label_str[UTIL_LINE_SIZE] = {};
+                char label_str[UDEV_LINE_SIZE] = {};
 
                 name = strdup(token->data);
                 if (!name)
@@ -1999,7 +1999,7 @@ static int udev_rule_apply_token_to_event(
         }
         case TK_A_ENV: {
                 const char *name = token->data;
-                char value_new[UTIL_NAME_SIZE], *p = value_new;
+                char value_new[UDEV_NAME_SIZE], *p = value_new;
                 size_t l = sizeof(value_new);
 
                 if (isempty(token->value)) {
@@ -2092,7 +2092,7 @@ static int udev_rule_apply_token_to_event(
 
                 p = skip_leading_chars(buf, NULL);
                 while (!isempty(p)) {
-                        char filename[UTIL_PATH_SIZE], *next;
+                        char filename[UDEV_PATH_SIZE], *next;
 
                         next = strchr(p, ' ');
                         if (next) {
@@ -2112,7 +2112,7 @@ static int udev_rule_apply_token_to_event(
         }
         case TK_A_ATTR: {
                 const char *key_name = token->data;
-                char value[UTIL_NAME_SIZE];
+                char value[UDEV_NAME_SIZE];
 
                 if (udev_resolve_subsys_kernel(key_name, buf, sizeof(buf), false) < 0 &&
                     sd_device_get_syspath(dev, &val) >= 0)
@@ -2132,7 +2132,7 @@ static int udev_rule_apply_token_to_event(
                 break;
         }
         case TK_A_SYSCTL: {
-                char value[UTIL_NAME_SIZE];
+                char value[UDEV_NAME_SIZE];
 
                 (void) udev_event_apply_format(event, token->data, buf, sizeof(buf), false);
                 (void) udev_event_apply_format(event, token->value, value, sizeof(value), false);
@@ -2305,7 +2305,7 @@ int udev_rules_apply_to_event(
 }
 
 static int apply_static_dev_perms(const char *devnode, uid_t uid, gid_t gid, mode_t mode, char **tags) {
-        char device_node[UTIL_PATH_SIZE], tags_dir[UTIL_PATH_SIZE], tag_symlink[UTIL_PATH_SIZE];
+        char device_node[UDEV_PATH_SIZE], tags_dir[UDEV_PATH_SIZE], tag_symlink[UDEV_PATH_SIZE];
         _cleanup_free_ char *unescaped_filename = NULL;
         struct stat stats;
         char **t;
index 747047dac87657a6deb8b0f98aaf9a73d426244e..7f8e23108772731a25bcdf86a98ea9716c5af4af 100644 (file)
@@ -26,7 +26,7 @@
 
 static const char *arg_action = "add";
 static ResolveNameTiming arg_resolve_name_timing = RESOLVE_NAME_EARLY;
-static char arg_syspath[UTIL_PATH_SIZE] = {};
+static char arg_syspath[UDEV_PATH_SIZE] = {};
 
 static int help(void) {
 
@@ -149,7 +149,7 @@ int test_main(int argc, char *argv[], void *userdata) {
                 printf("%s=%s\n", key, value);
 
         ORDERED_HASHMAP_FOREACH_KEY(val, cmd, event->run_list) {
-                char program[UTIL_PATH_SIZE];
+                char program[UDEV_PATH_SIZE];
 
                 (void) udev_event_apply_format(event, cmd, program, sizeof(program), false);
                 printf("run: '%s'\n", program);