@@ -8392,36 +8392,39 @@ wait_helper(PyObject *module, pid_t pid, int status, struct rusage *ru)
8392
8392
if (!result )
8393
8393
return NULL ;
8394
8394
8395
+ int pos = 0 ;
8396
+
8395
8397
#ifndef doubletime
8396
8398
#define doubletime (TV ) ((double)(TV).tv_sec + (TV).tv_usec * 0.000001)
8397
8399
#endif
8398
8400
8399
- PyStructSequence_SET_ITEM (result , 0 ,
8400
- PyFloat_FromDouble (doubletime (ru -> ru_utime )));
8401
- PyStructSequence_SET_ITEM (result , 1 ,
8402
- PyFloat_FromDouble (doubletime (ru -> ru_stime )));
8403
- #define SET_INT (result , index , value )\
8404
- PyStructSequence_SET_ITEM(result, index, PyLong_FromLong(value))
8405
- SET_INT (result , 2 , ru -> ru_maxrss );
8406
- SET_INT (result , 3 , ru -> ru_ixrss );
8407
- SET_INT (result , 4 , ru -> ru_idrss );
8408
- SET_INT (result , 5 , ru -> ru_isrss );
8409
- SET_INT (result , 6 , ru -> ru_minflt );
8410
- SET_INT (result , 7 , ru -> ru_majflt );
8411
- SET_INT (result , 8 , ru -> ru_nswap );
8412
- SET_INT (result , 9 , ru -> ru_inblock );
8413
- SET_INT (result , 10 , ru -> ru_oublock );
8414
- SET_INT (result , 11 , ru -> ru_msgsnd );
8415
- SET_INT (result , 12 , ru -> ru_msgrcv );
8416
- SET_INT (result , 13 , ru -> ru_nsignals );
8417
- SET_INT (result , 14 , ru -> ru_nvcsw );
8418
- SET_INT (result , 15 , ru -> ru_nivcsw );
8419
- #undef SET_INT
8420
-
8421
- if (PyErr_Occurred ()) {
8422
- Py_DECREF (result );
8423
- return NULL ;
8424
- }
8401
+ #define SET_RESULT (CALL ) \
8402
+ do { \
8403
+ PyObject *item = (CALL); \
8404
+ if (item == NULL) { \
8405
+ Py_DECREF(result); \
8406
+ return NULL; \
8407
+ } \
8408
+ PyStructSequence_SET_ITEM(result, pos++, item); \
8409
+ } while(0)
8410
+
8411
+ SET_RESULT (PyFloat_FromDouble (doubletime (ru -> ru_utime )));
8412
+ SET_RESULT (PyFloat_FromDouble (doubletime (ru -> ru_stime )));
8413
+ SET_RESULT (PyLong_FromLong (ru -> ru_maxrss ));
8414
+ SET_RESULT (PyLong_FromLong (ru -> ru_ixrss ));
8415
+ SET_RESULT (PyLong_FromLong (ru -> ru_idrss ));
8416
+ SET_RESULT (PyLong_FromLong (ru -> ru_isrss ));
8417
+ SET_RESULT (PyLong_FromLong (ru -> ru_minflt ));
8418
+ SET_RESULT (PyLong_FromLong (ru -> ru_majflt ));
8419
+ SET_RESULT (PyLong_FromLong (ru -> ru_nswap ));
8420
+ SET_RESULT (PyLong_FromLong (ru -> ru_inblock ));
8421
+ SET_RESULT (PyLong_FromLong (ru -> ru_oublock ));
8422
+ SET_RESULT (PyLong_FromLong (ru -> ru_msgsnd ));
8423
+ SET_RESULT (PyLong_FromLong (ru -> ru_msgrcv ));
8424
+ SET_RESULT (PyLong_FromLong (ru -> ru_nsignals ));
8425
+ SET_RESULT (PyLong_FromLong (ru -> ru_nvcsw ));
8426
+ SET_RESULT (PyLong_FromLong (ru -> ru_nivcsw ));
8427
+ #undef SET_RESULT
8425
8428
8426
8429
return Py_BuildValue ("NiN" , PyLong_FromPid (pid ), status , result );
8427
8430
}
0 commit comments