mirror of
https://github.com/dgibson/dtc.git
synced 2025-10-13 16:27:39 -04:00
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@gmail.com>
This commit is contained in:
parent
c231d94e0f
commit
24cb3d0681
4 changed files with 17 additions and 17 deletions
10
checks.c
10
checks.c
|
@ -706,15 +706,15 @@ static void disable_warning_error(struct check *c, bool warn, bool error)
|
||||||
c->error = c->error && !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;
|
int i;
|
||||||
const char *name = optarg;
|
const char *name = arg;
|
||||||
bool enable = true;
|
bool enable = true;
|
||||||
|
|
||||||
if ((strncmp(optarg, "no-", 3) == 0)
|
if ((strncmp(arg, "no-", 3) == 0)
|
||||||
|| (strncmp(optarg, "no_", 3) == 0)) {
|
|| (strncmp(arg, "no_", 3) == 0)) {
|
||||||
name = optarg + 3;
|
name = arg + 3;
|
||||||
enable = false;
|
enable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
dtc.h
2
dtc.h
|
@ -247,7 +247,7 @@ void sort_tree(struct boot_info *bi);
|
||||||
|
|
||||||
/* Checks */
|
/* 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);
|
void process_checks(bool force, struct boot_info *bi);
|
||||||
|
|
||||||
/* Flattened trees */
|
/* Flattened trees */
|
||||||
|
|
16
fstree.c
16
fstree.c
|
@ -37,26 +37,26 @@ static struct node *read_fstree(const char *dirname)
|
||||||
tree = build_node(NULL, NULL);
|
tree = build_node(NULL, NULL);
|
||||||
|
|
||||||
while ((de = readdir(d)) != NULL) {
|
while ((de = readdir(d)) != NULL) {
|
||||||
char *tmpnam;
|
char *tmpname;
|
||||||
|
|
||||||
if (streq(de->d_name, ".")
|
if (streq(de->d_name, ".")
|
||||||
|| streq(de->d_name, ".."))
|
|| streq(de->d_name, ".."))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
tmpnam = join_path(dirname, de->d_name);
|
tmpname = join_path(dirname, de->d_name);
|
||||||
|
|
||||||
if (lstat(tmpnam, &st) < 0)
|
if (lstat(tmpname, &st) < 0)
|
||||||
die("stat(%s): %s\n", tmpnam, strerror(errno));
|
die("stat(%s): %s\n", tmpname, strerror(errno));
|
||||||
|
|
||||||
if (S_ISREG(st.st_mode)) {
|
if (S_ISREG(st.st_mode)) {
|
||||||
struct property *prop;
|
struct property *prop;
|
||||||
FILE *pfile;
|
FILE *pfile;
|
||||||
|
|
||||||
pfile = fopen(tmpnam, "r");
|
pfile = fopen(tmpname, "r");
|
||||||
if (! pfile) {
|
if (! pfile) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"WARNING: Cannot open %s: %s\n",
|
"WARNING: Cannot open %s: %s\n",
|
||||||
tmpnam, strerror(errno));
|
tmpname, strerror(errno));
|
||||||
} else {
|
} else {
|
||||||
prop = build_property(xstrdup(de->d_name),
|
prop = build_property(xstrdup(de->d_name),
|
||||||
data_copy_file(pfile,
|
data_copy_file(pfile,
|
||||||
|
@ -67,12 +67,12 @@ static struct node *read_fstree(const char *dirname)
|
||||||
} else if (S_ISDIR(st.st_mode)) {
|
} else if (S_ISDIR(st.st_mode)) {
|
||||||
struct node *newchild;
|
struct node *newchild;
|
||||||
|
|
||||||
newchild = read_fstree(tmpnam);
|
newchild = read_fstree(tmpname);
|
||||||
newchild = name_node(newchild, xstrdup(de->d_name));
|
newchild = name_node(newchild, xstrdup(de->d_name));
|
||||||
add_child(tree, newchild);
|
add_child(tree, newchild);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(tmpnam);
|
free(tmpname);
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(d);
|
closedir(d);
|
||||||
|
|
6
util.c
6
util.c
|
@ -39,11 +39,11 @@
|
||||||
char *xstrdup(const char *s)
|
char *xstrdup(const char *s)
|
||||||
{
|
{
|
||||||
int len = strlen(s) + 1;
|
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)
|
char *join_path(const char *path, const char *name)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue