Project Name | CID | Checker | Category | Developer Description |
---|---|---|---|---|
xfsprogs | 1297531 | DEADCODE | Control flow issues | Relatively low, but also relatively hilarious - someone decided to "shut up" a GCC warning in 2006 by putting parentheses around an assignment used as a truth value, but misplaced them - this bug has been there for 9 years, until Coverity spotted it! |
694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 |
fshandlep = jdm_getfshandle( mntdir ); if ( ! fshandlep ) { fsrprintf(_("unable to get handle: %s: %s\n"), mntdir, strerror( errno )); return -1; } if ((fsfd = open(mntdir, O_RDONLY)) < 0) { fsrprintf(_("unable to open: %s: %s\n"), mntdir, strerror( errno )); free(fshandlep); return -1; } if (xfs_getgeom(fsfd, &fsgeom) < 0 ) { fsrprintf(_("Skipping %s: could not get XFS geometry\n"), mntdir); close(fsfd); free(fshandlep); return -1; } tmp_init(mntdir); |
<< Assigning: "ret" = "xfs_bulkstat(fsfd, &lastino, 64, &buf[0], &buflenout) == 0".
718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 |
while ((ret = xfs_bulkstat(fsfd, &lastino, GRABSZ, &buf[0], &buflenout) == 0)) { xfs_bstat_t *p; xfs_bstat_t *endp; if (buflenout == 0) goto out0; /* Each loop through, defrag targetrange percent of the files */ count = (buflenout * targetrange) / 100; qsort((char *)buf, buflenout, sizeof(struct xfs_bstat), cmp); for (p = buf, endp = (buf + buflenout); p < endp ; p++) { /* Do some obvious checks now */ if (((p->bs_mode & S_IFMT) != S_IFREG) || (p->bs_extents < 2)) continue; fd = jdm_open(fshandlep, p, O_RDWR|O_DIRECT); if (fd < 0) { /* This probably means the file was * removed while in progress of handling * it. Just quietly ignore this file. */ if (dflag) fsrprintf(_("could not open: " "inode %llu\n"), p->bs_ino); continue; } /* Don't know the pathname, so make up something */ sprintf(fname, "ino=%lld", (long long)p->bs_ino); /* Get a tmp file name */ tname = tmp_next(mntdir); ret = fsrfile_common(fname, tname, mntdir, fd, p); leftoffino = p->bs_ino; close(fd); if (ret == 0) { if (--count <= 0) break; } } if (endtime && endtime < time(0)) { tmp_close(mntdir); close(fsfd); fsrall_cleanup(1); exit(1); } } |
<< The condition "ret < 0" cannot be true.
773 |
if (ret < 0) |
<<< CID 1297531: Control flow issues DEADCODE <<< Execution cannot reach this statement: "fsrprintf(dcgettext(NULL, "...".
774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 |
fsrprintf(_("%s: xfs_bulkstat: %s\n"), progname, strerror(errno)); out0: tmp_close(mntdir); close(fsfd); free(fshandlep); return 0; } /* * To compare bstat structs for qsort. */ int cmp(const void *s1, const void *s2) { return( ((xfs_bstat_t *)s2)->bs_extents - ((xfs_bstat_t *)s1)->bs_extents); } /* * reorganize by directory hierarchy. * Stay in dev (a restriction based on structure of this program -- either * call efs_{n,u}mount() around each file, something smarter or this) */ static void fsrdir(char *dirname) { |
assignment | xfs_fsr.c:718 | |
const | xfs_fsr.c:773 | |
dead_error_condition | xfs_fsr.c:773 | |
dead_error_line | xfs_fsr.c:774 |