Re: [PATCH 11/23] files_transaction_cleanup(): new helper function

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

 



On 05/17/2017 03:19 PM, Jeff King wrote:
> On Wed, May 17, 2017 at 02:05:34PM +0200, Michael Haggerty wrote:
> 
>> Extract function from `files_transaction_commit()`. It will soon have
>> another caller.
>> [...]
>> @@ -2868,10 +2889,8 @@ static int files_transaction_commit(struct ref_store *ref_store,
>>  	if (transaction->state != REF_TRANSACTION_OPEN)
>>  		die("BUG: commit called for transaction that is not open");
>>  
>> -	if (!transaction->nr) {
>> -		transaction->state = REF_TRANSACTION_CLOSED;
>> -		return 0;
>> -	}
>> +	if (!transaction->nr)
>> +		goto cleanup;
> 
> This is slightly more than it says on the tin. I guess the reason is
> that the cleanup function is going to learn about more than just
> iterating over the transaction, and we'll want to trigger it even for
> empty transactions.

Mostly this is just DRY. For example, later the cleanup will be changed
to set the state to `REF_TRANSACTION_PREPARED` rather than
`REF_TRANSACTION_CLOSED`, and that change will be able to be made in one
place rather than two. I'll mention this in the commit message.

Michael




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]