xfsprogs: remove write-only assignments
PATCH 1/1 xfsprogs: remove write-only assignments
There are many instances where variable assignments are made, but never read (or are re-assigned before they are read). The Clang static analyzer finds these.
Here's a chunk of what I think are trivial removals of such assignments; other detections point to more serious problems (or are shared w/ kernel code so should probably be fixed there first).
---
These may be a bit tedious to review; perhaps graphical diff w/ more context would help in some cases?
copy/xfs_copy.c +1 -2
@@ -238,7 +238,7 @@ killall(void)void handler (int sig) { -pid_t pid =getpid (); +pid_t pid;int status, i; pid =wait (&status);
@@ -912,7 +912,6 @@ main(int argc, char **argv) - (__uint64_t)mp->m_sb.sb_fdblocks + 10 * num_ags)); kids = num_targets; - block = (struct xfs_btree_block *) btree_buf.data;for (agno =0 ; agno < num_ags && kids >0 ; agno++) {/* read in first blocks of the ag */
db/bmap.c +0 -1
@@ -88,7 +88,6 @@ bmap( } }else if (fmt ==XFS_DINODE_FMT_BTREE ) {push_cur (); - bno =NULLFSBLOCK ; rblock = (xfs_bmdr_block_t *)XFS_DFORK_PTR (dip, whichfork); fsize =XFS_DFORK_SIZE (dip, mp, whichfork); pp =XFS_BMDR_PTR_ADDR (rblock,1 ,xfs_bmdr_maxrecs (mp, fsize,0 ));
db/check.c +0 -1
@@ -1186,7 +1186,6 @@ blockuse_f(return 0 ; } optind =0 ; - count =1 ; shownames =0 ; fsb =XFS_DADDR_TO_FSB (mp, iocur_top->off >>BBSHIFT ); agno =XFS_FSB_TO_AGNO (mp, fsb);
db/convert.c +0 -1
@@ -200,7 +200,6 @@ convert_f(int argc, char **argv)if (cur_agno !=NULLAGNUMBER && (conmask &M (AGNUMBER )) ==0 ) { cvals[CT_AGNUMBER ].agnumber = cur_agno; mask |=M (AGNUMBER ); - conmask |= ~ctydescs[CT_AGNUMBER ].allowed; } v =0 ;for (c = (ctype_t )0 ; c <NCTS ; c++) {
growfs/xfs_growfs.c +0 -1
@@ -132,7 +132,6 @@ main(int argc, char **argv) maxpct = esize =0 ; dsize = lsize = rsize =0LL ; aflag = dflag = iflag = lflag = mflag = nflag = rflag = xflag =0 ; - ci =0 ;while ((c =getopt (argc, argv,"dD:e:ilL:m:np:rR:t:xV" )) !=EOF ) {switch (c) {
include/bitops.h +0 -1
@@ -28,7 +28,6 @@ static inline int fls(int x) r -=2 ; }if (!(x &0x80000000u )) { - x <<=1 ; r -=1 ; }return r;
libxfs/rdwr.c +1 -1
@@ -741,7 +741,7 @@ libxfs_readbuf(struct xfs_buftarg *btp, xfs_daddr_t blkno, int len, int flags,int libxfs_readbufr_map (struct xfs_buftarg *btp,struct xfs_buf *bp,int flags) { -int fd =libxfs_device_to_fd (btp->dev); +int fd;int error =0 ;char *buf;int i;
logprint/log_misc.c +0 -1
@@ -736,7 +736,6 @@ xlog_print_trans_inode( *ptr +=be32_to_cpu (op_head->oh_len);if (op_head->oh_flags &XLOG_CONTINUE_TRANS )return 1 ; - op_head = (xlog_op_header_t *)*ptr; }return 0 ;
logprint/log_print_all.c +0 -1
@@ -89,7 +89,6 @@ xlog_recover_print_buffer(xfs_disk_dquot_t *ddq; f = (xfs_buf_log_format_t *)item->ri_buf[0 ].i_addr; - len = item->ri_buf[0 ].i_len;printf (" " );ASSERT (f->blf_type ==XFS_LI_BUF ); printf(_("BUF: #regs:%d start blkno:0x%llx len:%d bmap size:%d flags:0x%x\n"),
mkfs/xfs_mkfs.c +0 -2
@@ -1964,8 +1964,6 @@ _("32 bit Project IDs always enabled on CRC enabled filesytems\n"));int rswidth;__uint64_t rtextbytes; - rswidth =0 ; -if (!norsflag && !xi.risfile && !(!rtsize && xi.disfile)) rswidth = ft.rtswidth;else
quota/path.c +2 -2
@@ -62,9 +62,9 @@ printpath(else if (qstat.qs_flags &XFS_QUOTA_GDQ_ACCT ) c =printf ("%sgqnoenforce" , c ?", " :"" );if (qstat.qs_flags &XFS_QUOTA_PDQ_ENFD ) - c =printf ("%spquota" , c ?", " :"" ); +printf ("%spquota" , c ?", " :"" );else if (qstat.qs_flags &XFS_QUOTA_PDQ_ACCT ) - c =printf ("%spqnoenforce" , c ?", " :"" ); +printf ("%spqnoenforce" , c ?", " :"" );printf (")" ); }printf ("\n" );
repair/attr_repair.c +0 -2
@@ -623,8 +623,6 @@ verify_da_path(xfs_mount_t *mp,#ifdef XR_DIR_TRACE cursor->level[this_level].n = newnode;#endif - node = newnode; - entry = cursor->level[this_level].index =0 ; }/*
repair/dir2.c +1 -2
@@ -606,7 +606,6 @@ _("bad level %d in block %u for directory inode %" PRIu64 "\n"), cursor->level[this_level].bno = dabno; cursor->level[this_level].hashval =be32_to_cpu (btree[0 ].hashval); - node = newnode; entry = cursor->level[this_level].index =0 ; }
@@ -780,7 +779,7 @@ process_sf_dir2(* run through entries, stop at first bad entry, don't need * to check for .. since that's encoded in its own field */ - sfep = next_sfep =xfs_dir2_sf_firstentry (sfp); + next_sfep =xfs_dir2_sf_firstentry (sfp);for (i =0 ; i < num_entries && ino_dir_size > (char *)next_sfep - (char *)sfp; i++) {
repair/phase5.c +0 -3
@@ -153,7 +153,6 @@ mk_incore_fstree(xfs_mount_t *mp, xfs_agnumber_t agno)/* * free extent ends here */ - in_extent =0 ;#if defined(XR_BLD_FREE_TRACE ) && defined(XR_BLD_ADD_EXTENT )fprintf (stderr,"adding extent %u [%u %u]\n" , agno, extent_start, extent_len);
@@ -223,7 +222,6 @@ setup_cursor(xfs_mount_t *mp, xfs_agnumber_t agno, bt_status_t *curs)do_error (_ ("error - not enough free space in filesystem\n" )); agb_ptr = curs->btree_blocks; - j = curs->level[0 ].num_blocks;/* * set up the free block array
@@ -438,7 +436,6 @@ calculate_freespace_cursor(xfs_mount_t *mp, xfs_agnumber_t agno,do_error (_ ("can't rebuild fs trees -- not enough free space " "on ag %u\n" ), agno); - i =0 ;while (ext_ptr !=NULL && blocks_needed >0 ) {if (ext_ptr->ex_blockcount <= blocks_needed) { blocks_needed -= ext_ptr->ex_blockcount;
repair/phase6.c +0 -1
@@ -1858,7 +1858,6 @@ _("entry \"%s\" in dir inode %" PRIu64 " inconsistent with .. value (%" PRIu64 "if (junkit) {if (inum == orphanage_ino) orphanage_ino =0 ; - junkit =0 ; nbad++;if (!no_modify) { dep->name[0 ] ='/' ;
repair/prefetch.c +0 -1
@@ -575,7 +575,6 @@ pf_batch_read(* go through the xfs_buf_t list copying from the * read buffer into the xfs_buf_t's and release them. */ - last_off = first_off;for (i =0 ; i < num; i++) { pbuf = ((char *)buf) + (LIBXFS_BBTOOFF64 (XFS_BUF_ADDR (bplist[i])) - first_off);
repair/sb.c +0 -2
@@ -597,8 +597,6 @@ free_geo(fs_geo_list_t *list)fs_geo_list_t *next;fs_geo_list_t *current; - current = list; -for (current = list; current !=NULL ; current = next) { next = current->next;free (current);
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 9 lines · Eric Sandeen
There are many instances where variable assignments are made, but never read (or are re-assigned before they are read). The Clang static analyzer finds these.
Here's a chunk of what I think are trivial removals of such assignments; other detections point to more serious problems (or are shared w/ kernel code so should probably be fixed there first).
Quoted 6 lines
Signed-off-by Eric Sandeen<[email protected]>---
These may be a bit tedious to review; perhaps graphical diff w/ more context would help in some cases?
This patch length is not so bad. Light reading with lunch. They all look good to me.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs