perf tools: Clean up O_LARGEFILE et al usage

Setting _FILE_OFFSET_BITS and using O_LARGEFILE, lseek64, etc,
is redundant. Thanks H. Peter Anvin for pointing it out.

So, this patch removes O_LARGEFILE, lseek64, etc.

Suggested-by: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
LKML-Reference: <4B6A8972.3070605@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
Xiao Guangrong
2010-02-04 16:46:42 +08:00
committed by Ingo Molnar
parent 447a194b39
commit f887f3019e
4 changed files with 22 additions and 25 deletions

View File

@@ -18,7 +18,7 @@
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
#define _LARGEFILE64_SOURCE
#define _FILE_OFFSET_BITS 64
#include <dirent.h>
#include <stdio.h>
@@ -83,7 +83,7 @@ static char *read_string(void)
char *str = NULL;
int size = 0;
int i;
s64 r;
off_t r;
for (;;) {
r = read(input_fd, buf, BUFSIZ);
@@ -117,8 +117,8 @@ static char *read_string(void)
i++;
/* move the file descriptor to the end of the string */
r = lseek64(input_fd, -(r - i), SEEK_CUR);
if (r < 0)
r = lseek(input_fd, -(r - i), SEEK_CUR);
if (r == (off_t)-1)
die("lseek");
if (str) {
@@ -282,8 +282,8 @@ static void update_cpu_data_index(int cpu)
static void get_next_page(int cpu)
{
off64_t save_seek;
off64_t ret;
off_t save_seek;
off_t ret;
if (!cpu_data[cpu].page)
return;
@@ -298,17 +298,17 @@ static void get_next_page(int cpu)
update_cpu_data_index(cpu);
/* other parts of the code may expect the pointer to not move */
save_seek = lseek64(input_fd, 0, SEEK_CUR);
save_seek = lseek(input_fd, 0, SEEK_CUR);
ret = lseek64(input_fd, cpu_data[cpu].offset, SEEK_SET);
if (ret < 0)
ret = lseek(input_fd, cpu_data[cpu].offset, SEEK_SET);
if (ret == (off_t)-1)
die("failed to lseek");
ret = read(input_fd, cpu_data[cpu].page, page_size);
if (ret < 0)
die("failed to read page");
/* reset the file pointer back */
lseek64(input_fd, save_seek, SEEK_SET);
lseek(input_fd, save_seek, SEEK_SET);
return;
}