@@ -9245,36 +9245,39 @@ wait_helper(PyObject *module, pid_t pid, int status, struct rusage *ru)
9245
9245
if (!result )
9246
9246
return NULL ;
9247
9247
9248
+ int pos = 0 ;
9249
+
9248
9250
#ifndef doubletime
9249
9251
#define doubletime (TV ) ((double)(TV).tv_sec + (TV).tv_usec * 0.000001)
9250
9252
#endif
9251
9253
9252
- PyStructSequence_SET_ITEM (result , 0 ,
9253
- PyFloat_FromDouble (doubletime (ru -> ru_utime )));
9254
- PyStructSequence_SET_ITEM (result , 1 ,
9255
- PyFloat_FromDouble (doubletime (ru -> ru_stime )));
9256
- #define SET_INT (result , index , value )\
9257
- PyStructSequence_SET_ITEM(result, index, PyLong_FromLong(value))
9258
- SET_INT (result , 2 , ru -> ru_maxrss );
9259
- SET_INT (result , 3 , ru -> ru_ixrss );
9260
- SET_INT (result , 4 , ru -> ru_idrss );
9261
- SET_INT (result , 5 , ru -> ru_isrss );
9262
- SET_INT (result , 6 , ru -> ru_minflt );
9263
- SET_INT (result , 7 , ru -> ru_majflt );
9264
- SET_INT (result , 8 , ru -> ru_nswap );
9265
- SET_INT (result , 9 , ru -> ru_inblock );
9266
- SET_INT (result , 10 , ru -> ru_oublock );
9267
- SET_INT (result , 11 , ru -> ru_msgsnd );
9268
- SET_INT (result , 12 , ru -> ru_msgrcv );
9269
- SET_INT (result , 13 , ru -> ru_nsignals );
9270
- SET_INT (result , 14 , ru -> ru_nvcsw );
9271
- SET_INT (result , 15 , ru -> ru_nivcsw );
9272
- #undef SET_INT
9273
-
9274
- if (PyErr_Occurred ()) {
9275
- Py_DECREF (result );
9276
- return NULL ;
9277
- }
9254
+ #define SET_RESULT (CALL ) \
9255
+ do { \
9256
+ PyObject *item = (CALL); \
9257
+ if (item == NULL) { \
9258
+ Py_DECREF(result); \
9259
+ return NULL; \
9260
+ } \
9261
+ PyStructSequence_SET_ITEM(result, pos++, item); \
9262
+ } while(0)
9263
+
9264
+ SET_RESULT (PyFloat_FromDouble (doubletime (ru -> ru_utime )));
9265
+ SET_RESULT (PyFloat_FromDouble (doubletime (ru -> ru_stime )));
9266
+ SET_RESULT (PyLong_FromLong (ru -> ru_maxrss ));
9267
+ SET_RESULT (PyLong_FromLong (ru -> ru_ixrss ));
9268
+ SET_RESULT (PyLong_FromLong (ru -> ru_idrss ));
9269
+ SET_RESULT (PyLong_FromLong (ru -> ru_isrss ));
9270
+ SET_RESULT (PyLong_FromLong (ru -> ru_minflt ));
9271
+ SET_RESULT (PyLong_FromLong (ru -> ru_majflt ));
9272
+ SET_RESULT (PyLong_FromLong (ru -> ru_nswap ));
9273
+ SET_RESULT (PyLong_FromLong (ru -> ru_inblock ));
9274
+ SET_RESULT (PyLong_FromLong (ru -> ru_oublock ));
9275
+ SET_RESULT (PyLong_FromLong (ru -> ru_msgsnd ));
9276
+ SET_RESULT (PyLong_FromLong (ru -> ru_msgrcv ));
9277
+ SET_RESULT (PyLong_FromLong (ru -> ru_nsignals ));
9278
+ SET_RESULT (PyLong_FromLong (ru -> ru_nvcsw ));
9279
+ SET_RESULT (PyLong_FromLong (ru -> ru_nivcsw ));
9280
+ #undef SET_RESULT
9278
9281
9279
9282
return Py_BuildValue ("NiN" , PyLong_FromPid (pid ), status , result );
9280
9283
}
0 commit comments