]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev-event: use normal pointer ops where appropriate
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 27 Jun 2019 06:58:00 +0000 (08:58 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 28 Jun 2019 14:20:48 +0000 (16:20 +0200)
src/udev/udev-event.c

index 09eb56b97de095d0ced8460e6ee12c190d3c86fd..0f74fe340a7ef23ed2a5667e4bd769e19f9e60e7 100644 (file)
@@ -157,24 +157,24 @@ static int get_subst_type(const char **str, bool strict, FormatSubstitutionType
         assert(*str);
         assert(ret_type);
 
-        if (p[0] == '$') {
+        if (*p == '$') {
                 p++;
-                if (p[0] == '$') {
+                if (*p == '$') {
                         *str = p;
                         return 0;
                 }
                 for (i = 0; i < ELEMENTSOF(map); i++)
                         if ((q = startswith(p, map[i].name)))
                                 break;
-        } else if (p[0] == '%') {
+        } else if (*p == '%') {
                 p++;
-                if (p[0] == '%') {
+                if (*p == '%') {
                         *str = p;
                         return 0;
                 }
 
                 for (i = 0; i < ELEMENTSOF(map); i++)
-                        if (p[0] == map[i].fmt) {
+                        if (*p == map[i].fmt) {
                                 q = p + 1;
                                 break;
                         }
@@ -184,7 +184,7 @@ static int get_subst_type(const char **str, bool strict, FormatSubstitutionType
                 /* When 'strict' flag is set, then '$' and '%' must be escaped. */
                 return strict ? -EINVAL : 0;
 
-        if (q[0] == '{') {
+        if (*q == '{') {
                 const char *start, *end;
                 size_t len;
 
@@ -200,7 +200,7 @@ static int get_subst_type(const char **str, bool strict, FormatSubstitutionType
                 strnscpy(ret_attr, UTIL_PATH_SIZE, start, len);
                 q = end + 1;
         } else
-                ret_attr[0] = '\0';
+                *ret_attr = '\0';
 
         *str = q;
         *ret_type = map[i].type;
@@ -311,7 +311,7 @@ static ssize_t udev_event_subst_format(
                         p = skip_leading_chars(event->program_result, NULL);
 
                         for (i = 1; i < index; i++) {
-                                while (p[0] != '\0' && !strchr(WHITESPACE, p[0]))
+                                while (*p && !strchr(WHITESPACE, *p))
                                         p++;
                                 p = skip_leading_chars(p, NULL);
                                 if (*p == '\0')
@@ -327,7 +327,7 @@ static ssize_t udev_event_subst_format(
                         if (has_plus)
                                 l = strpcpy(&s, l, start);
                         else {
-                                while (p[0] != '\0' && !strchr(WHITESPACE, p[0]))
+                                while (*p && !strchr(WHITESPACE, *p))
                                         p++;
                                 l = strnpcpy(&s, l, start, p - start);
                         }
@@ -447,7 +447,7 @@ ssize_t udev_event_apply_format(UdevEvent *event,
         assert(dest);
         assert(size > 0);
 
-        while (s[0] != '\0') {
+        while (*s) {
                 FormatSubstitutionType type;
                 char attr[UTIL_PATH_SIZE];
                 ssize_t subst_len;
@@ -480,7 +480,7 @@ ssize_t udev_event_apply_format(UdevEvent *event,
         }
 
         assert(size >= 1);
-        dest[0] = '\0';
+        *dest = '\0';
         return size;
 }
 
@@ -489,7 +489,7 @@ int udev_check_format(const char *s) {
         char attr[UTIL_PATH_SIZE];
         int r;
 
-        while (s[0] != '\0') {
+        while (*s) {
                 r = get_subst_type(&s, true, &type, attr);
                 if (r < 0)
                         return r;