diff mbox series

[04/20] tools/xenstore: let tdb_logger() preserve errno

Message ID 20221101152842.4257-5-jgross@suse.com (mailing list archive)
State Superseded
Headers show
Series tools/xenstore: do some cleanup and fixes | expand

Commit Message

Jürgen Groß Nov. 1, 2022, 3:28 p.m. UTC
tdb_logger() is called by TDB for logging errors. As errno is checked
often after doing the logging, tdb_logger() should preserve errno.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 tools/xenstore/xenstored_core.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Julien Grall Nov. 6, 2022, 9:09 p.m. UTC | #1
Hi Juergen,

On 01/11/2022 15:28, Juergen Gross wrote:
> tdb_logger() is called by TDB for logging errors. As errno is checked
> often after doing the logging, tdb_logger() should preserve errno.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Julien Grall <jgrall@amazon.com>

Cheers,

> ---
>   tools/xenstore/xenstored_core.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c
> index 5a174b9881..d48208ecfe 100644
> --- a/tools/xenstore/xenstored_core.c
> +++ b/tools/xenstore/xenstored_core.c
> @@ -2345,6 +2345,7 @@ static void tdb_logger(TDB_CONTEXT *tdb, int level, const char * fmt, ...)
>   {
>   	va_list ap;
>   	char *s;
> +	int saved_errno = errno;
>   
>   	va_start(ap, fmt);
>   	s = talloc_vasprintf(NULL, fmt, ap);
> @@ -2360,6 +2361,8 @@ static void tdb_logger(TDB_CONTEXT *tdb, int level, const char * fmt, ...)
>   		trace("talloc failure during logging\n");
>   		syslog(LOG_ERR, "talloc failure during logging\n");
>   	}
> +
> +	errno = saved_errno;
>   }
>   
>   void setup_structure(bool live_update)
diff mbox series

Patch

diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c
index 5a174b9881..d48208ecfe 100644
--- a/tools/xenstore/xenstored_core.c
+++ b/tools/xenstore/xenstored_core.c
@@ -2345,6 +2345,7 @@  static void tdb_logger(TDB_CONTEXT *tdb, int level, const char * fmt, ...)
 {
 	va_list ap;
 	char *s;
+	int saved_errno = errno;
 
 	va_start(ap, fmt);
 	s = talloc_vasprintf(NULL, fmt, ap);
@@ -2360,6 +2361,8 @@  static void tdb_logger(TDB_CONTEXT *tdb, int level, const char * fmt, ...)
 		trace("talloc failure during logging\n");
 		syslog(LOG_ERR, "talloc failure during logging\n");
 	}
+
+	errno = saved_errno;
 }
 
 void setup_structure(bool live_update)