]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40941: Fix stackdepth compiler warnings (GH-22377)
authorVictor Stinner <vstinner@python.org>
Wed, 23 Sep 2020 12:07:16 +0000 (14:07 +0200)
committerGitHub <noreply@github.com>
Wed, 23 Sep 2020 12:07:16 +0000 (14:07 +0200)
Explicitly cast a difference of two pointers to int:
PyFrameObject.f_stackdepth is an int.

Python/ceval.c

index 4bb4b820b8e17a5595904ff64a98afa0b538b03c..6430e792b8c5d8b69529ca9ab5836737be170627 100644 (file)
@@ -1433,9 +1433,9 @@ main_loop:
         if (_Py_TracingPossible(ceval2) &&
             tstate->c_tracefunc != NULL && !tstate->tracing) {
             int err;
-            /* see maybe_call_line_trace
+            /* see maybe_call_line_trace()
                for expository comments */
-            f->f_stackdepth = stack_pointer-f->f_valuestack;
+            f->f_stackdepth = (int)(stack_pointer - f->f_valuestack);
 
             err = maybe_call_line_trace(tstate->c_tracefunc,
                                         tstate->c_traceobj,
@@ -2265,7 +2265,7 @@ main_loop:
             assert(f->f_lasti >= (int)sizeof(_Py_CODEUNIT));
             f->f_lasti -= sizeof(_Py_CODEUNIT);
             f->f_state = FRAME_SUSPENDED;
-            f->f_stackdepth = stack_pointer-f->f_valuestack;
+            f->f_stackdepth = (int)(stack_pointer - f->f_valuestack);
             goto exiting;
         }
 
@@ -2282,7 +2282,7 @@ main_loop:
                 retval = w;
             }
             f->f_state = FRAME_SUSPENDED;
-            f->f_stackdepth = stack_pointer-f->f_valuestack;
+            f->f_stackdepth = (int)(stack_pointer - f->f_valuestack);
             goto exiting;
         }