linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio/inkern.c Use list_for_each_entry_safe
@ 2015-12-08 16:42 Anshul Garg
  2015-12-08 17:02 ` kbuild test robot
  2015-12-08 17:14 ` kbuild test robot
  0 siblings, 2 replies; 5+ messages in thread
From: Anshul Garg @ 2015-12-08 16:42 UTC (permalink / raw)
  To: jic23, knaack.h, lars, pmeerw, linux-iio, linux-kernel; +Cc: Anshul Garg

Use list_for_each_entry_safe instead of list_for_each_safe
and list_entry call.

Signed-off-by: Anshul Garg <aksgarg1989@gmail.com>
---
 drivers/iio/inkern.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index c8bad3c..f764eb6 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -61,12 +61,10 @@ EXPORT_SYMBOL_GPL(iio_map_array_register);
 int iio_map_array_unregister(struct iio_dev *indio_dev)
 {
 	int ret = -ENODEV;
-	struct iio_map_internal *mapi;
-	struct list_head *pos, *tmp;
+	struct iio_map_internal *mapi, *next;
 
 	mutex_lock(&iio_map_list_lock);
-	list_for_each_safe(pos, tmp, &iio_map_list) {
-		mapi = list_entry(pos, struct iio_map_internal, l);
+	list_for_each_entry_safe(mapi, next, &iio_map_listi, list) {
 		if (indio_dev == mapi->indio_dev) {
 			list_del(&mapi->l);
 			kfree(mapi);
-- 
1.7.9.5


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] iio/inkern.c Use list_for_each_entry_safe
  2015-12-08 16:42 Anshul Garg
@ 2015-12-08 17:02 ` kbuild test robot
  2015-12-08 17:14 ` kbuild test robot
  1 sibling, 0 replies; 5+ messages in thread
From: kbuild test robot @ 2015-12-08 17:02 UTC (permalink / raw)
  To: Anshul Garg
  Cc: kbuild-all, jic23, knaack.h, lars, pmeerw, linux-iio,
	linux-kernel, Anshul Garg

[-- Attachment #1: Type: text/plain, Size: 12767 bytes --]

Hi Anshul,

[auto build test ERROR on v4.4-rc4]
[also build test ERROR on next-20151208]

url:    https://github.com/0day-ci/linux/commits/Anshul-Garg/iio-inkern-c-Use-list_for_each_entry_safe/20151209-005155
config: x86_64-randconfig-x014-201549 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/list.h:8:0,
                    from include/linux/preempt.h:10,
                    from include/linux/spinlock.h:50,
                    from include/linux/mmzone.h:7,
                    from include/linux/gfp.h:5,
                    from include/linux/slab.h:14,
                    from drivers/iio/inkern.c:11:
   drivers/iio/inkern.c: In function 'iio_map_array_unregister':
>> include/linux/kernel.h:813:27: error: 'struct iio_map_internal' has no member named 'list'
     const typeof( ((type *)0)->member ) *__mptr = (ptr); \
                              ^
   include/linux/list.h:352:2: note: in expansion of macro 'container_of'
     container_of(ptr, type, member)
     ^
   include/linux/list.h:363:2: note: in expansion of macro 'list_entry'
     list_entry((ptr)->next, type, member)
     ^
   include/linux/list.h:521:13: note: in expansion of macro 'list_first_entry'
     for (pos = list_first_entry(head, typeof(*pos), member), \
                ^
>> drivers/iio/inkern.c:67:2: note: in expansion of macro 'list_for_each_entry_safe'
     list_for_each_entry_safe(mapi, next, &iio_map_listi, list) {
     ^
>> drivers/iio/inkern.c:67:40: error: 'iio_map_listi' undeclared (first use in this function)
     list_for_each_entry_safe(mapi, next, &iio_map_listi, list) {
                                           ^
   include/linux/kernel.h:813:49: note: in definition of macro 'container_of'
     const typeof( ((type *)0)->member ) *__mptr = (ptr); \
                                                    ^
   include/linux/list.h:363:2: note: in expansion of macro 'list_entry'
     list_entry((ptr)->next, type, member)
     ^
   include/linux/list.h:521:13: note: in expansion of macro 'list_first_entry'
     for (pos = list_first_entry(head, typeof(*pos), member), \
                ^
>> drivers/iio/inkern.c:67:2: note: in expansion of macro 'list_for_each_entry_safe'
     list_for_each_entry_safe(mapi, next, &iio_map_listi, list) {
     ^
   drivers/iio/inkern.c:67:40: note: each undeclared identifier is reported only once for each function it appears in
     list_for_each_entry_safe(mapi, next, &iio_map_listi, list) {
                                           ^
   include/linux/kernel.h:813:49: note: in definition of macro 'container_of'
     const typeof( ((type *)0)->member ) *__mptr = (ptr); \
                                                    ^
   include/linux/list.h:363:2: note: in expansion of macro 'list_entry'
     list_entry((ptr)->next, type, member)
     ^
   include/linux/list.h:521:13: note: in expansion of macro 'list_first_entry'
     for (pos = list_first_entry(head, typeof(*pos), member), \
                ^
>> drivers/iio/inkern.c:67:2: note: in expansion of macro 'list_for_each_entry_safe'
     list_for_each_entry_safe(mapi, next, &iio_map_listi, list) {
     ^
   In file included from include/linux/compiler.h:56:0,
                    from include/linux/err.h:4,
                    from drivers/iio/inkern.c:9:
>> include/linux/compiler-gcc.h:158:2: error: 'struct iio_map_internal' has no member named 'list'
     __builtin_offsetof(a, b)
     ^
   include/linux/stddef.h:16:32: note: in expansion of macro '__compiler_offsetof'
    #define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
                                   ^
   include/linux/kernel.h:814:29: note: in expansion of macro 'offsetof'
     (type *)( (char *)__mptr - offsetof(type,member) );})
                                ^
   include/linux/list.h:352:2: note: in expansion of macro 'container_of'
     container_of(ptr, type, member)
     ^
   include/linux/list.h:363:2: note: in expansion of macro 'list_entry'
     list_entry((ptr)->next, type, member)
     ^
   include/linux/list.h:521:13: note: in expansion of macro 'list_first_entry'
     for (pos = list_first_entry(head, typeof(*pos), member), \
                ^
>> drivers/iio/inkern.c:67:2: note: in expansion of macro 'list_for_each_entry_safe'
     list_for_each_entry_safe(mapi, next, &iio_map_listi, list) {
     ^
   In file included from include/linux/list.h:8:0,
                    from include/linux/preempt.h:10,
                    from include/linux/spinlock.h:50,
                    from include/linux/mmzone.h:7,
                    from include/linux/gfp.h:5,
                    from include/linux/slab.h:14,
                    from drivers/iio/inkern.c:11:
>> include/linux/kernel.h:813:27: error: 'struct iio_map_internal' has no member named 'list'
     const typeof( ((type *)0)->member ) *__mptr = (ptr); \
                              ^
   include/linux/list.h:352:2: note: in expansion of macro 'container_of'
     container_of(ptr, type, member)
     ^
   include/linux/list.h:393:2: note: in expansion of macro 'list_entry'
     list_entry((pos)->member.next, typeof(*(pos)), member)
     ^
   include/linux/list.h:522:7: note: in expansion of macro 'list_next_entry'
      n = list_next_entry(pos, member);   \
          ^
>> drivers/iio/inkern.c:67:2: note: in expansion of macro 'list_for_each_entry_safe'
     list_for_each_entry_safe(mapi, next, &iio_map_listi, list) {
     ^
>> include/linux/list.h:393:18: error: 'struct iio_map_internal' has no member named 'list'
     list_entry((pos)->member.next, typeof(*(pos)), member)
                     ^
   include/linux/kernel.h:813:49: note: in definition of macro 'container_of'
     const typeof( ((type *)0)->member ) *__mptr = (ptr); \
                                                    ^
   include/linux/list.h:393:2: note: in expansion of macro 'list_entry'
     list_entry((pos)->member.next, typeof(*(pos)), member)
     ^
   include/linux/list.h:522:7: note: in expansion of macro 'list_next_entry'
      n = list_next_entry(pos, member);   \
          ^
>> drivers/iio/inkern.c:67:2: note: in expansion of macro 'list_for_each_entry_safe'
     list_for_each_entry_safe(mapi, next, &iio_map_listi, list) {
     ^
   In file included from include/linux/compiler.h:56:0,
                    from include/linux/err.h:4,
                    from drivers/iio/inkern.c:9:
>> include/linux/compiler-gcc.h:158:2: error: 'struct iio_map_internal' has no member named 'list'
     __builtin_offsetof(a, b)
     ^
   include/linux/stddef.h:16:32: note: in expansion of macro '__compiler_offsetof'
    #define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
                                   ^
   include/linux/kernel.h:814:29: note: in expansion of macro 'offsetof'
     (type *)( (char *)__mptr - offsetof(type,member) );})
                                ^
   include/linux/list.h:352:2: note: in expansion of macro 'container_of'
     container_of(ptr, type, member)
     ^
   include/linux/list.h:393:2: note: in expansion of macro 'list_entry'
     list_entry((pos)->member.next, typeof(*(pos)), member)
     ^
   include/linux/list.h:522:7: note: in expansion of macro 'list_next_entry'
      n = list_next_entry(pos, member);   \
          ^
>> drivers/iio/inkern.c:67:2: note: in expansion of macro 'list_for_each_entry_safe'
     list_for_each_entry_safe(mapi, next, &iio_map_listi, list) {
     ^
   In file included from include/linux/preempt.h:10:0,
                    from include/linux/spinlock.h:50,
                    from include/linux/mmzone.h:7,
                    from include/linux/gfp.h:5,
                    from include/linux/slab.h:14,
                    from drivers/iio/inkern.c:11:
   include/linux/list.h:521:57: warning: left-hand operand of comma expression has no effect [-Wunused-value]
     for (pos = list_first_entry(head, typeof(*pos), member), \
                                                            ^
>> drivers/iio/inkern.c:67:2: note: in expansion of macro 'list_for_each_entry_safe'
     list_for_each_entry_safe(mapi, next, &iio_map_listi, list) {
     ^
   include/linux/list.h:523:11: error: 'struct iio_map_internal' has no member named 'list'
          &pos->member != (head);      \
              ^
>> drivers/iio/inkern.c:67:2: note: in expansion of macro 'list_for_each_entry_safe'
     list_for_each_entry_safe(mapi, next, &iio_map_listi, list) {
     ^
   In file included from include/linux/list.h:8:0,
                    from include/linux/preempt.h:10,
                    from include/linux/spinlock.h:50,
                    from include/linux/mmzone.h:7,
                    from include/linux/gfp.h:5,
                    from include/linux/slab.h:14,
                    from drivers/iio/inkern.c:11:
>> include/linux/kernel.h:813:27: error: 'struct iio_map_internal' has no member named 'list'
     const typeof( ((type *)0)->member ) *__mptr = (ptr); \
                              ^
   include/linux/list.h:352:2: note: in expansion of macro 'container_of'
     container_of(ptr, type, member)
     ^
   include/linux/list.h:393:2: note: in expansion of macro 'list_entry'
     list_entry((pos)->member.next, typeof(*(pos)), member)
     ^
   include/linux/list.h:524:20: note: in expansion of macro 'list_next_entry'
          pos = n, n = list_next_entry(n, member))
                       ^
>> drivers/iio/inkern.c:67:2: note: in expansion of macro 'list_for_each_entry_safe'
     list_for_each_entry_safe(mapi, next, &iio_map_listi, list) {
     ^
>> include/linux/list.h:393:18: error: 'struct iio_map_internal' has no member named 'list'
     list_entry((pos)->member.next, typeof(*(pos)), member)
                     ^
   include/linux/kernel.h:813:49: note: in definition of macro 'container_of'
     const typeof( ((type *)0)->member ) *__mptr = (ptr); \
                                                    ^
   include/linux/list.h:393:2: note: in expansion of macro 'list_entry'
     list_entry((pos)->member.next, typeof(*(pos)), member)
     ^
   include/linux/list.h:524:20: note: in expansion of macro 'list_next_entry'
          pos = n, n = list_next_entry(n, member))
                       ^
>> drivers/iio/inkern.c:67:2: note: in expansion of macro 'list_for_each_entry_safe'
     list_for_each_entry_safe(mapi, next, &iio_map_listi, list) {
     ^
   In file included from include/linux/compiler.h:56:0,
                    from include/linux/err.h:4,
                    from drivers/iio/inkern.c:9:
>> include/linux/compiler-gcc.h:158:2: error: 'struct iio_map_internal' has no member named 'list'
     __builtin_offsetof(a, b)
     ^
   include/linux/stddef.h:16:32: note: in expansion of macro '__compiler_offsetof'
    #define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
                                   ^
   include/linux/kernel.h:814:29: note: in expansion of macro 'offsetof'
     (type *)( (char *)__mptr - offsetof(type,member) );})
                                ^
   include/linux/list.h:352:2: note: in expansion of macro 'container_of'
     container_of(ptr, type, member)
     ^
   include/linux/list.h:393:2: note: in expansion of macro 'list_entry'
     list_entry((pos)->member.next, typeof(*(pos)), member)
     ^
   include/linux/list.h:524:20: note: in expansion of macro 'list_next_entry'
          pos = n, n = list_next_entry(n, member))
                       ^

vim +813 include/linux/kernel.h

^1da177e Linus Torvalds 2005-04-16  807   * @ptr:	the pointer to the member.
^1da177e Linus Torvalds 2005-04-16  808   * @type:	the type of the container struct this is embedded in.
^1da177e Linus Torvalds 2005-04-16  809   * @member:	the name of the member within the struct.
^1da177e Linus Torvalds 2005-04-16  810   *
^1da177e Linus Torvalds 2005-04-16  811   */
^1da177e Linus Torvalds 2005-04-16  812  #define container_of(ptr, type, member) ({			\
^1da177e Linus Torvalds 2005-04-16 @813  	const typeof( ((type *)0)->member ) *__mptr = (ptr);	\
^1da177e Linus Torvalds 2005-04-16  814  	(type *)( (char *)__mptr - offsetof(type,member) );})
^1da177e Linus Torvalds 2005-04-16  815  
b9d4f426 Arnaud Lacombe 2011-07-25  816  /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */

:::::: The code at line 813 was first introduced by commit
:::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:::::: TO: Linus Torvalds <torvalds@ppc970.osdl.org>
:::::: CC: Linus Torvalds <torvalds@ppc970.osdl.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 21227 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] iio/inkern.c Use list_for_each_entry_safe
  2015-12-08 16:42 Anshul Garg
  2015-12-08 17:02 ` kbuild test robot
@ 2015-12-08 17:14 ` kbuild test robot
  1 sibling, 0 replies; 5+ messages in thread
From: kbuild test robot @ 2015-12-08 17:14 UTC (permalink / raw)
  To: Anshul Garg
  Cc: kbuild-all, jic23, knaack.h, lars, pmeerw, linux-iio,
	linux-kernel, Anshul Garg

[-- Attachment #1: Type: text/plain, Size: 2287 bytes --]

Hi Anshul,

[auto build test ERROR on v4.4-rc4]
[also build test ERROR on next-20151208]

url:    https://github.com/0day-ci/linux/commits/Anshul-Garg/iio-inkern-c-Use-list_for_each_entry_safe/20151209-005155
config: sh-allyesconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=sh 

All errors (new ones prefixed by >>):

   drivers/iio/inkern.c: In function 'iio_map_array_unregister':
>> drivers/iio/inkern.c:67:2: error: 'struct iio_map_internal' has no member named 'list'
   drivers/iio/inkern.c:67:2: error: 'iio_map_listi' undeclared (first use in this function)
   drivers/iio/inkern.c:67:2: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/iio/inkern.c:67:2: error: 'struct iio_map_internal' has no member named 'list'
>> drivers/iio/inkern.c:67:2: error: 'struct iio_map_internal' has no member named 'list'
>> drivers/iio/inkern.c:67:2: error: 'struct iio_map_internal' has no member named 'list'
>> drivers/iio/inkern.c:67:2: error: 'struct iio_map_internal' has no member named 'list'
   drivers/iio/inkern.c:67:2: warning: left-hand operand of comma expression has no effect [-Wunused-value]
>> drivers/iio/inkern.c:67:2: error: 'struct iio_map_internal' has no member named 'list'
>> drivers/iio/inkern.c:67:2: error: 'struct iio_map_internal' has no member named 'list'
>> drivers/iio/inkern.c:67:2: error: 'struct iio_map_internal' has no member named 'list'
>> drivers/iio/inkern.c:67:2: error: 'struct iio_map_internal' has no member named 'list'

vim +67 drivers/iio/inkern.c

    61	int iio_map_array_unregister(struct iio_dev *indio_dev)
    62	{
    63		int ret = -ENODEV;
    64		struct iio_map_internal *mapi, *next;
    65	
    66		mutex_lock(&iio_map_list_lock);
  > 67		list_for_each_entry_safe(mapi, next, &iio_map_listi, list) {
    68			if (indio_dev == mapi->indio_dev) {
    69				list_del(&mapi->l);
    70				kfree(mapi);

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 37980 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] iio/inkern.c Use list_for_each_entry_safe
@ 2015-12-08 17:45 Anshul Garg
  2015-12-12 17:23 ` Jonathan Cameron
  0 siblings, 1 reply; 5+ messages in thread
From: Anshul Garg @ 2015-12-08 17:45 UTC (permalink / raw)
  To: jic23, knaack.h, lars, pmeerw, linux-iio, linux-kernel; +Cc: Anshul Garg

Use list_for_each_entry_safe instead of list_for_each_safe
and list_entry call.

Signed-off-by: Anshul Garg <aksgarg1989@gmail.com>
---
 drivers/iio/inkern.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index c8bad3c..f764eb6 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -61,12 +61,10 @@ EXPORT_SYMBOL_GPL(iio_map_array_register);
 int iio_map_array_unregister(struct iio_dev *indio_dev)
 {
 	int ret = -ENODEV;
-	struct iio_map_internal *mapi;
-	struct list_head *pos, *tmp;
+	struct iio_map_internal *mapi, *next;
 
 	mutex_lock(&iio_map_list_lock);
-	list_for_each_safe(pos, tmp, &iio_map_list) {
-		mapi = list_entry(pos, struct iio_map_internal, l);
+	list_for_each_entry_safe(mapi, next, &iio_map_list, l) {
 		if (indio_dev == mapi->indio_dev) {
 			list_del(&mapi->l);
 			kfree(mapi);
-- 
1.7.9.5


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] iio/inkern.c Use list_for_each_entry_safe
  2015-12-08 17:45 [PATCH] iio/inkern.c Use list_for_each_entry_safe Anshul Garg
@ 2015-12-12 17:23 ` Jonathan Cameron
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2015-12-12 17:23 UTC (permalink / raw)
  To: Anshul Garg, knaack.h, lars, pmeerw, linux-iio, linux-kernel

On 08/12/15 17:45, Anshul Garg wrote:
> Use list_for_each_entry_safe instead of list_for_each_safe
> and list_entry call.
> 
> Signed-off-by: Anshul Garg <aksgarg1989@gmail.com>
Applied to the togreg branch of iio.git - initially pushed out
as testing for the autobuilder to play with it.

Thanks,

Jonathan
> ---
>  drivers/iio/inkern.c |    6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index c8bad3c..f764eb6 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -61,12 +61,10 @@ EXPORT_SYMBOL_GPL(iio_map_array_register);
>  int iio_map_array_unregister(struct iio_dev *indio_dev)
>  {
>  	int ret = -ENODEV;
> -	struct iio_map_internal *mapi;
> -	struct list_head *pos, *tmp;
> +	struct iio_map_internal *mapi, *next;
>  
>  	mutex_lock(&iio_map_list_lock);
> -	list_for_each_safe(pos, tmp, &iio_map_list) {
> -		mapi = list_entry(pos, struct iio_map_internal, l);
> +	list_for_each_entry_safe(mapi, next, &iio_map_list, l) {
>  		if (indio_dev == mapi->indio_dev) {
>  			list_del(&mapi->l);
>  			kfree(mapi);
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-12-12 17:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-08 17:45 [PATCH] iio/inkern.c Use list_for_each_entry_safe Anshul Garg
2015-12-12 17:23 ` Jonathan Cameron
  -- strict thread matches above, loose matches on Subject: below --
2015-12-08 16:42 Anshul Garg
2015-12-08 17:02 ` kbuild test robot
2015-12-08 17:14 ` kbuild test robot

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).