From: Cheyenne Wills Date: Mon, 27 Jul 2020 18:31:35 +0000 (-0600) Subject: afs: Avoid using logical OR when setting f_fsid X-Git-Tag: openafs-devel-1_9_0~23 X-Git-Url: http://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=c56873bf95f6325b70e63ed56ce59a3c6b2b753b 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 --- diff --git a/src/afs/HPUX/osi_vfsops.c b/src/afs/HPUX/osi_vfsops.c index 5d53926..6383d53 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 71002ec..1f03b8f 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 2dfa201..38b1e72 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;