Skip to content

Commit 3461ccf

Browse files
author
Anselm Kruis
committed
Stackless issue python#140: Fix compiler warnings
- Initialize variable 'len' in function unwrap_frame_arg(). - Assign to '*valid' in function slp_find_execname(). - Disable GCC warning -Waddress in macro TASKLET_SETVAL(task, val). - Update Stackless/changelog.txt for issues python#138, python#140
1 parent 056666a commit 3461ccf

3 files changed

Lines changed: 27 additions & 3 deletions

File tree

Stackless/changelog.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ What's New in Stackless 3.X.X?
99

1010
*Release date: 20XX-XX-XX*
1111

12+
- https://github.com/stackless-dev/stackless/issues/140
13+
Fix bugs in prickelpit.c unwrap_frame_arg() and slp_find_execname().
14+
15+
- https://github.com/stackless-dev/stackless/issues/138
16+
Correctly propose Stackless calls for C-functions.
17+
1218
- https://bitbucket.org/stackless-dev/stackless/issues/129
1319
C-API: Calling PyTasklet_New( NULL, ...) no longer crashes.
1420

Stackless/core/stackless_impl.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,11 +679,23 @@ do { \
679679
} while(0)
680680

681681
/* ditto, without incref. Made no sense to optimize. */
682+
#if defined(__GNUC__) && defined(__STDC__) && (__STDC_VERSION__ >= 199901L)
683+
#define SLP_DISABLE_GCC_W_ADDRESS \
684+
_Pragma("GCC diagnostic push") \
685+
_Pragma("GCC diagnostic ignored \"-Waddress\"")
686+
#define SLP_RESTORE_WARNINGS \
687+
_Pragma("GCC diagnostic pop")
688+
#else
689+
#define SLP_DISABLE_GCC_W_ADDRESS /**/
690+
#define SLP_RESTORE_WARNINGS /**/
691+
#endif
682692

683693
#define TASKLET_SETVAL_OWN(task, val) \
684694
do { \
685695
PyObject *hold = (task)->tempval; \
696+
SLP_DISABLE_GCC_W_ADDRESS /* suppress warning, if val == Py_NONE */ \
686697
assert(val != NULL); \
698+
SLP_RESTORE_WARNINGS \
687699
(task)->tempval = (PyObject *) val; \
688700
Py_DECREF(hold); \
689701
} while(0)

Stackless/pickling/prickelpit.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,11 @@ unwrap_frame_arg(PyObject * args) {
236236
int is_instance;
237237
Py_ssize_t len, i;
238238

239-
if (!PyTuple_Check(args) || (len = PyTuple_Size(args)) < 1) {
239+
if (!PyTuple_Check(args)) {
240+
Py_INCREF(args);
241+
return args;
242+
}
243+
if ((len = PyTuple_Size(args)) < 1) {
240244
if (len < 0)
241245
return NULL;
242246
Py_INCREF(args);
@@ -500,6 +504,8 @@ slp_find_execname(PyFrameObject *f, int *valid)
500504
PyObject *dic = dp ? dp->dict : NULL;
501505
PyObject *exec_addr = PyLong_FromVoidPtr(f->f_execute);
502506

507+
assert(valid != NULL);
508+
503509
if (exec_addr == NULL) return NULL;
504510
exec_name = dic ? PyDict_GetItem(dic, exec_addr) : NULL;
505511
if (exec_name == NULL) {
@@ -508,7 +514,7 @@ slp_find_execname(PyFrameObject *f, int *valid)
508514
sprintf(msg, "frame exec function at %lx is not registered!",
509515
(unsigned long)(void *)f->f_execute);
510516
PyErr_SetString(PyExc_ValueError, msg);
511-
valid = 0;
517+
*valid = 0;
512518
}
513519
else {
514520
PyFrame_ExecFunc *good, *bad;
@@ -517,7 +523,7 @@ slp_find_execname(PyFrameObject *f, int *valid)
517523
goto err_exit;
518524
}
519525
if (f->f_execute == bad)
520-
valid = 0;
526+
*valid = 0;
521527
else if (f->f_execute != good) {
522528
PyErr_SetString(PyExc_SystemError,
523529
"inconsistent c?frame function registration");

0 commit comments

Comments
 (0)