Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

generic_file_aio_read() cleanups

As akpm points out, there's really no need for generic_file_aio_read to
make a special case of count 0: just loop through nr_segs doing nothing.
And as Harvey Harrison points out, there's no need to reset retval to 0
where it's already 0.

Setting count (or ocount) to 0 before calling generic_segment_checks is
unnecessary too; but reluctantly I'll leave that removal to someone with a
wider range of gcc versions to hand - 4.1.2 and 4.2.1 don't warn about it,
but perhaps others do - I forget which are the warniest versions.

Signed-off-by: Hugh Dickins <hugh@veritas.com>
Tested-by: Lawrence Greenfield <leg@google.com>
Cc: Christoph Rohland <hans-christoph.rohland@sap.com>
Cc: Badari Pulavarty <pbadari@us.ibm.com>
Cc: Zach Brown <zach.brown@oracle.com>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Hugh Dickins and committed by
Linus Torvalds
11fa977e a858f7b2

+19 -23
+19 -23
mm/filemap.c
··· 1197 1197 1198 1198 mapping = filp->f_mapping; 1199 1199 inode = mapping->host; 1200 - retval = 0; 1201 1200 if (!count) 1202 1201 goto out; /* skip atime */ 1203 1202 size = i_size_read(inode); ··· 1208 1209 } 1209 1210 if (retval > 0) 1210 1211 *ppos = pos + retval; 1211 - } 1212 - if (likely(retval != 0)) { 1213 - file_accessed(filp); 1214 - goto out; 1212 + if (retval) { 1213 + file_accessed(filp); 1214 + goto out; 1215 + } 1215 1216 } 1216 1217 } 1217 1218 1218 - retval = 0; 1219 - if (count) { 1220 - for (seg = 0; seg < nr_segs; seg++) { 1221 - read_descriptor_t desc; 1219 + for (seg = 0; seg < nr_segs; seg++) { 1220 + read_descriptor_t desc; 1222 1221 1223 - desc.written = 0; 1224 - desc.arg.buf = iov[seg].iov_base; 1225 - desc.count = iov[seg].iov_len; 1226 - if (desc.count == 0) 1227 - continue; 1228 - desc.error = 0; 1229 - do_generic_file_read(filp,ppos,&desc,file_read_actor); 1230 - retval += desc.written; 1231 - if (desc.error) { 1232 - retval = retval ?: desc.error; 1233 - break; 1234 - } 1235 - if (desc.count > 0) 1236 - break; 1222 + desc.written = 0; 1223 + desc.arg.buf = iov[seg].iov_base; 1224 + desc.count = iov[seg].iov_len; 1225 + if (desc.count == 0) 1226 + continue; 1227 + desc.error = 0; 1228 + do_generic_file_read(filp, ppos, &desc, file_read_actor); 1229 + retval += desc.written; 1230 + if (desc.error) { 1231 + retval = retval ?: desc.error; 1232 + break; 1237 1233 } 1234 + if (desc.count > 0) 1235 + break; 1238 1236 } 1239 1237 out: 1240 1238 return retval;