]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Ignore _Py_write_noraise() result: cast to (void) (#108291)
authorVictor Stinner <vstinner@python.org>
Tue, 22 Aug 2023 14:28:20 +0000 (16:28 +0200)
committerGitHub <noreply@github.com>
Tue, 22 Aug 2023 14:28:20 +0000 (14:28 +0000)
Code using _Py_write_noraise() usually cannot report. Ignore errors
is the least surprising behavior for users.

Modules/faulthandler.c
Python/pylifecycle.c
Python/traceback.c
Python/tracemalloc.c

index 428b090193f093c8dc229b941abd7f8834062216..d8cfc13a7dc6d504580293de049ff055bd136907 100644 (file)
@@ -26,7 +26,7 @@
 /* Allocate at maximum 100 MiB of the stack to raise the stack overflow */
 #define STACK_OVERFLOW_MAX_SIZE (100 * 1024 * 1024)
 
-#define PUTS(fd, str) _Py_write_noraise(fd, str, strlen(str))
+#define PUTS(fd, str) (void)_Py_write_noraise(fd, str, strlen(str))
 
 
 // clang uses __attribute__((no_sanitize("undefined")))
@@ -576,7 +576,7 @@ faulthandler_thread(void *unused)
         /* Timeout => dump traceback */
         assert(st == PY_LOCK_FAILURE);
 
-        _Py_write_noraise(thread.fd, thread.header, (int)thread.header_len);
+        (void)_Py_write_noraise(thread.fd, thread.header, (int)thread.header_len);
 
         errmsg = _Py_DumpTracebackThreads(thread.fd, thread.interp, NULL);
         ok = (errmsg == NULL);
index 263ead39fa472abafb144c98101f2a7f40701763..9837e0f0d52e6d91e57bf699bd2490742c92007c 100644 (file)
@@ -57,7 +57,7 @@
 #  undef BYTE
 #endif
 
-#define PUTS(fd, str) _Py_write_noraise(fd, str, (int)strlen(str))
+#define PUTS(fd, str) (void)_Py_write_noraise(fd, str, (int)strlen(str))
 
 
 #ifdef __cplusplus
index bddb8763a2f9be780215f4d24f4b53b47ac56552..61ace38275355cc47f647dfa7b87baee439447ca 100644 (file)
@@ -25,7 +25,7 @@
 
 #define OFF(x) offsetof(PyTracebackObject, x)
 
-#define PUTS(fd, str) _Py_write_noraise(fd, str, (int)strlen(str))
+#define PUTS(fd, str) (void)_Py_write_noraise(fd, str, (int)strlen(str))
 #define MAX_STRING_LENGTH 500
 #define MAX_FRAME_DEPTH 100
 #define MAX_NTHREADS 100
@@ -1047,7 +1047,7 @@ _Py_DumpDecimal(int fd, size_t value)
         value /= 10;
     } while (value);
 
-    _Py_write_noraise(fd, ptr, end - ptr);
+    (void)_Py_write_noraise(fd, ptr, end - ptr);
 }
 
 /* Format an integer as hexadecimal with width digits into fd file descriptor.
@@ -1072,7 +1072,7 @@ _Py_DumpHexadecimal(int fd, uintptr_t value, Py_ssize_t width)
         value >>= 4;
     } while ((end - ptr) < width || value);
 
-    _Py_write_noraise(fd, ptr, end - ptr);
+    (void)_Py_write_noraise(fd, ptr, end - ptr);
 }
 
 void
@@ -1125,7 +1125,7 @@ _Py_DumpASCII(int fd, PyObject *text)
         }
         if (!need_escape) {
             // The string can be written with a single write() syscall
-            _Py_write_noraise(fd, str, size);
+            (void)_Py_write_noraise(fd, str, size);
             goto done;
         }
     }
@@ -1135,7 +1135,7 @@ _Py_DumpASCII(int fd, PyObject *text)
         if (' ' <= ch && ch <= 126) {
             /* printable ASCII character */
             char c = (char)ch;
-            _Py_write_noraise(fd, &c, 1);
+            (void)_Py_write_noraise(fd, &c, 1);
         }
         else if (ch <= 0xff) {
             PUTS(fd, "\\x");
index f8ad939dccaccdf6088a01186266572f5e8edbde..7d294ea5fe744c9b9bf42ba534117926201933bc 100644 (file)
@@ -1247,7 +1247,7 @@ tracemalloc_get_traceback(unsigned int domain, uintptr_t ptr)
 }
 
 
-#define PUTS(fd, str) _Py_write_noraise(fd, str, (int)strlen(str))
+#define PUTS(fd, str) (void)_Py_write_noraise(fd, str, (int)strlen(str))
 
 static void
 _PyMem_DumpFrame(int fd, frame_t * frame)