[Crosstoolchain-logs] [device-tree-compiler] 121/198: dtc: fix some more -Wshadow warnings

Hector Oron zumbi at moszumanska.debian.org
Thu Dec 8 17:07:00 UTC 2016


This is an automated email from the git hooks/post-receive script.

zumbi pushed a commit to branch upstream/1.4.x
in repository device-tree-compiler.

commit 24cb3d0681d9196d57176a0a94bfc6e610ef7b45
Author: Florian Fainelli <f.fainelli at gmail.com>
Date:   Sat Feb 1 16:41:59 2014 +1100

    dtc: fix some more -Wshadow warnings
    
    Building on a RHEL6 system produced the following -Wshadow warnings in
    fstree.c, util.c and checks.c:
    
    cc1: warnings being treated as errors
    checks.c: In function 'parse_checks_option':
    checks.c:709: error: declaration of 'optarg' shadows a global
    declaration
    /usr/include/getopt.h:59: error: shadowed declaration is here
    make[1]: *** [checks.o] Error 1
    make[1]: *** Waiting for unfinished jobs....
    make[1]: *** Waiting for unfinished jobs....
    cc1: warnings being treated as errors
    fstree.c: In function 'read_fstree':
    fstree.c:40: error: declaration of 'tmpnam' shadows a global
    declaration
    /usr/include/stdio.h:208: error: shadowed declaration is here
    make[1]: *** [fstree.o] Error 1
    cc1: warnings being treated as errors
    util.c: In function 'xstrdup':
    util.c:42: error: declaration of 'dup' shadows a global declaration
    /usr/include/unistd.h:528: error: shadowed declaration is here
    
    Fix all of these -Wshadow warnings by using slightly different variable
    names which won't collide with anything else.
    
    Signed-off-by: Florian Fainelli <f.fainelli at gmail.com>
---
 checks.c | 10 +++++-----
 dtc.h    |  2 +-
 fstree.c | 16 ++++++++--------
 util.c   |  6 +++---
 4 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/checks.c b/checks.c
index 11a4086..47eda65 100644
--- a/checks.c
+++ b/checks.c
@@ -706,15 +706,15 @@ static void disable_warning_error(struct check *c, bool warn, bool error)
 	c->error = c->error && !error;
 }
 
-void parse_checks_option(bool warn, bool error, const char *optarg)
+void parse_checks_option(bool warn, bool error, const char *arg)
 {
 	int i;
-	const char *name = optarg;
+	const char *name = arg;
 	bool enable = true;
 
-	if ((strncmp(optarg, "no-", 3) == 0)
-	    || (strncmp(optarg, "no_", 3) == 0)) {
-		name = optarg + 3;
+	if ((strncmp(arg, "no-", 3) == 0)
+	    || (strncmp(arg, "no_", 3) == 0)) {
+		name = arg + 3;
 		enable = false;
 	}
 
diff --git a/dtc.h b/dtc.h
index 20e4d56..20de073 100644
--- a/dtc.h
+++ b/dtc.h
@@ -247,7 +247,7 @@ void sort_tree(struct boot_info *bi);
 
 /* Checks */
 
-void parse_checks_option(bool warn, bool error, const char *optarg);
+void parse_checks_option(bool warn, bool error, const char *arg);
 void process_checks(bool force, struct boot_info *bi);
 
 /* Flattened trees */
diff --git a/fstree.c b/fstree.c
index f377453..4d2791c 100644
--- a/fstree.c
+++ b/fstree.c
@@ -37,26 +37,26 @@ static struct node *read_fstree(const char *dirname)
 	tree = build_node(NULL, NULL);
 
 	while ((de = readdir(d)) != NULL) {
-		char *tmpnam;
+		char *tmpname;
 
 		if (streq(de->d_name, ".")
 		    || streq(de->d_name, ".."))
 			continue;
 
-		tmpnam = join_path(dirname, de->d_name);
+		tmpname = join_path(dirname, de->d_name);
 
-		if (lstat(tmpnam, &st) < 0)
-			die("stat(%s): %s\n", tmpnam, strerror(errno));
+		if (lstat(tmpname, &st) < 0)
+			die("stat(%s): %s\n", tmpname, strerror(errno));
 
 		if (S_ISREG(st.st_mode)) {
 			struct property *prop;
 			FILE *pfile;
 
-			pfile = fopen(tmpnam, "r");
+			pfile = fopen(tmpname, "r");
 			if (! pfile) {
 				fprintf(stderr,
 					"WARNING: Cannot open %s: %s\n",
-					tmpnam, strerror(errno));
+					tmpname, strerror(errno));
 			} else {
 				prop = build_property(xstrdup(de->d_name),
 						      data_copy_file(pfile,
@@ -67,12 +67,12 @@ static struct node *read_fstree(const char *dirname)
 		} else if (S_ISDIR(st.st_mode)) {
 			struct node *newchild;
 
-			newchild = read_fstree(tmpnam);
+			newchild = read_fstree(tmpname);
 			newchild = name_node(newchild, xstrdup(de->d_name));
 			add_child(tree, newchild);
 		}
 
-		free(tmpnam);
+		free(tmpname);
 	}
 
 	closedir(d);
diff --git a/util.c b/util.c
index 330b594..be67836 100644
--- a/util.c
+++ b/util.c
@@ -39,11 +39,11 @@
 char *xstrdup(const char *s)
 {
 	int len = strlen(s) + 1;
-	char *dup = xmalloc(len);
+	char *d = xmalloc(len);
 
-	memcpy(dup, s, len);
+	memcpy(d, s, len);
 
-	return dup;
+	return d;
 }
 
 char *join_path(const char *path, const char *name)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/crosstoolchain/device-tree-compiler.git



More information about the Crosstoolchain-logs mailing list