linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Hartmut Knaack <knaack.h@gmx.de>,
	Cristina Opriceana <cristina.opriceana@gmail.com>
Cc: lars@metafoo.de, pmeerw@pmeerw.net, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org, daniel.baluta@intel.com,
	octavian.purdila@intel.com
Subject: Re: [PATCH 3/3] tools: iio: Add ARRAY_SIZE macro
Date: Sun, 19 Jul 2015 15:03:04 +0100	[thread overview]
Message-ID: <55ABAE18.4000308@kernel.org> (raw)
In-Reply-To: <55A4083C.6030107@gmx.de>

On 13/07/15 19:49, Hartmut Knaack wrote:
> Cristina Opriceana schrieb am 13.07.2015 um 15:20:
>> Calculation of the length of an array can be done with the ARRAY_SIZE
>> macro to make code more abstract and remove the associated
>> checkpatch.pl warning.
>>
>> Signed-off-by: Cristina Opriceana <cristina.opriceana@gmail.com>
> Acked-by: Hartmut Knaack <knaack.h@gmx.de>
Applied to the togreg branch of iio.git and initially pushed out as
testing.  Good patch set, thanks!

Jonathan
>> ---
>>  tools/iio/iio_utils.c | 2 +-
>>  tools/iio/iio_utils.h | 2 ++
>>  2 files changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c
>> index 4a7e480..e177f40 100644
>> --- a/tools/iio/iio_utils.c
>> +++ b/tools/iio/iio_utils.c
>> @@ -39,7 +39,7 @@ int iioutils_break_up_name(const char *full_name, char **generic_name)
>>  	char *working, *prefix = "";
>>  	int i, ret;
>>  
>> -	for (i = 0; i < sizeof(iio_direction) / sizeof(iio_direction[0]); i++)
>> +	for (i = 0; i < ARRAY_SIZE(iio_direction); i++)
>>  		if (!strncmp(full_name, iio_direction[i],
>>  			     strlen(iio_direction[i]))) {
>>  			prefix = iio_direction[i];
>> diff --git a/tools/iio/iio_utils.h b/tools/iio/iio_utils.h
>> index 0866101..f30a109 100644
>> --- a/tools/iio/iio_utils.h
>> +++ b/tools/iio/iio_utils.h
>> @@ -18,6 +18,8 @@
>>  #define FORMAT_SCAN_ELEMENTS_DIR "%s/scan_elements"
>>  #define FORMAT_TYPE_FILE "%s_type"
>>  
>> +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
>> +
>>  extern const char *iio_dir;
>>  
>>  /**
>>
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


      reply	other threads:[~2015-07-19 14:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-13 13:13 [PATCH 0/3] tools: iio: Fix style issues Cristina Opriceana
2015-07-13 13:15 ` [PATCH 1/3] tools: iio: Remove explicit NULL comparison Cristina Opriceana
2015-07-13 18:46   ` Hartmut Knaack
2015-07-19 14:01     ` Jonathan Cameron
2015-07-13 13:17 ` [PATCH 2/3] tools: iio: Remove unnecessary braces Cristina Opriceana
2015-07-13 18:48   ` Hartmut Knaack
2015-07-19 14:02     ` Jonathan Cameron
2015-07-13 13:20 ` [PATCH 3/3] tools: iio: Add ARRAY_SIZE macro Cristina Opriceana
2015-07-13 18:49   ` Hartmut Knaack
2015-07-19 14:03     ` Jonathan Cameron [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55ABAE18.4000308@kernel.org \
    --to=jic23@kernel.org \
    --cc=cristina.opriceana@gmail.com \
    --cc=daniel.baluta@intel.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=octavian.purdila@intel.com \
    --cc=pmeerw@pmeerw.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).