[systemd-devel] [PATCH 2/4] shared: mark strv_length() _pure_

2013-12-01 Thread Shawn Landden
---
 src/shared/strv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/shared/strv.c b/src/shared/strv.c
index 607c221..cc6adfa 100644
--- a/src/shared/strv.c
+++ b/src/shared/strv.c
@@ -84,7 +84,7 @@ char **strv_copy(char * const *l) {
 return r;
 }
 
-unsigned strv_length(char * const *l) {
+_pure_ unsigned strv_length(char * const *l) {
 unsigned n = 0;
 
 if (!l)
-- 
1.8.4.4

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 2/4] shared: mark strv_length() _pure_

2013-12-01 Thread Zbigniew Jędrzejewski-Szmek
On Sun, Dec 01, 2013 at 02:50:15PM -0800, Shawn Landden wrote:
> ---
>  src/shared/strv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/shared/strv.c b/src/shared/strv.c
> index 607c221..cc6adfa 100644
> --- a/src/shared/strv.c
> +++ b/src/shared/strv.c
> @@ -84,7 +84,7 @@ char **strv_copy(char * const *l) {
>  return r;
>  }
>  
> -unsigned strv_length(char * const *l) {
> +_pure_ unsigned strv_length(char * const *l) {
>  unsigned n = 0;
>  
_pure_ only makes sense in .h files, except for static functions of course, 
which
are not declared in an .h file. This annotation tells the compiler how to 
optimize
calls to the function, so it must be available where it is used.

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 2/4] shared: mark strv_length() _pure_

2013-12-01 Thread Shawn Landden
On Sun, Dec 1, 2013 at 3:59 PM, Zbigniew Jędrzejewski-Szmek
 wrote:
> On Sun, Dec 01, 2013 at 02:50:15PM -0800, Shawn Landden wrote:
>> ---
>>  src/shared/strv.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/shared/strv.c b/src/shared/strv.c
>> index 607c221..cc6adfa 100644
>> --- a/src/shared/strv.c
>> +++ b/src/shared/strv.c
>> @@ -84,7 +84,7 @@ char **strv_copy(char * const *l) {
>>  return r;
>>  }
>>
>> -unsigned strv_length(char * const *l) {
>> +_pure_ unsigned strv_length(char * const *l) {
>>  unsigned n = 0;
>>
> _pure_ only makes sense in .h files, except for static functions of course, 
> which
> are not declared in an .h file. This annotation tells the compiler how to 
> optimize
> calls to the function, so it must be available where it is used.
yes indeed, and in the .h file its already _pure_.
>
> Zbyszek
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel