]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
maint: fix shadow declaration
authorSami Kerola <kerolasa@iki.fi>
Wed, 31 Dec 2014 23:01:21 +0000 (23:01 +0000)
committerKarel Zak <kzak@redhat.com>
Wed, 7 Jan 2015 09:08:21 +0000 (10:08 +0100)
This change fixes all shadow declarations.  The worth while to mention
fix is with libfdisk sun geometry.  It comes from bitops.h cpu_to_be16
macro that further expands from include/bits/byteswap.h that has the
shadowing.

libfdisk/src/sun.c:961:173: warning: declaration of '__v' shadows a previous local [-Wshadow]
libfdisk/src/sun.c:961:69: warning: shadowed declaration is here [-Wshadow]
libfdisk/src/sun.c:961:178: warning: declaration of '__x' shadows a previous local [-Wshadow]
libfdisk/src/sun.c:961:74: warning: shadowed declaration is here [-Wshadow]

That could have caused earlier some unexpected results.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
disk-utils/cfdisk.c
disk-utils/fsck.cramfs.c
libfdisk/src/sun.c
libfdisk/src/table.c
libmount/src/tab_parse.c
libsmartcols/src/table_print.c
login-utils/lslogins.c
misc-utils/findmnt.c
misc-utils/lslocks.c
sys-utils/swapon.c
sys-utils/zramctl.c

