Re: [PATCH 1/3] misc: always check setenv(3) return value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Aug 14, 2016 at 08:24:04AM +0100, Sami Kerola wrote:
> @@ -9,7 +9,7 @@ extern char *safe_getenv(const char *arg);
>  static inline void xsetenv(char const *name, char const *val, int overwrite)
>  {
>  	if (setenv(name, val, overwrite) != 0)
> -		err(EXIT_FAILURE, "failed to set the %s environment variable", name);
> +		err(EXIT_FAILURE, _("failed to set the %s environment variable"), name);
>  }

no nls.h included

In file included from lib/env.c:22:0:
./include/env.h: In function ‘xsetenv’:
./include/env.h:12:21: warning: implicit declaration of function ‘_’ [-Wimplicit-function-declaration]
./include/env.h:12:3: warning: nested extern declaration of ‘_’ [-Wnested-externs]
./include/env.h:12:21: warning: passing argument 2 of ‘err’ makes pointer from integer without a cast [-Wint-conversion]


>  	if (pwd->pw_uid)
> -		logindefs_setenv("PATH", "ENV_PATH", _PATH_DEFPATH);
> +		if (logindefs_setenv("PATH", "ENV_PATH", _PATH_DEFPATH) != 0)
> +			err(EXIT_FAILURE, _("failed to set the %s environment variable"), "PATH");
>  
>  	else if (logindefs_setenv("PATH", "ENV_ROOTPATH", NULL) != 0)
> -		logindefs_setenv("PATH", "ENV_SUPATH", _PATH_DEFPATH_ROOT);
> +		if (logindefs_setenv("PATH", "ENV_SUPATH", _PATH_DEFPATH_ROOT) != 0)
> +			err(EXIT_FAILURE, _("failed to set the %s environment variable"), "PATH");

What about to use { } ?

 login-utils/login.c: In function ‘init_environ’:
 login-utils/login.c:1050:5: warning: suggest explicit braces to avoid  ambiguous ‘else’ [-Wparentheses]


Fixed.

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux