11/*
22 * Debugging functions for CUPS.
33 *
4- * Copyright © 2020-2024 by OpenPrinting.
4+ * Copyright © 2020-2026 by OpenPrinting.
55 * Copyright © 2008-2018 by Apple Inc.
66 *
77 * Licensed under Apache License v2.0. See the file "LICENSE" for more
@@ -89,6 +89,7 @@ _cups_debug_printf(const char *format, /* I - Printf-style format string */
8989 char buffer [2048 ]; /* Output buffer */
9090 ssize_t bytes ; /* Number of bytes in buffer */
9191 int level ; /* Log level in message */
92+ int myerrno = errno ;/* Copy of errno value */
9293
9394
9495 /*
@@ -100,7 +101,7 @@ _cups_debug_printf(const char *format, /* I - Printf-style format string */
100101 getenv ("CUPS_DEBUG_FILTER" ), 0 );
101102
102103 if (_cups_debug_fd < 0 )
103- return ;
104+ goto done ;
104105
105106 /*
106107 * Filter as needed...
@@ -112,7 +113,7 @@ _cups_debug_printf(const char *format, /* I - Printf-style format string */
112113 level = 0 ;
113114
114115 if (level > _cups_debug_level )
115- return ;
116+ goto done ;
116117
117118 if (debug_filter )
118119 {
@@ -123,7 +124,7 @@ _cups_debug_printf(const char *format, /* I - Printf-style format string */
123124 _cupsMutexUnlock (& debug_init_mutex );
124125
125126 if (result )
126- return ;
127+ goto done ;
127128 }
128129
129130 /*
@@ -158,6 +159,10 @@ _cups_debug_printf(const char *format, /* I - Printf-style format string */
158159 _cupsMutexLock (& debug_log_mutex );
159160 write (_cups_debug_fd , buffer , (size_t )bytes );
160161 _cupsMutexUnlock (& debug_log_mutex );
162+
163+ done :
164+
165+ errno = myerrno ;
161166}
162167
163168
@@ -172,6 +177,7 @@ _cups_debug_puts(const char *s) /* I - String to output */
172177 char buffer [2048 ]; /* Output buffer */
173178 ssize_t bytes ; /* Number of bytes in buffer */
174179 int level ; /* Log level in message */
180+ int myerrno = errno ;/* Copy of errno value */
175181
176182
177183 /*
@@ -183,7 +189,7 @@ _cups_debug_puts(const char *s) /* I - String to output */
183189 getenv ("CUPS_DEBUG_FILTER" ), 0 );
184190
185191 if (_cups_debug_fd < 0 )
186- return ;
192+ goto done ;
187193
188194 /*
189195 * Filter as needed...
@@ -195,7 +201,7 @@ _cups_debug_puts(const char *s) /* I - String to output */
195201 level = 0 ;
196202
197203 if (level > _cups_debug_level )
198- return ;
204+ goto done ;
199205
200206 if (debug_filter )
201207 {
@@ -206,7 +212,7 @@ _cups_debug_puts(const char *s) /* I - String to output */
206212 _cupsMutexUnlock (& debug_init_mutex );
207213
208214 if (result )
209- return ;
215+ goto done ;
210216 }
211217
212218 /*
@@ -238,6 +244,10 @@ _cups_debug_puts(const char *s) /* I - String to output */
238244 _cupsMutexLock (& debug_log_mutex );
239245 write (_cups_debug_fd , buffer , (size_t )bytes );
240246 _cupsMutexUnlock (& debug_log_mutex );
247+
248+ done :
249+
250+ errno = myerrno ;
241251}
242252
243253
0 commit comments