Re: [RFC PATCH v2 01/16] bcache: move definition of 'int ret' out of macro read_bucket()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2019/4/22 1:47 上午, Chaitanya Kulkarni wrote:
> May be we should make this as an inline function instead of macro ?
> Reason being:-
> 1. It is not a simple substitution.
> 2. It has multiple function calls.
> 3. With this patch it is now dependent on local variable declared
>     outside of macro.
> 
> Any thoughts ?
> 

Hi Chaitanya,

I agree with you. There are some symbol names shared with "caller" of
read_bucket(), so it is not very simple change to change the macro into
an inline function. At this moment I will keep the change as simple as
possible, and later I will think of change this macro into an inline
routine.

Thanks.

Coly Li


> 
> On 04/19/2019 11:24 AM, Coly Li wrote:
>> 'int ret' is defined as a local variable inside macro read_bucket().
>> Since this macro is called multiple times, and following patches will
>> use a 'int ret' variable in bch_journal_read(), this patch moves
>> definition of 'int ret' from macro read_bucket() to range of function
>> bch_journal_read().
>>
>> Signed-off-by: Coly Li <colyli@xxxxxxx>
>> ---
>>   drivers/md/bcache/journal.c | 5 +++--
>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
>> index b2fd412715b1..6e18057d1d82 100644
>> --- a/drivers/md/bcache/journal.c
>> +++ b/drivers/md/bcache/journal.c
>> @@ -147,7 +147,7 @@ int bch_journal_read(struct cache_set *c, struct list_head *list)
>>   {
>>   #define read_bucket(b)							\
>>   	({								\
>> -		int ret = journal_read_bucket(ca, list, b);		\
>> +		ret = journal_read_bucket(ca, list, b);			\
>>   		__set_bit(b, bitmap);					\
>>   		if (ret < 0)						\
>>   			return ret;					\
>> @@ -156,6 +156,7 @@ int bch_journal_read(struct cache_set *c, struct list_head *list)
>>
>>   	struct cache *ca;
>>   	unsigned int iter;
>> +	int ret = 0;
>>
>>   	for_each_cache(ca, c, iter) {
>>   		struct journal_device *ja = &ca->journal;
>> @@ -267,7 +268,7 @@ int bch_journal_read(struct cache_set *c, struct list_head *list)
>>   					    struct journal_replay,
>>   					    list)->j.seq;
>>
>> -	return 0;
>> +	return ret;
>>   #undef read_bucket
>>   }
>>
>>
> 


-- 

Coly Li



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux