diff mbox series

ceph: initialize i_size variable in ceph_sync_read

Message ID 20211123123439.70644-1-jlayton@kernel.org (mailing list archive)
State New, archived
Headers show
Series ceph: initialize i_size variable in ceph_sync_read | expand

Commit Message

Jeff Layton Nov. 23, 2021, 12:34 p.m. UTC
Newer compilers seem to determine that this variable being uninitialized
isn't a problem, but older compilers (from the RHEL8 era) seem to choke
on it and complain that it could be used uninitialized.

Go ahead and initialize the variable at declaration time to silence
potential compiler warnings.

Fixes: c3d8e0b5de48 ("ceph: return the real size read when it hits EOF")
Cc: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ceph/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Xiubo Li Nov. 23, 2021, 12:39 p.m. UTC | #1
On 11/23/21 8:34 PM, Jeff Layton wrote:
> Newer compilers seem to determine that this variable being uninitialized
> isn't a problem, but older compilers (from the RHEL8 era) seem to choke
> on it and complain that it could be used uninitialized.
>
> Go ahead and initialize the variable at declaration time to silence
> potential compiler warnings.
>
> Fixes: c3d8e0b5de48 ("ceph: return the real size read when it hits EOF")
> Cc: Xiubo Li <xiubli@redhat.com>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>   fs/ceph/file.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ceph/file.c b/fs/ceph/file.c
> index 220a41831b46..69ea42392f51 100644
> --- a/fs/ceph/file.c
> +++ b/fs/ceph/file.c
> @@ -847,7 +847,7 @@ static ssize_t ceph_sync_read(struct kiocb *iocb, struct iov_iter *to,
>   	ssize_t ret;
>   	u64 off = iocb->ki_pos;
>   	u64 len = iov_iter_count(to);
> -	u64 i_size;
> +	u64 i_size = i_size_read(inode);
>   
>   	dout("sync_read on file %p %llu~%u %s\n", file, off, (unsigned)len,
>   	     (file->f_flags & O_DIRECT) ? "O_DIRECT" : "");

LGTM.

Reviewed-by: Xiubo Li <xiubli@redhat.com>
diff mbox series

Patch

diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 220a41831b46..69ea42392f51 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -847,7 +847,7 @@  static ssize_t ceph_sync_read(struct kiocb *iocb, struct iov_iter *to,
 	ssize_t ret;
 	u64 off = iocb->ki_pos;
 	u64 len = iov_iter_count(to);
-	u64 i_size;
+	u64 i_size = i_size_read(inode);
 
 	dout("sync_read on file %p %llu~%u %s\n", file, off, (unsigned)len,
 	     (file->f_flags & O_DIRECT) ? "O_DIRECT" : "");