ocfs2/dlm: Clean up errors in dlmdomain.c

Message ID 62e91e34.969.18b27f9ec40.Coremail.wangkailong@jari.cn
State New
Headers
Series ocfs2/dlm: Clean up errors in dlmdomain.c |

Commit Message

KaiLong Wang Oct. 13, 2023, 7:39 a.m. UTC
  Fix the following errors reported by checkpatch:

ERROR: "foo * bar" should be "foo *bar"
ERROR: spaces required around that '=' (ctx:VxV)
ERROR: spaces required around that '==' (ctx:VxV)
ERROR: do not use assignment in if condition

Signed-off-by: KaiLong Wang <wangkailong@jari.cn>
---
 fs/ocfs2/dlm/dlmdomain.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
  

Comments

kernel test robot Oct. 17, 2023, 7:12 a.m. UTC | #1
Hi KaiLong,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on linus/master v6.6-rc6 next-20231017]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/KaiLong-Wang/ocfs2-dlm-Clean-up-errors-in-dlmdomain-c/20231017-115916
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/62e91e34.969.18b27f9ec40.Coremail.wangkailong%40jari.cn
patch subject: [PATCH] ocfs2/dlm: Clean up errors in dlmdomain.c
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20231017/202310171436.cr0GHO3X-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231017/202310171436.cr0GHO3X-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202310171436.cr0GHO3X-lkp@intel.com/

All warnings (new ones prefixed by >>):

   fs/ocfs2/dlm/dlmdomain.c: In function 'dlm_alloc_pagevec':
>> fs/ocfs2/dlm/dlmdomain.c:78:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
      78 |         for (i = 0; i < pages; i++)
         |         ^~~
   fs/ocfs2/dlm/dlmdomain.c:80:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
      80 |                 if (!(vec[i]))
         |                 ^~


vim +/for +78 fs/ocfs2/dlm/dlmdomain.c

03d864c02c3ea8 Daniel Phillips 2006-03-10  69  
03d864c02c3ea8 Daniel Phillips 2006-03-10  70  static void **dlm_alloc_pagevec(int pages)
03d864c02c3ea8 Daniel Phillips 2006-03-10  71  {
6da2ec56059c3c Kees Cook       2018-06-12  72  	void **vec = kmalloc_array(pages, sizeof(void *), GFP_KERNEL);
03d864c02c3ea8 Daniel Phillips 2006-03-10  73  	int i;
03d864c02c3ea8 Daniel Phillips 2006-03-10  74  
03d864c02c3ea8 Daniel Phillips 2006-03-10  75  	if (!vec)
03d864c02c3ea8 Daniel Phillips 2006-03-10  76  		return NULL;
03d864c02c3ea8 Daniel Phillips 2006-03-10  77  
03d864c02c3ea8 Daniel Phillips 2006-03-10 @78  	for (i = 0; i < pages; i++)
8586048e6e9be0 KaiLong Wang    2023-10-13  79  		vec[i] = (void *)__get_free_page(GFP_KERNEL);
8586048e6e9be0 KaiLong Wang    2023-10-13  80  		if (!(vec[i]))
03d864c02c3ea8 Daniel Phillips 2006-03-10  81  			goto out_free;
c8f33b6e86af74 Joel Becker     2006-03-16  82  
685f1adb3872d9 Mark Fasheh     2006-03-23  83  	mlog(0, "Allocated DLM hash pagevec; %d pages (%lu expected), %lu buckets per page\n",
f5a923d1ba648b Mark Fasheh     2006-11-28  84  	     pages, (unsigned long)DLM_HASH_PAGES,
f5a923d1ba648b Mark Fasheh     2006-11-28  85  	     (unsigned long)DLM_BUCKETS_PER_PAGE);
03d864c02c3ea8 Daniel Phillips 2006-03-10  86  	return vec;
03d864c02c3ea8 Daniel Phillips 2006-03-10  87  out_free:
03d864c02c3ea8 Daniel Phillips 2006-03-10  88  	dlm_free_pagevec(vec, i);
03d864c02c3ea8 Daniel Phillips 2006-03-10  89  	return NULL;
03d864c02c3ea8 Daniel Phillips 2006-03-10  90  }
03d864c02c3ea8 Daniel Phillips 2006-03-10  91
  
