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