Menu

#1 six simple coding bugs and fixes

open
nobody
None
5
2008-06-25
2008-06-25
No

I ran the Tru64 source through my C/C++ syntax checker and found the following problems.

I will run my checker with more verbosity and submit any other bugs found.

Larry

./advfs_tru64_src_v1/kernel/msfs/bs/bs_tagdir.c: comparison takes precedence over assignment near line 1551
if (sts = check_mcell_ptr (*vdIndex, *bfMCId, *tp, domain) != EOK ) {
...

add parens to fix:

if ((sts = check_mcell_ptr (*vdIndex, *bfMCId, *tp, domain)) != EOK ) {
...
----------------------------------------------------------------------

./advfs_tru64_src_v1/kernel/msfs/osf/msfs_vfsops.c: comparison takes precedence over assignment near line 1157
if (sts = bs_access(
&bfap,
dn->rootTag,
dn->bfSetp,
FtxNilFtxH,
BF_OP_GET_VNODE,
mp,
&nvp
) != EOK) {
...

add parens to fix:

if ((sts = bs_access(
&bfap,
dn->rootTag,
dn->bfSetp,
FtxNilFtxH,
BF_OP_GET_VNODE,
mp,
&nvp
)) != EOK) {
...

----------------------------------------------------------------------

./advfs_tru64_src_v1/kernel/msfs/osf/msfs_vnops.c: comparison takes precedence over assignment near line 1117
if (sts = fs_update_stats(vp, bfap, FtxNilFtxH, 0) != EOK) {
...

add parens to fix:

if ((sts = fs_update_stats(vp, bfap, FtxNilFtxH, 0)) != EOK) {
...
----------------------------------------------------------------------

./advfs_tru64_src_v1/kernel/msfs/osf/msfs_vnops.c: comparison takes precedence over bitwise-and near line 5890

if ((flag & RGETFLCK == 0) && (flag & RSETFLCK == 0)) {
...

add parens to fix:

if (((flag & RGETFLCK) == 0) && ((flag & RSETFLCK) == 0)) {
...

----------------------------------------------------------------------

./advfs_tru64_src_v1/sbin/advfs/salvage/salvage_build.c: comparison takes precedence over bitwise-and near line 2337
if (pShadow->bsXA[x].vdBlk != XTNT_TERM &
pShadow->bsXA[x].vdBlk != PERM_HOLE_START)
...

change & to && to fix

if (pShadow->bsXA[x].vdBlk != XTNT_TERM &&
pShadow->bsXA[x].vdBlk != PERM_HOLE_START)
...

----------------------------------------------------------------------

./advfs_tru64_src_v1/sbin/backup/vdump/vdump.c: comparison takes precedence over assignment near line 4292
if (rcnt = write( fd, blk, cnt ) == ERROR) {
...

add parens to fix:

if ((rcnt = write( fd, blk, cnt )) == ERROR) {
...

----------------------------------------------------------------------

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.