@@ -9577,36 +9577,39 @@ wait_helper(PyObject *module, pid_t pid, int status, struct rusage *ru)
9577
9577
if (!result )
9578
9578
return NULL ;
9579
9579
9580
+ int pos = 0 ;
9581
+
9580
9582
#ifndef doubletime
9581
9583
#define doubletime (TV ) ((double)(TV).tv_sec + (TV).tv_usec * 0.000001)
9582
9584
#endif
9583
9585
9584
- PyStructSequence_SET_ITEM (result , 0 ,
9585
- PyFloat_FromDouble (doubletime (ru -> ru_utime )));
9586
- PyStructSequence_SET_ITEM (result , 1 ,
9587
- PyFloat_FromDouble (doubletime (ru -> ru_stime )));
9588
- #define SET_INT (result , index , value )\
9589
- PyStructSequence_SET_ITEM(result, index, PyLong_FromLong(value))
9590
- SET_INT (result , 2 , ru -> ru_maxrss );
9591
- SET_INT (result , 3 , ru -> ru_ixrss );
9592
- SET_INT (result , 4 , ru -> ru_idrss );
9593
- SET_INT (result , 5 , ru -> ru_isrss );
9594
- SET_INT (result , 6 , ru -> ru_minflt );
9595
- SET_INT (result , 7 , ru -> ru_majflt );
9596
- SET_INT (result , 8 , ru -> ru_nswap );
9597
- SET_INT (result , 9 , ru -> ru_inblock );
9598
- SET_INT (result , 10 , ru -> ru_oublock );
9599
- SET_INT (result , 11 , ru -> ru_msgsnd );
9600
- SET_INT (result , 12 , ru -> ru_msgrcv );
9601
- SET_INT (result , 13 , ru -> ru_nsignals );
9602
- SET_INT (result , 14 , ru -> ru_nvcsw );
9603
- SET_INT (result , 15 , ru -> ru_nivcsw );
9604
- #undef SET_INT
9605
-
9606
- if (PyErr_Occurred ()) {
9607
- Py_DECREF (result );
9608
- return NULL ;
9609
- }
9586
+ #define SET_RESULT (CALL ) \
9587
+ do { \
9588
+ PyObject *item = (CALL); \
9589
+ if (item == NULL) { \
9590
+ Py_DECREF(result); \
9591
+ return NULL; \
9592
+ } \
9593
+ PyStructSequence_SET_ITEM(result, pos++, item); \
9594
+ } while(0)
9595
+
9596
+ SET_RESULT (PyFloat_FromDouble (doubletime (ru -> ru_utime )));
9597
+ SET_RESULT (PyFloat_FromDouble (doubletime (ru -> ru_stime )));
9598
+ SET_RESULT (PyLong_FromLong (ru -> ru_maxrss ));
9599
+ SET_RESULT (PyLong_FromLong (ru -> ru_ixrss ));
9600
+ SET_RESULT (PyLong_FromLong (ru -> ru_idrss ));
9601
+ SET_RESULT (PyLong_FromLong (ru -> ru_isrss ));
9602
+ SET_RESULT (PyLong_FromLong (ru -> ru_minflt ));
9603
+ SET_RESULT (PyLong_FromLong (ru -> ru_majflt ));
9604
+ SET_RESULT (PyLong_FromLong (ru -> ru_nswap ));
9605
+ SET_RESULT (PyLong_FromLong (ru -> ru_inblock ));
9606
+ SET_RESULT (PyLong_FromLong (ru -> ru_oublock ));
9607
+ SET_RESULT (PyLong_FromLong (ru -> ru_msgsnd ));
9608
+ SET_RESULT (PyLong_FromLong (ru -> ru_msgrcv ));
9609
+ SET_RESULT (PyLong_FromLong (ru -> ru_nsignals ));
9610
+ SET_RESULT (PyLong_FromLong (ru -> ru_nvcsw ));
9611
+ SET_RESULT (PyLong_FromLong (ru -> ru_nivcsw ));
9612
+ #undef SET_RESULT
9610
9613
9611
9614
return Py_BuildValue ("NiN" , PyLong_FromPid (pid ), status , result );
9612
9615
}
0 commit comments