Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 223957
b: refs/heads/master
c: 1e7972c
h: refs/heads/master
i:
  223955: b201b2d
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Jan 3, 2011
1 parent 442848d commit 8205bf5
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 25 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: daec78a09de3df5fbfbbd167da0304d49d7fcfe5
refs/heads/master: 1e7972cc5c16e06f258b0278d8c9adfb5aa75c68
6 changes: 3 additions & 3 deletions trunk/tools/perf/util/header.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ int perf_header__write(struct perf_header *self, int fd, bool at_exit)
static int perf_header__getbuffer64(struct perf_header *self,
int fd, void *buf, size_t size)
{
if (do_read(fd, buf, size) <= 0)
if (readn(fd, buf, size) <= 0)
return -1;

if (self->needs_swap)
Expand Down Expand Up @@ -660,7 +660,7 @@ int perf_file_header__read(struct perf_file_header *self,
{
lseek(fd, 0, SEEK_SET);

if (do_read(fd, self, sizeof(*self)) <= 0 ||
if (readn(fd, self, sizeof(*self)) <= 0 ||
memcmp(&self->magic, __perf_magic, sizeof(self->magic)))
return -1;

Expand Down Expand Up @@ -821,7 +821,7 @@ static int perf_file_header__read_pipe(struct perf_pipe_file_header *self,
struct perf_header *ph, int fd,
bool repipe)
{
if (do_read(fd, self, sizeof(*self)) <= 0 ||
if (readn(fd, self, sizeof(*self)) <= 0 ||
memcmp(&self->magic, __perf_magic, sizeof(self->magic)))
return -1;

Expand Down
22 changes: 2 additions & 20 deletions trunk/tools/perf/util/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -838,23 +838,6 @@ static struct thread *perf_session__register_idle_thread(struct perf_session *se
return thread;
}

int do_read(int fd, void *buf, size_t size)
{
void *buf_start = buf;

while (size) {
int ret = read(fd, buf, size);

if (ret <= 0)
return ret;

size -= ret;
buf += ret;
}

return buf - buf_start;
}

#define session_done() (*(volatile int *)(&session_done))
volatile int session_done;

Expand All @@ -872,7 +855,7 @@ static int __perf_session__process_pipe_events(struct perf_session *self,

head = 0;
more:
err = do_read(self->fd, &event, sizeof(struct perf_event_header));
err = readn(self->fd, &event, sizeof(struct perf_event_header));
if (err <= 0) {
if (err == 0)
goto done;
Expand All @@ -892,8 +875,7 @@ static int __perf_session__process_pipe_events(struct perf_session *self,
p += sizeof(struct perf_event_header);

if (size - sizeof(struct perf_event_header)) {
err = do_read(self->fd, p,
size - sizeof(struct perf_event_header));
err = readn(self->fd, p, size - sizeof(struct perf_event_header));
if (err <= 0) {
if (err == 0) {
pr_err("unexpected end of event stream\n");
Expand Down
1 change: 0 additions & 1 deletion trunk/tools/perf/util/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ void mem_bswap_64(void *src, int byte_size);

int perf_session__create_kernel_maps(struct perf_session *self);

int do_read(int fd, void *buf, size_t size);
void perf_session__update_sample_type(struct perf_session *self);
void perf_session__set_sample_id_all(struct perf_session *session, bool value);
void perf_session__set_sample_type(struct perf_session *session, u64 type);
Expand Down
17 changes: 17 additions & 0 deletions trunk/tools/perf/util/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,20 @@ unsigned long convert_unit(unsigned long value, char *unit)

return value;
}

int readn(int fd, void *buf, size_t n)
{
void *buf_start = buf;

while (n) {
int ret = read(fd, buf, n);

if (ret <= 0)
return ret;

n -= ret;
buf += ret;
}

return buf - buf_start;
}
1 change: 1 addition & 0 deletions trunk/tools/perf/util/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ void argv_free(char **argv);
bool strglobmatch(const char *str, const char *pat);
bool strlazymatch(const char *str, const char *pat);
unsigned long convert_unit(unsigned long value, char *unit);
int readn(int fd, void *buf, size_t size);

#define _STR(x) #x
#define STR(x) _STR(x)
Expand Down

0 comments on commit 8205bf5

Please sign in to comment.