[Ocfs2-tools-devel] [PATCH] Cleanup unused variables

Goldwyn Rodrigues rgoldwyn at gmail.com
Thu Mar 1 12:46:35 PST 2012


Hi Sunil,


On Fri, Feb 24, 2012 at 11:55 AM, Sunil Mushran
<sunil.mushran at oracle.com> wrote:
> This mixes up trivial and non-trivial. Please separate them.
> The non-trivial will need a thorough review.


I went through the changes again and I did not find any non-trivial
changes. All variables eliminated are examples of variables being
assigned to, but not used later in the function. There is only one
case where the variable is used, in ocfs2_split_extent(), where eb is
used to find out rightmost_el. However, rightmost_el is also not used
making the use of eb useless.

If you want them to be split into smaller patches, say file-wise, let
me know and I will do so.

>
>
> On 02/24/2012 09:50 AM, Goldwyn Rodrigues wrote:
>>
>> Compiler warnings of unused variables. This will need a thorough review.
>>
>> extent_tree.c: In function ‘ocfs2_new_path’:
>> extent_tree.c:432:12: warning: variable ‘ret’ set but not used
>> extent_tree.c: In function ‘ocfs2_rotate_subtree_right’:
>> extent_tree.c:1429:29: warning: variable ‘eb’ set but not used
>> extent_tree.c:1425:8: warning: variable ‘right_leaf_eb’ set but not used
>> extent_tree.c: In function ‘ocfs2_unlink_subtree’:
>> extent_tree.c:1802:28: warning: variable ‘el’ set but not used
>> extent_tree.c: In function ‘ocfs2_rotate_subtree_left’:
>> extent_tree.c:1837:8: warning: variable ‘root_buf’ set but not used
>> extent_tree.c: In function ‘ocfs2_split_extent’:
>> extent_tree.c:3766:28: warning: variable ‘rightmost_el’ set but not used
>> extent_tree.c: In function ‘ocfs2_truncate_rec’:
>> extent_tree.c:4033:6: warning: variable ‘wants_rotate’ set but not used
>> extent_tree.c: In function ‘ocfs2_split_extent’:
>> extent_tree.c:3781:30: warning: variable ‘eb’ set but not used
>> dir_indexed.c: In function ‘ocfs2_dx_dir_transfer_leaf’:
>> dir_indexed.c:759:42: warning: variable ‘new_list’ set but not used
>> commands.c:1179:17: warning: variable ‘traverse’ set but not used
>> jconfig.c: In function ‘j_config_parse_base’:
>> jconfig.c:318:12: warning: variable ‘toknam’ set but not used
>> jconfig.c: In function ‘j_config_add_stanza’:
>> jconfig.c:1063:12: warning: variable ‘tmp’ set but not used
>> pacemaker.c:46:13: warning: ‘stonithd_ci’ defined but not used
>> test_client.c:24:18: warning: ‘fill_uuid’ defined but not used
>> libo2info.c: In function ‘do_fiemap’:
>> libo2info.c:408:25: warning: variable ‘blk_shift’ set but not used
>>
>> Signed-off-by: Goldwyn Rodrigues<rgoldwyn at suse.de>
>> ---
>>  debugfs.ocfs2/commands.c   |    6 ++----
>>  libocfs2/dir_indexed.c     |    3 +--
>>  libocfs2/extent_tree.c     |   26 +++-----------------------
>>  o2cb_ctl/jconfig.c         |    6 ------
>>  o2info/libo2info.c         |    5 +----
>>  ocfs2_controld/pacemaker.c |    1 -
>>  6 files changed, 7 insertions(+), 40 deletions(-)
>>
>> diff --git a/debugfs.ocfs2/commands.c b/debugfs.ocfs2/commands.c
>> index bb70bd1..a94bfcd 100644
>> --- a/debugfs.ocfs2/commands.c
>> +++ b/debugfs.ocfs2/commands.c
>> @@ -1176,7 +1176,7 @@ static void do_logdump(char **args)
>>        uint16_t slotnum;
>>        uint64_t blkno;
>>        FILE *out;
>> -       int index = 1, traverse = 1;
>> +       int index = 1;
>>        const char *logdump_usage = "usage: logdump [-T]<slot#>";
>>
>>        if (check_device_open())
>> @@ -1187,10 +1187,8 @@ static void do_logdump(char **args)
>>                return ;
>>        }
>>
>> -       if (!strncmp(args[index], "-T", 2)) {
>> -               traverse = 0;
>> +       if (!strncmp(args[index], "-T", 2))
>>                index++;
>> -       }
>>
>>        if (get_slotnum(args[index],&slotnum)) {
>>                fprintf(stderr, "%s: Invalid node slot number\n", args[0]);
>> diff --git a/libocfs2/dir_indexed.c b/libocfs2/dir_indexed.c
>> index 11e762a..41e0f80 100644
>> --- a/libocfs2/dir_indexed.c
>> +++ b/libocfs2/dir_indexed.c
>> @@ -756,7 +756,7 @@ static errcode_t
>> ocfs2_dx_dir_transfer_leaf(ocfs2_filesys *fs,
>>        int i, j, num_used;
>>        uint32_t major_hash;
>>        struct ocfs2_dx_leaf *orig_dx_leaf, *new_dx_leaf;
>> -       struct ocfs2_dx_entry_list *orig_list, *new_list, *tmp_list;
>> +       struct ocfs2_dx_entry_list *orig_list, *tmp_list;
>>        struct ocfs2_dx_entry *dx_entry;
>>
>>        tmp_list =&tmp_dx_leaf->dl_list;
>>
>> @@ -765,7 +765,6 @@ static errcode_t
>> ocfs2_dx_dir_transfer_leaf(ocfs2_filesys *fs,
>>                orig_dx_leaf = orig_dx_leaves[i];
>>                orig_list =&orig_dx_leaf->dl_list;
>>                new_dx_leaf = new_dx_leaves[i];
>> -               new_list =&new_dx_leaf->dl_list;
>>
>>
>>                num_used = orig_list->de_num_used;
>>
>> diff --git a/libocfs2/extent_tree.c b/libocfs2/extent_tree.c
>> index 738cb66..373cac6 100644
>> --- a/libocfs2/extent_tree.c
>> +++ b/libocfs2/extent_tree.c
>> @@ -429,12 +429,11 @@ static struct ocfs2_path *ocfs2_new_path(char *buf,
>>                                         struct ocfs2_extent_list *root_el,
>>                                         uint64_t blkno)
>>  {
>> -       errcode_t ret = 0;
>>        struct ocfs2_path *path = NULL;
>>
>>        assert(root_el->l_tree_depth<  OCFS2_MAX_PATH_DEPTH);
>>
>> -       ret = ocfs2_malloc0(sizeof(*path),&path);
>> +       ocfs2_malloc0(sizeof(*path),&path);
>>        if (path) {
>>                path->p_tree_depth = root_el->l_tree_depth;
>>                path->p_node[0].blkno = blkno;
>> @@ -1422,14 +1421,9 @@ static errcode_t
>> ocfs2_rotate_subtree_right(ocfs2_filesys *fs,
>>  {
>>        errcode_t ret;
>>        int i;
>> -       char *right_leaf_eb;
>> -       char *left_leaf_eb = NULL;
>>        struct ocfs2_extent_list *right_el, *left_el;
>>        struct ocfs2_extent_rec move_rec;
>> -       struct ocfs2_extent_block *eb;
>>
>> -       left_leaf_eb = path_leaf_buf(left_path);
>> -       eb = (struct ocfs2_extent_block *)left_leaf_eb;
>>        left_el = path_leaf_el(left_path);
>>
>>        if (left_el->l_next_free_rec != left_el->l_count)
>> @@ -1445,7 +1439,6 @@ static errcode_t
>> ocfs2_rotate_subtree_right(ocfs2_filesys *fs,
>>        assert(left_path->p_node[subtree_index].blkno ==
>>               right_path->p_node[subtree_index].blkno);
>>
>> -       right_leaf_eb = path_leaf_buf(right_path);
>>        right_el = path_leaf_el(right_path);
>>
>>        ocfs2_create_empty_extent(right_el);
>> @@ -1799,11 +1792,8 @@ static errcode_t ocfs2_unlink_subtree(ocfs2_filesys
>> *fs,
>>        errcode_t ret;
>>        int i;
>>        struct ocfs2_extent_list *root_el =
>> left_path->p_node[subtree_index].el;
>> -       struct ocfs2_extent_list *el;
>>        struct ocfs2_extent_block *eb;
>>
>> -       el = path_leaf_el(left_path);
>> -
>>        eb = (struct ocfs2_extent_block *)right_path->p_node[subtree_index
>> + 1].buf;
>>
>>        for(i = 1; i<  root_el->l_next_free_rec; i++)
>> @@ -1834,7 +1824,6 @@ static int ocfs2_rotate_subtree_left(ocfs2_filesys
>> *fs,
>>  {
>>        errcode_t ret;
>>        int i, del_right_subtree = 0, right_has_empty = 0;
>> -       char *root_buf;
>>        struct ocfs2_extent_list *right_leaf_el, *left_leaf_el;
>>        struct ocfs2_extent_block *eb;
>>
>> @@ -1842,7 +1831,6 @@ static int ocfs2_rotate_subtree_left(ocfs2_filesys
>> *fs,
>>
>>        right_leaf_el = path_leaf_el(right_path);
>>        left_leaf_el = path_leaf_el(left_path);
>> -       root_buf = left_path->p_node[subtree_index].buf;
>>        assert(left_path->p_node[subtree_index].blkno ==
>>               right_path->p_node[subtree_index].blkno);
>>
>> @@ -3763,7 +3751,6 @@ static int ocfs2_split_extent(struct insert_ctxt
>> *insert_ctxt,
>>        char *last_eb_buf = NULL;
>>        struct ocfs2_extent_rec *rec =&el->l_recs[split_index];
>>
>>        struct ocfs2_merge_ctxt merge_ctxt;
>> -       struct ocfs2_extent_list *rightmost_el;
>>        ocfs2_filesys *fs = insert_ctxt->fs;
>>
>>        if (rec->e_cpos>  split_rec.e_cpos ||
>> @@ -3791,18 +3778,12 @@ static int ocfs2_split_extent(struct
>> insert_ctxt *insert_ctxt,
>>         * rightmost extent list.
>>         */
>>        if (path->p_tree_depth) {
>> -               struct ocfs2_extent_block *eb;
>>                ret = ocfs2_read_extent_block(fs,
>>                                ocfs2_et_get_last_eb_blk(insert_ctxt->et),
>>                                last_eb_buf);
>>                if (ret)
>>                        goto out;
>> -
>> -               eb = (struct ocfs2_extent_block *) last_eb_buf;
>> -
>> -               rightmost_el =&eb->h_list;
>>
>> -       } else
>> -               rightmost_el = path_root_el(path);
>> +       }
>>
>>        if (rec->e_cpos == split_rec.e_cpos&&
>>        rec->e_leaf_clusters == split_rec.e_leaf_clusters)
>> @@ -4030,7 +4011,7 @@ static int ocfs2_truncate_rec(ocfs2_filesys *fs,
>>  {
>>        errcode_t ret;
>>        uint32_t left_cpos, rec_range, trunc_range;
>> -       int wants_rotate = 0, is_rightmost_tree_rec = 0;
>> +       int is_rightmost_tree_rec = 0;
>>        struct ocfs2_path *left_path = NULL;
>>        struct ocfs2_extent_list *el = path_leaf_el(path);
>>        struct ocfs2_extent_rec *rec;
>> @@ -4096,7 +4077,6 @@ static int ocfs2_truncate_rec(ocfs2_filesys *fs,
>>
>>                memset(rec, 0, sizeof(*rec));
>>                ocfs2_cleanup_merge(el, index);
>> -               wants_rotate = 1;
>>
>>                next_free = el->l_next_free_rec;
>>                if (is_rightmost_tree_rec&&  next_free>  1) {
>>
>> diff --git a/o2cb_ctl/jconfig.c b/o2cb_ctl/jconfig.c
>> index d5bb975..bad34ba 100644
>> --- a/o2cb_ctl/jconfig.c
>> +++ b/o2cb_ctl/jconfig.c
>> @@ -315,7 +315,6 @@ static JConfig *j_config_parse_any(JConfigCtxt *cfc,
>>  static void j_config_parse_base(GScanner *scanner, JConfigCtxt *cfc)
>>  {
>>      gboolean done;
>> -    gchar *toknam;
>>      GTokenValue *value;
>>
>>      value =&scanner->next_value;
>>
>> @@ -369,11 +368,9 @@ static void j_config_parse_base(GScanner
>> *scanner, JConfigCtxt *cfc)
>>                  /* Another one I don't think I should get */
>>                  break;
>>              case G_TOKEN_IDENTIFIER:
>> -                toknam = "G_TOKEN_IDENTIFIER";
>>                  j_config_parse_stanza_name(scanner, cfc);
>>                  break;
>>              default:
>> -                toknam = "NONE";
>>                  if (cfc->verbose)
>>                      g_warning("Unknown token\n");
>>                  cfc->error = TRUE;
>> @@ -1060,7 +1057,6 @@ JConfigStanza *j_config_add_stanza(JConfig *cf,
>>  {
>>      JConfigStanza *cfs;
>>      GList *elem;
>> -    GList *tmp;
>>
>>      g_return_val_if_fail(cf != NULL, NULL);
>>      g_return_val_if_fail(stanza_name != NULL, NULL);
>> @@ -1086,8 +1082,6 @@ JConfigStanza *j_config_add_stanza(JConfig *cf,
>>                              g_strdup(stanza_name),
>>                              elem);
>>      }
>> -    else
>> -        tmp = g_list_append(elem, cfs);
>>
>>      return(cfs);
>>  }  /* j_config_add_stanza() */
>> diff --git a/o2info/libo2info.c b/o2info/libo2info.c
>> index c98a58e..cff7c2d 100644
>> --- a/o2info/libo2info.c
>> +++ b/o2info/libo2info.c
>> @@ -405,7 +405,7 @@ static int do_fiemap(int fd, int flags, struct
>> o2info_fiemap *ofp)
>>        char buf[4096];
>>
>>        int ret = 0, last = 0;
>> -       int cluster_shift = 0, blk_shift = 0;
>> +       int cluster_shift = 0;
>>        int count = (sizeof(buf) - sizeof(struct fiemap)) /
>>                     sizeof(struct fiemap_extent);
>>
>> @@ -419,9 +419,6 @@ static int do_fiemap(int fd, int flags, struct
>> o2info_fiemap *ofp)
>>        if (ofp->clustersize)
>>                cluster_shift = ul_log2(ofp->clustersize);
>>
>> -       if (ofp->blocksize)
>> -               blk_shift = ul_log2(ofp->blocksize);
>> -
>>        memset(fiemap, 0, sizeof(*fiemap));
>>
>>        ret = figure_extents(fd,&num_extents, 0);
>>
>> diff --git a/ocfs2_controld/pacemaker.c b/ocfs2_controld/pacemaker.c
>> index 822cf41..18f776a 100644
>> --- a/ocfs2_controld/pacemaker.c
>> +++ b/ocfs2_controld/pacemaker.c
>> @@ -43,7 +43,6 @@
>>
>>  int                   our_nodeid = 0;
>>  static int            pcmk_ci;
>> -static int             stonithd_ci;
>>  static char *         clustername = "pacemaker";
>>  extern struct list_head mounts;
>>  const char *stackname = "pcmk";



-- 
Goldwyn



More information about the Ocfs2-tools-devel mailing list