]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/idmapping.c: get_map_ranges(): Rename local variable
authorAlejandro Colomar <alx@kernel.org>
Thu, 11 Jan 2024 11:04:23 +0000 (12:04 +0100)
committerSerge Hallyn <serge@hallyn.com>
Fri, 12 Jul 2024 03:42:58 +0000 (22:42 -0500)
For a pointer iterator used often, a single-letter identifier is more
appropriate.  That reduces the length of lines considerably, avoiding
unnecessary line breaks.  And since we initialize it with

m = mappings;

it's clear what it is.

Link: <https://github.com/shadow-maint/shadow/commit/ff2baed5dbf81e8967b805889f565fedb48600df#r136635300>
Cc: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/idmapping.c

index 5cbb6fefc0bda0962292fb775aed1d93c2945c3e..6bf7a4f93758f2ed4ffafca1bec89862b3dc4663 100644 (file)
@@ -29,7 +29,7 @@
 
 struct map_range *get_map_ranges(int ranges, int argc, char **argv)
 {
-       struct map_range *mappings, *mapping;
+       struct map_range *mappings, *m;
        int idx, argidx;
 
        if (ranges < 0 || argc < 0) {
@@ -50,37 +50,33 @@ struct map_range *get_map_ranges(int ranges, int argc, char **argv)
        }
 
        /* Gather up the ranges from the command line */
-       mapping = mappings;
-       for (idx = 0, argidx = 0; idx < ranges; idx++, argidx += 3, mapping++) {
-               if (str2ul(&mapping->upper, argv[argidx + 0]) == -1) {
+       m = mappings;
+       for (idx = 0, argidx = 0; idx < ranges; idx++, argidx += 3, m++) {
+               if (str2ul(&m->upper, argv[argidx + 0]) == -1) {
                        free(mappings);
                        return NULL;
                }
-               if (str2ul(&mapping->lower, argv[argidx + 1]) == -1) {
+               if (str2ul(&m->lower, argv[argidx + 1]) == -1) {
                        free(mappings);
                        return NULL;
                }
-               if (str2ul(&mapping->count, argv[argidx + 2]) == -1) {
+               if (str2ul(&m->count, argv[argidx + 2]) == -1) {
                        free(mappings);
                        return NULL;
                }
-               if (ULONG_MAX - mapping->upper <= mapping->count || ULONG_MAX - mapping->lower <= mapping->count) {
+               if (ULONG_MAX - m->upper <= m->count || ULONG_MAX - m->lower <= m->count) {
                        fprintf(log_get_logfd(), _( "%s: subuid overflow detected.\n"), log_get_progname());
                        exit(EXIT_FAILURE);
                }
-               if (mapping->upper > UINT_MAX ||
-                       mapping->lower > UINT_MAX ||
-                       mapping->count > UINT_MAX)  {
+               if (m->upper > UINT_MAX || m->lower > UINT_MAX || m->count > UINT_MAX)  {
                        fprintf(log_get_logfd(), _( "%s: subuid overflow detected.\n"), log_get_progname());
                        exit(EXIT_FAILURE);
                }
-               if (mapping->lower + mapping->count > UINT_MAX ||
-                               mapping->upper + mapping->count > UINT_MAX) {
+               if (m->lower + m->count > UINT_MAX || m->upper + m->count > UINT_MAX) {
                        fprintf(log_get_logfd(), _( "%s: subuid overflow detected.\n"), log_get_progname());
                        exit(EXIT_FAILURE);
                }
-               if (mapping->lower + mapping->count < mapping->lower ||
-                               mapping->upper + mapping->count < mapping->upper) {
+               if (m->lower + m->count < m->lower || m->upper + m->count < m->upper) {
                        /* this one really shouldn't be possible given previous checks */
                        fprintf(log_get_logfd(), _( "%s: subuid overflow detected.\n"), log_get_progname());
                        exit(EXIT_FAILURE);