glusterfs icon indicating copy to clipboard operation
glusterfs copied to clipboard

Clang warning fixes

Open mykaul opened this issue 10 months ago • 7 comments

This is a series of independent patches (can be cherry-picked independently if needed) that fix warnings that clang (19.1.7) complained when Gluster was compiled with it.

Signed-off-by: Yaniv Kaul [email protected]

mykaul avatar Feb 17 '25 10:02 mykaul

CLANG-FORMAT FAILURE: Before merging the patch, this diff needs to be considered for passing clang-format

index 9e1999613..bf77d88d9 100644
--- a/xlators/features/shard/src/shard.c
+++ b/xlators/features/shard/src/shard.c
@@ -1289,7 +1289,8 @@ shard_refresh_internal_dir_cbk(call_frame_t *frame, void *cookie,
 {
     shard_local_t *local = NULL;
     inode_t *linked_inode = NULL;
-    shard_internal_dir_type_t type = (shard_internal_dir_type_t)(unsigned long)cookie;
+    shard_internal_dir_type_t type = (shard_internal_dir_type_t)(unsigned long)
+        cookie;
 
     local = frame->local;
 
@@ -1370,7 +1371,8 @@ shard_lookup_internal_dir_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
 {
     inode_t *link_inode = NULL;
     shard_local_t *local = NULL;
-    shard_internal_dir_type_t type = (shard_internal_dir_type_t)(unsigned long)cookie;
+    shard_internal_dir_type_t type = (shard_internal_dir_type_t)(unsigned long)
+        cookie;
 
     local = frame->local;
 
@@ -5889,7 +5891,8 @@ shard_mkdir_internal_dir_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
 {
     inode_t *link_inode = NULL;
     shard_local_t *local = NULL;
-    shard_internal_dir_type_t type = (shard_internal_dir_type_t)(unsigned long)cookie;
+    shard_internal_dir_type_t type = (shard_internal_dir_type_t)(unsigned long)
+        cookie;
 
     local = frame->local;
 
diff --git a/xlators/features/simple-quota/src/simple-quota.c b/xlators/features/simple-quota/src/simple-quota.c
index 244458a99..5a928fc71 100644
--- a/xlators/features/simple-quota/src/simple-quota.c
+++ b/xlators/features/simple-quota/src/simple-quota.c
@@ -129,7 +129,7 @@ sq_set_ns_hardlimit(xlator_t *this, inode_t *inode, int64_t limit, int64_t size,
     ret = inode_ctx_put(inode, this, (uint64_t)(uintptr_t)sq_ctx);
     if (IS_ERROR(ret)) {
         GF_FREE(sq_ctx);
-	sq_ctx = NULL;
+        sq_ctx = NULL;
         goto out;
     }
 
@@ -217,7 +217,9 @@ sq_update_brick_usage(xlator_t *this, inode_t *inode)
     if (!tmp_mq) {
         goto out;
     }
-    loc_t loc = { 0, };
+    loc_t loc = {
+        0,
+    };
     loc.inode = inode_ref(inode);
     int ret = syncop_getxattr(FIRST_CHILD(this), &loc, &dict, SQUOTA_SIZE_KEY,
                               NULL, NULL);
@@ -262,7 +264,7 @@ sq_update_hard_limit(xlator_t *this, inode_t *ns, int64_t limit, int64_t size)
            limit, size);
     sq_ctx->hard_lim = limit;
 
-    //GF_ASSERT(size > 0);
+    // GF_ASSERT(size > 0);
 
 out:
     return;
diff --git a/xlators/protocol/client/src/client.h b/xlators/protocol/client/src/client.h
index d974650fa..96bf86fc8 100644
--- a/xlators/protocol/client/src/client.h
+++ b/xlators/protocol/client/src/client.h
@@ -95,8 +95,8 @@ typedef struct clnt_conf {
     rpc_clnt_prog_t *dump;
 
     int client_id;
-    int event_threads; /* # of event threads
-                        * configured */
+    int event_threads;        /* # of event threads
+                               * configured */
     uint64_t reopen_fd_count; /* Count of fds reopened after a
                                  connection is established */
     gf_lock_t rec_lock;
@@ -123,7 +123,7 @@ typedef struct clnt_conf {
                                   */
     gf_boolean_t filter_o_direct; /* if set, filter O_DIRECT from
                                      the flags list of open() */
-    gf_boolean_t send_gids; /* let the server resolve gids */
+    gf_boolean_t send_gids;       /* let the server resolve gids */
 
     gf_boolean_t destroy; /* if enabled implies fini was called
                            * on @this xlator instance */
@@ -136,7 +136,7 @@ typedef struct clnt_conf {
                                       * logged
                                       */
 
-    gf_boolean_t old_protocol;         /* used only for old-protocol testing */
+    gf_boolean_t old_protocol; /* used only for old-protocol testing */
     gf_boolean_t fini_completed;
     gf_boolean_t strict_locks; /* When set, doesn't reopen saved fds after
                                   reconnect if POSIX locks are held on them.
@@ -145,8 +145,8 @@ typedef struct clnt_conf {
                                   complaince as bricks cleanup any granted
                                   locks when a client disconnects.
                                */
-    gf_boolean_t connection_to_brick; /*True from attempt to connect to brick
-                                        till disconnection to brick*/
+    gf_boolean_t connection_to_brick;  /*True from attempt to connect to brick
+                                         till disconnection to brick*/
     pthread_cond_t fini_complete_cond; /* Used to wait till we finsh the fini
                                           compltely, ie client_fini_complete
                                           to return*/

gluster-ant avatar Feb 17 '25 10:02 gluster-ant

CLANG-FORMAT FAILURE: Before merging the patch, this diff needs to be considered for passing clang-format

index 244458a99..5a928fc71 100644
--- a/xlators/features/simple-quota/src/simple-quota.c
+++ b/xlators/features/simple-quota/src/simple-quota.c
@@ -129,7 +129,7 @@ sq_set_ns_hardlimit(xlator_t *this, inode_t *inode, int64_t limit, int64_t size,
     ret = inode_ctx_put(inode, this, (uint64_t)(uintptr_t)sq_ctx);
     if (IS_ERROR(ret)) {
         GF_FREE(sq_ctx);
-	sq_ctx = NULL;
+        sq_ctx = NULL;
         goto out;
     }
 
@@ -217,7 +217,9 @@ sq_update_brick_usage(xlator_t *this, inode_t *inode)
     if (!tmp_mq) {
         goto out;
     }
-    loc_t loc = { 0, };
+    loc_t loc = {
+        0,
+    };
     loc.inode = inode_ref(inode);
     int ret = syncop_getxattr(FIRST_CHILD(this), &loc, &dict, SQUOTA_SIZE_KEY,
                               NULL, NULL);
@@ -262,7 +264,7 @@ sq_update_hard_limit(xlator_t *this, inode_t *ns, int64_t limit, int64_t size)
            limit, size);
     sq_ctx->hard_lim = limit;
 
-    //GF_ASSERT(size > 0);
+    // GF_ASSERT(size > 0);
 
 out:
     return;
diff --git a/xlators/protocol/client/src/client.h b/xlators/protocol/client/src/client.h
index d974650fa..96bf86fc8 100644
--- a/xlators/protocol/client/src/client.h
+++ b/xlators/protocol/client/src/client.h
@@ -95,8 +95,8 @@ typedef struct clnt_conf {
     rpc_clnt_prog_t *dump;
 
     int client_id;
-    int event_threads; /* # of event threads
-                        * configured */
+    int event_threads;        /* # of event threads
+                               * configured */
     uint64_t reopen_fd_count; /* Count of fds reopened after a
                                  connection is established */
     gf_lock_t rec_lock;
@@ -123,7 +123,7 @@ typedef struct clnt_conf {
                                   */
     gf_boolean_t filter_o_direct; /* if set, filter O_DIRECT from
                                      the flags list of open() */
-    gf_boolean_t send_gids; /* let the server resolve gids */
+    gf_boolean_t send_gids;       /* let the server resolve gids */
 
     gf_boolean_t destroy; /* if enabled implies fini was called
                            * on @this xlator instance */
@@ -136,7 +136,7 @@ typedef struct clnt_conf {
                                       * logged
                                       */
 
-    gf_boolean_t old_protocol;         /* used only for old-protocol testing */
+    gf_boolean_t old_protocol; /* used only for old-protocol testing */
     gf_boolean_t fini_completed;
     gf_boolean_t strict_locks; /* When set, doesn't reopen saved fds after
                                   reconnect if POSIX locks are held on them.
@@ -145,8 +145,8 @@ typedef struct clnt_conf {
                                   complaince as bricks cleanup any granted
                                   locks when a client disconnects.
                                */
-    gf_boolean_t connection_to_brick; /*True from attempt to connect to brick
-                                        till disconnection to brick*/
+    gf_boolean_t connection_to_brick;  /*True from attempt to connect to brick
+                                         till disconnection to brick*/
     pthread_cond_t fini_complete_cond; /* Used to wait till we finsh the fini
                                           compltely, ie client_fini_complete
                                           to return*/

gluster-ant avatar Feb 17 '25 13:02 gluster-ant

CLANG-FORMAT FAILURE: Before merging the patch, this diff needs to be considered for passing clang-format

index d974650fa..96bf86fc8 100644
--- a/xlators/protocol/client/src/client.h
+++ b/xlators/protocol/client/src/client.h
@@ -95,8 +95,8 @@ typedef struct clnt_conf {
     rpc_clnt_prog_t *dump;
 
     int client_id;
-    int event_threads; /* # of event threads
-                        * configured */
+    int event_threads;        /* # of event threads
+                               * configured */
     uint64_t reopen_fd_count; /* Count of fds reopened after a
                                  connection is established */
     gf_lock_t rec_lock;
@@ -123,7 +123,7 @@ typedef struct clnt_conf {
                                   */
     gf_boolean_t filter_o_direct; /* if set, filter O_DIRECT from
                                      the flags list of open() */
-    gf_boolean_t send_gids; /* let the server resolve gids */
+    gf_boolean_t send_gids;       /* let the server resolve gids */
 
     gf_boolean_t destroy; /* if enabled implies fini was called
                            * on @this xlator instance */
@@ -136,7 +136,7 @@ typedef struct clnt_conf {
                                       * logged
                                       */
 
-    gf_boolean_t old_protocol;         /* used only for old-protocol testing */
+    gf_boolean_t old_protocol; /* used only for old-protocol testing */
     gf_boolean_t fini_completed;
     gf_boolean_t strict_locks; /* When set, doesn't reopen saved fds after
                                   reconnect if POSIX locks are held on them.
@@ -145,8 +145,8 @@ typedef struct clnt_conf {
                                   complaince as bricks cleanup any granted
                                   locks when a client disconnects.
                                */
-    gf_boolean_t connection_to_brick; /*True from attempt to connect to brick
-                                        till disconnection to brick*/
+    gf_boolean_t connection_to_brick;  /*True from attempt to connect to brick
+                                         till disconnection to brick*/
     pthread_cond_t fini_complete_cond; /* Used to wait till we finsh the fini
                                           compltely, ie client_fini_complete
                                           to return*/

gluster-ant avatar Feb 17 '25 15:02 gluster-ant

@pranithk - can you please review this? I fixed all clang issues, have no idea what it's complaining about here. Some are benign, but some may be real issues that we wish to get fixed. As I use clang, it'd be easier to work without seeing all the warnings during compilation (of course there are many many more, mainly on dead assignments)

mykaul avatar Feb 20 '25 11:02 mykaul

Can one of the admins review this change?

mykaul avatar Mar 01 '25 12:03 mykaul

I will do it by this Friday. Sorry for the delay in response, I was feeling a bit under the weather.

pranithk avatar Mar 04 '25 10:03 pranithk

@gluster/gluster-maintainers please review.

mykaul avatar Apr 18 '25 16:04 mykaul