You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by Igor Galić <i....@brainsware.org> on 2013/04/26 21:06:53 UTC

Re: git commit: Replace SIZE() with COUNTOF() and countof()


----- Original Message -----
> Updated Branches:
>   refs/heads/master 207ac9a66 -> 1617f7620
> 
> 
> Replace SIZE() with COUNTOF() and countof()
[snip]
> Branch: refs/heads/master
> Commit: 1617f7620e652623779c28e29685f0f264190da5
> Parents: 207ac9a
[snip]
> diff --git a/iocore/cache/Cache.cc b/iocore/cache/Cache.cc
> index 9676291..bc273d3 100644
> --- a/iocore/cache/Cache.cc
> +++ b/iocore/cache/Cache.cc
> @@ -1167,7 +1166,7 @@ Vol::init(char *s, off_t blocks, off_t
> dir_skip, bool clear)
>    init_info->vol_aio[2].aiocb.aio_offset = bs;
>    init_info->vol_aio[3].aiocb.aio_offset = bs + footer_offset;
>  
> -  for (i = 0; i < 4; i++) {
> +  for (unsigned i = 0; i < countof(init_info->vol_aio); i++) {
>      AIOCallback *aio = &(init_info->vol_aio[i]);
>      aio->aiocb.aio_fildes = fd;
>      aio->aiocb.aio_buf = &(init_info->vol_h_f[i *
>      STORE_BLOCK_SIZE]);

Why not use size_t then?

-- i
Igor Galić

Tel: +43 (0) 664 886 22 883
Mail: i.galic@brainsware.org
URL: http://brainsware.org/
GPG: 6880 4155 74BD FD7C B515  2EA5 4B1D 9E08 A097 C9AE


Re: git commit: Replace SIZE() with COUNTOF() and countof()

Posted by James Peach <jp...@apache.org>.
On Apr 26, 2013, at 12:06 PM, Igor Galić <i....@brainsware.org> wrote:

> 
> 
> ----- Original Message -----
>> Updated Branches:
>>  refs/heads/master 207ac9a66 -> 1617f7620
>> 
>> 
>> Replace SIZE() with COUNTOF() and countof()
> [snip]
>> Branch: refs/heads/master
>> Commit: 1617f7620e652623779c28e29685f0f264190da5
>> Parents: 207ac9a
> [snip]
>> diff --git a/iocore/cache/Cache.cc b/iocore/cache/Cache.cc
>> index 9676291..bc273d3 100644
>> --- a/iocore/cache/Cache.cc
>> +++ b/iocore/cache/Cache.cc
>> @@ -1167,7 +1166,7 @@ Vol::init(char *s, off_t blocks, off_t
>> dir_skip, bool clear)
>>   init_info->vol_aio[2].aiocb.aio_offset = bs;
>>   init_info->vol_aio[3].aiocb.aio_offset = bs + footer_offset;
>> 
>> -  for (i = 0; i < 4; i++) {
>> +  for (unsigned i = 0; i < countof(init_info->vol_aio); i++) {
>>     AIOCallback *aio = &(init_info->vol_aio[i]);
>>     aio->aiocb.aio_fildes = fd;
>>     aio->aiocb.aio_buf = &(init_info->vol_h_f[i *
>>     STORE_BLOCK_SIZE]);
> 
> Why not use size_t then?

Just because it seemed like overkill. unsigned is large enough and doesn't need an additional header to be included. size_t is usually 8 bytes and then we have to go and use %zu and do all of that platform compatibility goop ...

> 
> -- i
> Igor Galić
> 
> Tel: +43 (0) 664 886 22 883
> Mail: i.galic@brainsware.org
> URL: http://brainsware.org/
> GPG: 6880 4155 74BD FD7C B515  2EA5 4B1D 9E08 A097 C9AE
>