Skip to contentSkip to conversation

ceph: initialize i_size variable in ceph_sync_read

PATCH In review Jeff Layton 2 participants 2 messages Nov 23, 2021 Ceph client

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: initialize i_size variable in ceph_sync_read

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 <[email protected]>
---
 fs/ceph/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/file.c +1 -1
index 220a41831b46..69ea42392f51 100644
@@ -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" : "");
Signature · 1 line
2.33.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Jeff Layton

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 <[email protected]>
---
  fs/ceph/file.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/file.c +0 -0
index 220a41831b46..69ea42392f51 100644

fs/ceph/file.c static ssize_t ceph_sync_read(struct kiocb *iocb, struct iov_iter *to, · line 853

Quoted 8 lines
fs/ceph/file.c +1 -1
@@ -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.