[CRIU] [PATCH 1/2] pstree: Introduce task_alive() helper

Pavel Emelyanov xemul at parallels.com
Fri Aug 8 04:05:02 PDT 2014


On 08/08/2014 02:52 PM, Cyrill Gorcunov wrote:
> On Thu, Aug 07, 2014 at 01:30:54PM +0400, Pavel Emelyanov wrote:
>> +++ b/include/pstree.h
>> @@ -40,6 +40,11 @@ static inline int shared_fdtable(struct pstree_item *item) {
>>  		item->ids->files_id == item->parent->ids->files_id);
>>  }
>>  
>> +static inline bool task_alive(struct pstree_item *i)
>> +{
>> +	return (i->state == TASK_ALIVE) || (i->state == TASK_STOPPED);
>> +}
>> +
> 
> I would rather do
> 
> static inline bool task_is(struct pstree_item *i, int state)
> {
> 	return i->state == state;
> }
> 
> #define task_is_alive(i) 	(task_is(i, TASK_ALIVE) || task_is(i, TASK_STOPPED))
> #define task_is_dead(i) 	(task_is(i, TASK_DEAD))
> #define task_is_helper(i) 	(task_is(i, TASK_HELPER))
> 
> ?

Just more code from my POV. What I would do it turn state from number into bits
so that task_alive() becomes i->state & (TASK_ALIVE | TASK_STOPPED)



More information about the CRIU mailing list