kernel test robot Oct. 19, 2023, 9:53 a.m. UTC | #2
Hi KaiLong,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on linus/master v6.6-rc6 next-20231019]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/KaiLong-Wang/ocfs2-dlm-Clean-up-errors-in-dlmdomain-c/20231017-115916
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/62e91e34.969.18b27f9ec40.Coremail.wangkailong%40jari.cn
patch subject: [PATCH] ocfs2/dlm: Clean up errors in dlmdomain.c
config: sh-allmodconfig (https://download.01.org/0day-ci/archive/20231019/202310191736.myy5k3i6-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231019/202310191736.myy5k3i6-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202310191736.myy5k3i6-lkp@intel.com/

All warnings (new ones prefixed by >>):

   fs/ocfs2/dlm/dlmdomain.c: In function 'dlm_alloc_pagevec':
   fs/ocfs2/dlm/dlmdomain.c:78:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
      78 |         for (i = 0; i < pages; i++)
         |         ^~~
   fs/ocfs2/dlm/dlmdomain.c:80:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
      80 |                 if (!(vec[i]))
         |                 ^~
   fs/ocfs2/dlm/dlmdomain.c: In function 'dlm_alloc_pagevec.constprop':
>> fs/ocfs2/dlm/dlmdomain.c:80:26: warning: array subscript 32 is outside array bounds of 'void[128]' [-Warray-bounds=]
      80 |                 if (!(vec[i]))
         |                      ~~~~^~~~
   In file included from fs/ocfs2/dlm/dlmdomain.c:12:
   In function 'kmalloc',
       inlined from 'kmalloc_array' at include/linux/slab.h:635:10,
       inlined from 'dlm_alloc_pagevec.constprop' at fs/ocfs2/dlm/dlmdomain.c:72:15:
   include/linux/slab.h:599:24: note: at offset 128 into object of size 128 allocated by 'kmalloc_trace'
     599 |                 return kmalloc_trace(
         |                        ^~~~~~~~~~~~~~
     600 |                                 kmalloc_caches[kmalloc_type(flags, _RET_IP_)][index],
         |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     601 |                                 flags, size);
         |                                 ~~~~~~~~~~~~


vim +80 fs/ocfs2/dlm/dlmdomain.c

    69	
    70	static void **dlm_alloc_pagevec(int pages)
    71	{
    72		void **vec = kmalloc_array(pages, sizeof(void *), GFP_KERNEL);
    73		int i;
    74	
    75		if (!vec)
    76			return NULL;
    77	
    78		for (i = 0; i < pages; i++)
    79			vec[i] = (void *)__get_free_page(GFP_KERNEL);
  > 80			if (!(vec[i]))
    81				goto out_free;
    82	
    83		mlog(0, "Allocated DLM hash pagevec; %d pages (%lu expected), %lu buckets per page\n",
    84		     pages, (unsigned long)DLM_HASH_PAGES,
    85		     (unsigned long)DLM_BUCKETS_PER_PAGE);
    86		return vec;
    87	out_free:
    88		dlm_free_pagevec(vec, i);
    89		return NULL;
    90	}
    91
  

Patch

diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c
index 5c04dde99981..a9955eb97625 100644
--- a/fs/ocfs2/dlm/dlmdomain.c
+++ b/fs/ocfs2/dlm/dlmdomain.c
@@ -76,7 +76,8 @@  static void **dlm_alloc_pagevec(int pages)
 		return NULL;
 
 	for (i = 0; i < pages; i++)
-		if (!(vec[i] = (void *)__get_free_page(GFP_KERNEL)))
+		vec[i] = (void *)__get_free_page(GFP_KERNEL);
+		if (!(vec[i]))
 			goto out_free;
 
 	mlog(0, "Allocated DLM hash pagevec; %d pages (%lu expected), %lu buckets per page\n",
@@ -170,7 +171,7 @@  void __dlm_insert_lockres(struct dlm_ctxt *dlm, struct dlm_lock_resource *res)
 	     res->lockname.name);
 }
 
