[CRIU] [PATCH 1/4] log: Don't modify global @errno in __print_on_level

Andrew Vagin avagin at parallels.com
Thu Mar 26 01:46:17 PDT 2015


Acked-by: Andrew Vagin <avagin at parallels.com>

On Thu, Mar 26, 2015 at 11:23:12AM +0300, Cyrill Gorcunov wrote:
> The __print_on_level routine may modify global @errno
> variable which is inacceptable: this is logging routine
> which must be transparent to the rest of the program code.
> 
> Thus save @errno in local @__errno variable and restore
> it on return.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  log.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/log.c b/log.c
> index a9f1757efa5a..e32e38b2afc3 100644
> --- a/log.c
> +++ b/log.c
> @@ -155,6 +155,7 @@ unsigned int log_get_loglevel(void)
>  static void __print_on_level(unsigned int loglevel, const char *format, va_list params)
>  {
>  	int fd, size, ret, off = 0;
> +	int __errno = errno;
>  
>  	if (unlikely(loglevel == LOG_MSG)) {
>  		fd = STDOUT_FILENO;
> @@ -176,6 +177,7 @@ static void __print_on_level(unsigned int loglevel, const char *format, va_list
>  			break;
>  		off += ret;
>  	}
> +	errno =  __errno;
>  }
>  
>  void print_on_level(unsigned int loglevel, const char *format, ...)
> -- 
> 1.9.3
> 


More information about the CRIU mailing list