index 60a9535243641c91462661aa1683dac666244469..1d4e2d579ee3c3c240a474901f20b549160975ea 100644 (file)
@@ -505,7 +505,7 @@ static int ask_menu(struct fdisk_ask *ask, struct cfdisk *cf)
 
        /* wait for keys */
        do {
-               int key = getch();
+               key = getch();
 
                if (ui_resize)
                        ui_menu_resize(cf);
@@ -2006,7 +2006,6 @@ static int main_menu_action(struct cfdisk *cf, int key)
        case 'W': /* Write */
        {
                char buf[64] = { 0 };
-               int rc;
 
                if (fdisk_is_readonly(cf->cxt)) {
                        warn = _("Device open in read-only mode");
@@ -2098,8 +2097,9 @@ static int ui_run(struct cfdisk *cf)
                ui_warnx(_("Device open in read-only mode."));
 
        do {
-               int rc = 0, key = getch();
+               int key = getch();
 
+               rc = 0;
                if (ui_resize)
                        /* Note that ncurses getch() returns ERR when interrupted
                         * by signal, but SLang does not interrupt at all. */
index 6b4b69e926de097e2eab7f9c1fe9413e7cd67a60..419b9acb500cb04054a22b584ac52b81721b7f21 100644 (file)
@@ -101,25 +101,26 @@ static size_t blksize = 0;
 /* Input status of 0 to print help and exit without an error. */
 static void __attribute__((__noreturn__)) usage(int status)
 {
-       FILE *stream = status ? stderr : stdout;
+       FILE *out = status ? stderr : stdout;
 
-       fputs(USAGE_HEADER, stream);
-       fprintf(stream,
+       fputs(USAGE_HEADER, out);
+       fprintf(out,
                _(" %s [options] <file>\n"), program_invocation_short_name);
 
-       fputs(USAGE_SEPARATOR, stream);
-       fputs(_("Check and repair a compressed ROM filesystem.\n"), stream);
-
-       fputs(USAGE_OPTIONS, stream);
-       fputs(_(" -a                       for compatibility only, ignored\n"), stream);
-       fputs(_(" -v, --verbose            be more verbose\n"), stream);
-       fputs(_(" -y                       for compatibility only, ignored\n"), stream);
-       fputs(_(" -b, --blocksize <size>   use this blocksize, defaults to page size\n"), stream);
-       fputs(_("     --extract[=<dir>]    test uncompression, optionally extract into <dir>\n"), stream);
-       fputs(USAGE_SEPARATOR, stream);
-       fputs(USAGE_HELP, stream);
-       fputs(USAGE_VERSION, stream);
-       fputs(USAGE_SEPARATOR, stream);
+       fputs(USAGE_SEPARATOR, out);
+       fputs(_("Check and repair a compressed ROM filesystem.\n"), out);
+
+       fputs(USAGE_OPTIONS, out);
+       fputs(_(" -a                       for compatibility only, ignored\n"), out);
+       fputs(_(" -v, --verbose            be more verbose\n"), out);
+       fputs(_(" -y                       for compatibility only, ignored\n"), out);
+       fputs(_(" -b, --blocksize <size>   use this blocksize, defaults to page size\n"), out);
+       fputs(_("     --extract[=<dir>]    test uncompression, optionally extract into <dir>\n"), out);
+       fputs(USAGE_SEPARATOR, out);
+       fputs(USAGE_HELP, out);
+       fputs(USAGE_VERSION, out);
+       fputs(USAGE_SEPARATOR, out);
+
        exit(status);
 }
 
@@ -364,7 +365,7 @@ static int uncompress_block(void *src, size_t len)
 #define lchown chown
 #endif
 
-static void do_uncompress(char *path, int fd, unsigned long offset,
+static void do_uncompress(char *path, int outfd, unsigned long offset,
                          unsigned long size)
 {
        unsigned long curr = offset + 4 * ((size + blksize - 1) / blksize);
@@ -404,7 +405,7 @@ static void do_uncompress(char *path, int fd, unsigned long offset,
                }
                size -= out;
                if (*extract_dir != '\0')
-                       if (write(fd, outbuffer, out) < 0)
+                       if (write(outfd, outbuffer, out) < 0)
                                err(FSCK_EX_ERROR, _("write failed: %s"),
                                    path);
                curr = next;
@@ -488,7 +489,7 @@ static void do_directory(char *path, struct cramfs_inode *i)
 static void do_file(char *path, struct cramfs_inode *i)
 {
        unsigned long offset = i->offset << 2;
-       int fd = 0;
+       int outfd = 0;
 
        if (offset == 0 && i->size != 0)
                errx(FSCK_EX_UNCORRECTED,
@@ -501,14 +502,14 @@ static void do_file(char *path, struct cramfs_inode *i)
        if (opt_verbose)
                print_node('f', i, path);
        if (*extract_dir != '\0') {
-               fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, i->mode);
-               if (fd < 0)
+               outfd = open(path, O_WRONLY | O_CREAT | O_TRUNC, i->mode);
+               if (outfd < 0)
                        err(FSCK_EX_ERROR, _("cannot open %s"), path);
        }
        if (i->size)
-               do_uncompress(path, fd, offset, i->size);
+               do_uncompress(path, outfd, offset, i->size);
        if ( *extract_dir != '\0') {
-               if (close_fd(fd) != 0)
+               if (close_fd(outfd) != 0)
                        err(FSCK_EX_ERROR, _("write failed: %s"), path);
                change_file_status(path, i);
        }
index babff6263cc5780eb3607c3bb5d85cc56e37a6bd..d99c39f6f5732c150de83b80c98e42c727717fc3 100644 (file)
@@ -957,9 +957,11 @@ static int sun_write_disklabel(struct fdisk_context *cxt)
        sunlabel->nhead = cpu_to_be16(cxt->geom.heads);
        sunlabel->nsect = cpu_to_be16(cxt->geom.sectors);
 
-       if (cxt->geom.cylinders != be16_to_cpu(sunlabel->ncyl))
-               sunlabel->ncyl = cpu_to_be16( cxt->geom.cylinders
-                                     - be16_to_cpu(sunlabel->acyl) );
+       if (cxt->geom.cylinders != be16_to_cpu(sunlabel->ncyl)) {
+               int a = cpu_to_be16(cxt->geom.cylinders);
+               int b = be16_to_cpu(sunlabel->acyl);
+               sunlabel->ncyl = a - b;
+       }
 
        ush = (unsigned short *) sunlabel;
 
index 1add09fca2a2e5b05529ed7ee85eccd3ca4daa63..9234814523ef4b0460cec212151345dd0fc3996b 100644 (file)
@@ -437,16 +437,16 @@ static int table_add_freespace(
        }
 
        while (fdisk_table_next_partition(tb, &itr, &x) == 0) {
-               fdisk_sector_t end, best_end = 0;
+               fdisk_sector_t the_end, best_end = 0;
 
                if (!fdisk_partition_has_end(x))
                        continue;
 
-               end = fdisk_partition_get_end(x);
+               the_end = fdisk_partition_get_end(x);
                if (best)
                        best_end = fdisk_partition_get_end(best);
 
-               if (end < pa->start && (!best || best_end < end))
+               if (the_end < pa->start && (!best || best_end < the_end))
                        best = x;
        }
 
index 58b71ca4e28f9307713c9093879aea684c64afb0..05496f7602e2dbb2e57d1f2ae10974a0a328ade1 100644 (file)
@@ -173,10 +173,10 @@ static int mnt_parse_mountinfo_line(struct libmnt_fs *fs, char *s)
                /* remove "(deleted)" suffix */
                sz = strlen(fs->target);
                if (sz > PATH_DELETED_SUFFIX_SZ) {
-                       char *p = fs->target + (sz - PATH_DELETED_SUFFIX_SZ);
+                       char *ptr = fs->target + (sz - PATH_DELETED_SUFFIX_SZ);
 
-                       if (strcmp(p, PATH_DELETED_SUFFIX) == 0)
-                               *p = '\0';
+                       if (strcmp(ptr, PATH_DELETED_SUFFIX) == 0)
+                               *ptr = '\0';
                }
 
                unmangle_string(fs->root);
index 4191515edaf994fdde915d57fb9214bef8b9b11d..542d8a22d7c4934adc1fa5c46e46a9a9b4c1bc95 100644 (file)
@@ -660,13 +660,13 @@ static int recount_widths(struct libscols_table *tb, struct libscols_buffer *buf
                        }
                } else if (width < tb->termwidth) {
                        /* enlarge the last column */
-                       struct libscols_column *cl = list_entry(
+                       struct libscols_column *col = list_entry(
                                tb->tb_columns.prev, struct libscols_column, cl_columns);
 
                        DBG(TAB, ul_debugobj(tb, "   enlarge width (last column)"));
 
-                       if (!scols_column_is_right(cl) && tb->termwidth - width > 0) {
-                               cl->width += tb->termwidth - width;
+                       if (!scols_column_is_right(col) && tb->termwidth - width > 0) {
+                               col->width += tb->termwidth - width;
                                width = tb->termwidth;
                        }
                }
index ef7096aec8b7a7f531cd9d8d12f918c78805c545..48ba6d8ad5911a168dd10af5cf2aa11d130a79ee 100644 (file)
@@ -892,33 +892,33 @@ static int create_usertree(struct lslogins_control *ctl)
 
 static struct libscols_table *setup_table(struct lslogins_control *ctl)
 {
-       struct libscols_table *tb = scols_new_table();
+       struct libscols_table *table = scols_new_table();
        int n = 0;
 
-       if (!tb)
+       if (!table)
                errx(EXIT_FAILURE, _("failed to initialize output table"));
        if (ctl->noheadings)
-               scols_table_enable_noheadings(tb, 1);
+               scols_table_enable_noheadings(table, 1);
 
        switch(outmode) {
        case OUT_COLON:
-               scols_table_enable_raw(tb, 1);
-               scols_table_set_column_separator(tb, ":");
+               scols_table_enable_raw(table, 1);
+               scols_table_set_column_separator(table, ":");
                break;
        case OUT_NEWLINE:
-               scols_table_set_column_separator(tb, "\n");
+               scols_table_set_column_separator(table, "\n");
                /* fallthrough */
        case OUT_EXPORT:
-               scols_table_enable_export(tb, 1);
+               scols_table_enable_export(table, 1);
                break;
        case OUT_NUL:
-               scols_table_set_line_separator(tb, "\0");
+               scols_table_set_line_separator(table, "\0");
                /* fallthrough */
        case OUT_RAW:
-               scols_table_enable_raw(tb, 1);
+               scols_table_enable_raw(table, 1);
                break;
        case OUT_PRETTY:
-               scols_table_enable_noheadings(tb, 1);
+               scols_table_enable_noheadings(table, 1);
        default:
                break;
        }
@@ -929,7 +929,7 @@ static struct libscols_table *setup_table(struct lslogins_control *ctl)
                if (ctl->notrunc)
                        flags &= ~SCOLS_FL_TRUNC;
 
-               if (!scols_table_new_column(tb,
+               if (!scols_table_new_column(table,
                                coldescs[columns[n]].name,
                                coldescs[columns[n]].whint,
                                flags))
@@ -937,9 +937,9 @@ static struct libscols_table *setup_table(struct lslogins_control *ctl)
                ++n;
        }
 
-       return tb;
+       return table;
 fail:
-       scols_unref_table(tb);
+       scols_unref_table(table);
        return NULL;
 }
 
@@ -1106,7 +1106,7 @@ done:
 }
 #endif
 
-static int print_pretty(struct libscols_table *tb)
+static int print_pretty(struct libscols_table *table)
 {
        struct libscols_iter *itr = scols_new_iter(SCOLS_ITER_FORWARD);
        struct libscols_column *col;
@@ -1115,8 +1115,8 @@ static int print_pretty(struct libscols_table *tb)
        const char *hstr, *dstr;
        int n = 0;
 
-       ln = scols_table_get_line(tb, 0);
-       while (!scols_table_next_column(tb, itr, &col)) {
+       ln = scols_table_get_line(table, 0);
+       while (!scols_table_next_column(table, itr, &col)) {
 
                data = scols_line_get_cell(ln, n);
 
index 153ea453a76163684ecb7392e71c46d7c8c114af..9d1f298af2de49aee3c042f998fe184b2dd61b90 100644 (file)
@@ -856,7 +856,7 @@ static struct libmnt_table *parse_tabfiles(char **files,
  * Parses mountinfo and calls mnt_cache_set_targets(cache, mtab). Only
  * necessary if @tb in main() was read from a non-kernel source.
  */
-static void cache_set_targets(struct libmnt_cache *cache)
+static void cache_set_targets(struct libmnt_cache *tmp)
 {
        struct libmnt_table *tb;
        const char *path;
@@ -870,7 +870,7 @@ static void cache_set_targets(struct libmnt_cache *cache)
                _PATH_PROC_MOUNTS;
 
        if (mnt_table_parse_file(tb, path) == 0)
-               mnt_cache_set_targets(cache, tb);
+               mnt_cache_set_targets(tmp, tb);
 
        mnt_unref_table(tb);
 }
index 045186a14a80de59de2d455c15d0b7c513bd64dd..6dac1879f8e1a7418634f76b9201ff8295eb1efd 100644 (file)
@@ -162,7 +162,7 @@ static char *get_fallback_filename(dev_t dev)
  * Return the absolute path of a file from
  * a given inode number (and its size)
  */
-static char *get_filename_sz(ino_t inode, pid_t pid, size_t *size)
+static char *get_filename_sz(ino_t inode, pid_t lock_pid, size_t *size)
 {
        struct stat sb;
        struct dirent *dp;
@@ -180,7 +180,7 @@ static char *get_filename_sz(ino_t inode, pid_t pid, size_t *size)
         * iterate the *entire* filesystem searching
         * for the damn file.
         */
-       sprintf(path, "/proc/%d/fd/", pid);
+       sprintf(path, "/proc/%d/fd/", lock_pid);
        if (!(dirp = opendir(path)))
                return NULL;
 
index 8a3a21739d1034148e732f95d9f417cd7aa92c60..c5106abcc4e3b64e5d54272bff56c61d505c4259 100644 (file)
@@ -643,35 +643,35 @@ static int swapon_by_uuid(const char *uuid, int prio, int dsc)
 
 /* -o <options> or fstab */
 static int parse_options(const char *optstr,
-                        int *priority, int *discard, int *nofail)
+                        int *prio, int *disc, int *nofail)
 {
        char *arg = NULL;
 
        assert(optstr);
-       assert(priority);
-       assert(discard);
+       assert(prio);
+       assert(disc);
        assert(nofail);
 
        if (mnt_optstr_get_option(optstr, "nofail", NULL, 0) == 0)
                *nofail = 1;
 
        if (mnt_optstr_get_option(optstr, "discard", &arg, NULL) == 0) {
-               *discard |= SWAP_FLAG_DISCARD;
+               *disc |= SWAP_FLAG_DISCARD;
 
                if (arg) {
                        /* only single-time discards are wanted */
                        if (strcmp(arg, "once") == 0)
-                               *discard |= SWAP_FLAG_DISCARD_ONCE;
+                               *disc |= SWAP_FLAG_DISCARD_ONCE;
 
                        /* do discard for every released swap page */
                        if (strcmp(arg, "pages") == 0)
-                               *discard |= SWAP_FLAG_DISCARD_PAGES;
+                               *disc |= SWAP_FLAG_DISCARD_PAGES;
                        }
        }
 
        arg = NULL;
        if (mnt_optstr_get_option(optstr, "pri", &arg, NULL) == 0 && arg)
-               *priority = atoi(arg);
+               *prio = atoi(arg);
 
        return 0;
 }
index 4abc587a78003e001c7bafde04de6c3cffd748e7..2d47e56309203998f75ee73cba506331b5986be9 100644 (file)
@@ -351,7 +351,7 @@ static void status(struct zram *z)
        if (z)
                fill_table_row(tb, z);          /* just one device specified */
        else {
-               size_t i;                       /* list all used devices */
+               /* list all used devices */
                z = new_zram(NULL);
 
                for (i = 0; ; i++) {