]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
recordmcount: Remove uread()
authorMatt Helsley <mhelsley@vmware.com>
Wed, 24 Jul 2019 21:04:56 +0000 (14:04 -0700)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Sat, 31 Aug 2019 16:19:38 +0000 (12:19 -0400)
uread() is only used to initialize the ELF file's pseudo
private-memory mapping while uwrite() and ulseek() work within
the pseudo-mapping and extend it as necessary.  Thus it is not
a complementary function to uwrite() and ulseek(). It also makes
no sense to do cleanups inside uread() when its only caller,
mmap_file(), is doing the relevant allocations and associated
initializations.

Therefore it's clearer to use a plain read() call to initialize the
data in mmap_file() and remove uread().

Link: http://lkml.kernel.org/r/31a87c22b19150cec1c8dc800c8b0873a2741703.1563992889.git.mhelsley@vmware.com
Signed-off-by: Matt Helsley <mhelsley@vmware.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
scripts/recordmcount.c

index ebe98c39f3cd5ae9b1e4dd2ccfcd48d93f9e1f37..c0dd4634406361b28b3ffeb2595434b0df745c5b 100644 (file)
@@ -89,7 +89,7 @@ succeed_file(void)
        longjmp(jmpenv, SJ_SUCCEED);
 }
 
-/* ulseek, uread, ...:  Check return value for errors. */
+/* ulseek, uwrite, ...:  Check return value for errors. */
 
 static off_t
 ulseek(int const fd, off_t const offset, int const whence)
@@ -112,17 +112,6 @@ ulseek(int const fd, off_t const offset, int const whence)
        return file_ptr - file_map;
 }
 
-static size_t
-uread(int const fd, void *const buf, size_t const count)
-{
-       size_t const n = read(fd, buf, count);
-       if (n != count) {
-               perror("read");
-               fail_file();
-       }
-       return n;
-}
-
 static size_t
 uwrite(int const fd, void const *const buf, size_t const count)
 {
@@ -298,7 +287,10 @@ static void *mmap_file(char const *fname)
        if (file_map == MAP_FAILED) {
                mmap_failed = 1;
                file_map = umalloc(sb.st_size);
-               uread(fd_map, file_map, sb.st_size);
+               if (read(fd_map, file_map, sb.st_size) != sb.st_size) {
+                       perror(fname);
+                       fail_file();
+               }
        }
        close(fd_map);