[systemd-devel] [PATCH 4/5] shared:util : Remove shadow compile warning
Zbigniew Jędrzejewski-Szmek
zbyszek at in.waw.pl
Thu Oct 16 16:09:32 PDT 2014
On Fri, Oct 17, 2014 at 12:43:52AM +0300, philippedeswert at gmail.com wrote:
> From: Philippe De Swert <philippedeswert at gmail.com>
>
> Removes the following compilation warning:
> src/shared/util.c: In function 'rm_rf_children_dangerous':
> src/shared/util.c:2800:22: warning: declaration of 'is_dir' shadows a global declaration [-Wshadow]
> In file included from src/shared/util.c:77:0:
> src/shared/mkdir.h:45:5: warning: shadowed declaration is here [-Wshadow]
> ---
What compiler version are you using? IIRC, gcc used to warn about
local variables shadowing globals and then stopped.
Zbyszek
> src/shared/util.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/shared/util.c b/src/shared/util.c
> index 5f6249e..1545547 100644
> --- a/src/shared/util.c
> +++ b/src/shared/util.c
> @@ -2797,7 +2797,7 @@ int rm_rf_children_dangerous(int fd, bool only_dirs, bool honour_sticky, struct
>
> for (;;) {
> struct dirent *de;
> - bool is_dir, keep_around;
> + bool is_a_dir, keep_around;
> struct stat st;
> int r;
>
> @@ -2821,17 +2821,17 @@ int rm_rf_children_dangerous(int fd, bool only_dirs, bool honour_sticky, struct
> continue;
> }
>
> - is_dir = S_ISDIR(st.st_mode);
> + is_a_dir = S_ISDIR(st.st_mode);
> keep_around =
> honour_sticky &&
> (st.st_uid == 0 || st.st_uid == getuid()) &&
> (st.st_mode & S_ISVTX);
> } else {
> - is_dir = de->d_type == DT_DIR;
> + is_a_dir = de->d_type == DT_DIR;
> keep_around = false;
> }
>
> - if (is_dir) {
> + if (is_a_dir) {
> int subdir_fd;
>
> /* if root_dev is set, remove subdirectories only, if device is same as dir */
> --
> 1.8.3.2
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
More information about the systemd-devel
mailing list