From c56873bf95f6325b70e63ed56ce59a3c6b2b753b Mon Sep 17 00:00:00 2001 From: Cheyenne Wills Date: Mon, 27 Jul 2020 12:31:35 -0600 Subject: [PATCH] afs: Avoid using logical OR when setting f_fsid Building with clang-10 produces the warning/error message warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare] for the expression abp->f_fsid = (AFS_VFSMAGIC << 16) || AFS_VFSFSID; The message is because a logical OR '||' is used instead of a bitwise OR '|'. The result of this expression will always set the f_fsid member to a 1 and not the intended value of AFS_VFSMAGIC combined with AFS_VFSFSID. Update the expression to use a bitwise OR instead of the logical OR. Note: This will change value stored in the f_fsid that is returned from statfs. Using a logical OR has existed since OpenAFS 1.0 for hpux/solaris and in UKERNEL since OpenAFS 1.5 with the commit 'UKERNEL: add uafs_statvfs' b822971a. Change-Id: I3e85ba48058ac68e3e3ac7f277623f660187926c Reviewed-on: https://gerrit.openafs.org/14292 Reviewed-by: Andrew Deason Tested-by: BuildBot Reviewed-by: Benjamin Kaduk --- src/afs/HPUX/osi_vfsops.c | 2 +- src/afs/SOLARIS/osi_vfsops.c | 2 +- src/afs/UKERNEL/osi_vfsops.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/afs/HPUX/osi_vfsops.c b/src/afs/HPUX/osi_vfsops.c index 5d53926ba2..6383d5345c 100644 --- a/src/afs/HPUX/osi_vfsops.c +++ b/src/afs/HPUX/osi_vfsops.c @@ -166,7 +166,7 @@ afs_statfs(struct vfs *afsp, struct k_statvfs *abp) */ abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files = abp->f_ffree = abp->f_favail = AFS_VFS_FAKEFREE; - abp->f_fsid = (AFS_VFSMAGIC << 16) || AFS_VFSFSID; + abp->f_fsid = (AFS_VFSMAGIC << 16) | AFS_VFSFSID; AFS_GUNLOCK(); return 0; diff --git a/src/afs/SOLARIS/osi_vfsops.c b/src/afs/SOLARIS/osi_vfsops.c index 71002ec0c5..1f03b8f3d3 100644 --- a/src/afs/SOLARIS/osi_vfsops.c +++ b/src/afs/SOLARIS/osi_vfsops.c @@ -229,7 +229,7 @@ afs_statvfs(struct vfs *afsp, struct statvfs64 *abp) abp->f_bsize = afsp->vfs_bsize; abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files = abp->f_favail = abp->f_ffree = AFS_VFS_FAKEFREE; - abp->f_fsid = (AFS_VFSMAGIC << 16) || AFS_VFSFSID; + abp->f_fsid = (AFS_VFSMAGIC << 16) | AFS_VFSFSID; AFS_GUNLOCK(); return 0; diff --git a/src/afs/UKERNEL/osi_vfsops.c b/src/afs/UKERNEL/osi_vfsops.c index 2dfa201d05..38b1e72ec8 100644 --- a/src/afs/UKERNEL/osi_vfsops.c +++ b/src/afs/UKERNEL/osi_vfsops.c @@ -129,7 +129,7 @@ afs_statvfs(struct vfs *afsp, struct statvfs *abp) abp->f_fsid.val[0] = AFS_VFSMAGIC; abp->f_fsid.val[1] = AFS_VFSFSID; #else - abp->f_fsid = (AFS_VFSMAGIC << 16) || AFS_VFSFSID; + abp->f_fsid = (AFS_VFSMAGIC << 16) | AFS_VFSFSID; #endif return 0;