lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <50642ECB.20707@kernel.dk>
Date:	Thu, 27 Sep 2012 12:47:39 +0200
From:	Jens Axboe <axboe@...nel.dk>
To:	Tejun Heo <tj@...nel.org>
CC:	Maxim Levitsky <maximlevitsky@...il.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Alex Dubov <oakad@...oo.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] scatterlist: add sg_nents

On 09/26/2012 06:38 PM, Tejun Heo wrote:
> (cc'ing Jens)
> 
> On Wed, Sep 26, 2012 at 11:49:00AM +0200, Maxim Levitsky wrote:
>> Useful helper to know the number of entries in scatterlist.
>>
>> Signed-off-by: Maxim Levitsky <maximlevitsky@...il.com>
>> ---
>>  include/linux/scatterlist.h |    1 +
>>  lib/scatterlist.c           |   22 ++++++++++++++++++++++
>>  2 files changed, 23 insertions(+)
>>
>> diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
>> index 7b600da..4bd6c06 100644
>> --- a/include/linux/scatterlist.h
>> +++ b/include/linux/scatterlist.h
>> @@ -201,6 +201,7 @@ static inline void *sg_virt(struct scatterlist *sg)
>>  	return page_address(sg_page(sg)) + sg->offset;
>>  }
>>  
>> +int sg_nents(struct scatterlist *sg);
>>  struct scatterlist *sg_next(struct scatterlist *);
>>  struct scatterlist *sg_last(struct scatterlist *s, unsigned int);
>>  void sg_init_table(struct scatterlist *, unsigned int);
>> diff --git a/lib/scatterlist.c b/lib/scatterlist.c
>> index e76d85c..5cd9cdc 100644
>> --- a/lib/scatterlist.c
>> +++ b/lib/scatterlist.c
>> @@ -39,6 +39,28 @@ struct scatterlist *sg_next(struct scatterlist *sg)
>>  EXPORT_SYMBOL(sg_next);
>>  
>>  /**
>> + * sg_nents - return total count of entries in scatterlist
>> + * @sg:		The scatterlist
>> + *
>> + * Description:
>> + * Allows to know how many entries are in sg, taking into acount
>> + * chaining as well
>> + *
>> + **/
>> +int sg_nents(struct scatterlist *sg)
>> +{
>> +	int nents = 0;
>> +	while (sg) {
>> +		nents++;
>> +		sg = sg_next(sg);
>> +	}
>> +
>> +	return nents;
>> +}
>> +EXPORT_SYMBOL(sg_nents);
> 
> How about the following instead?
> 
> 	for (nents = 0; sg; sg = sg_next(sg))
> 		nents++;
> 	return nents;
> 
> Other than that,
> 
>  Acked-by: Tejun Heo <tj@...nel.org>

Agree, that'd be cleaner. I've just applied it as-is. Maxim, feel free
to send an update to it. I pulled the driver bit into the
for-3.7/drivers branch as well.

-- 
Jens Axboe

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