-struct dlm_lock_resource * __dlm_lookup_lockres_full(struct dlm_ctxt *dlm,
+struct dlm_lock_resource *__dlm_lookup_lockres_full(struct dlm_ctxt *dlm,
 						     const char *name,
 						     unsigned int len,
 						     unsigned int hash)
@@ -203,7 +204,7 @@  struct dlm_lock_resource * __dlm_lookup_lockres_full(struct dlm_ctxt *dlm,
  * currently in the process of dropping its mastery reference.
  * use __dlm_lookup_lockres_full when you need the lock resource
  * regardless (e.g. dlm_get_lock_resource) */
-struct dlm_lock_resource * __dlm_lookup_lockres(struct dlm_ctxt *dlm,
+struct dlm_lock_resource *__dlm_lookup_lockres(struct dlm_ctxt *dlm,
 						const char *name,
 						unsigned int len,
 						unsigned int hash)
@@ -228,7 +229,7 @@  struct dlm_lock_resource * __dlm_lookup_lockres(struct dlm_ctxt *dlm,
 	return res;
 }
 
-struct dlm_lock_resource * dlm_lookup_lockres(struct dlm_ctxt *dlm,
+struct dlm_lock_resource *dlm_lookup_lockres(struct dlm_ctxt *dlm,
 				    const char *name,
 				    unsigned int len)
 {
@@ -241,7 +242,7 @@  struct dlm_lock_resource * dlm_lookup_lockres(struct dlm_ctxt *dlm,
 	return res;
 }
 
-static struct dlm_ctxt * __dlm_lookup_domain_full(const char *domain, int len)
+static struct dlm_ctxt *__dlm_lookup_domain_full(const char *domain, int len)
 {
 	struct dlm_ctxt *tmp;
 
@@ -251,7 +252,7 @@  static struct dlm_ctxt * __dlm_lookup_domain_full(const char *domain, int len)
 	 * but domain may not be! */
 	list_for_each_entry(tmp, &dlm_domains, list) {
 		if (strlen(tmp->name) == len &&
-		    memcmp(tmp->name, domain, len)==0)
+		    memcmp(tmp->name, domain, len) == 0)
 			return tmp;
 	}
 
@@ -259,7 +260,7 @@  static struct dlm_ctxt * __dlm_lookup_domain_full(const char *domain, int len)
 }
 
 /* For null terminated domain strings ONLY */
-static struct dlm_ctxt * __dlm_lookup_domain(const char *domain)
+static struct dlm_ctxt *__dlm_lookup_domain(const char *domain)
 {
 	assert_spin_locked(&dlm_domain_lock);
 
@@ -827,7 +828,7 @@  static int dlm_query_join_handler(struct o2net_msg *msg, u32 len, void *data,
 	 * node(s) that just left but still part of the cluster. DISALLOW
 	 * join request if joining node has different node map.
 	 */
-	nodenum=0;
+	nodenum = 0;
 	while (nodenum < O2NM_MAX_NODES) {
 		if (test_bit(nodenum, dlm->domain_map)) {
 			if (!byte_test_bit(nodenum, query->node_map)) {
@@ -2095,7 +2096,7 @@  static int dlm_protocol_compare(struct dlm_protocol_version *existing,
  * If registration was successful, proto will contain the negotiated
  * locking protocol.
  */
-struct dlm_ctxt * dlm_register_domain(const char *domain,
+struct dlm_ctxt *dlm_register_domain(const char *domain,
 			       u32 key,
 			       struct dlm_protocol_version *fs_proto)
 {