perf tools: Stop using 'self' in pstack
As suggested by tglx long ago. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-zgcldbjno41jn02b15760k4p@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
f95e0818cb
commit
61e945150f
@ -17,59 +17,59 @@ struct pstack {
|
|||||||
|
|
||||||
struct pstack *pstack__new(unsigned short max_nr_entries)
|
struct pstack *pstack__new(unsigned short max_nr_entries)
|
||||||
{
|
{
|
||||||
struct pstack *self = zalloc((sizeof(*self) +
|
struct pstack *pstack = zalloc((sizeof(*pstack) +
|
||||||
max_nr_entries * sizeof(void *)));
|
max_nr_entries * sizeof(void *)));
|
||||||
if (self != NULL)
|
if (pstack != NULL)
|
||||||
self->max_nr_entries = max_nr_entries;
|
pstack->max_nr_entries = max_nr_entries;
|
||||||
return self;
|
return pstack;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pstack__delete(struct pstack *self)
|
void pstack__delete(struct pstack *pstack)
|
||||||
{
|
{
|
||||||
free(self);
|
free(pstack);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pstack__empty(const struct pstack *self)
|
bool pstack__empty(const struct pstack *pstack)
|
||||||
{
|
{
|
||||||
return self->top == 0;
|
return pstack->top == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pstack__remove(struct pstack *self, void *key)
|
void pstack__remove(struct pstack *pstack, void *key)
|
||||||
{
|
{
|
||||||
unsigned short i = self->top, last_index = self->top - 1;
|
unsigned short i = pstack->top, last_index = pstack->top - 1;
|
||||||
|
|
||||||
while (i-- != 0) {
|
while (i-- != 0) {
|
||||||
if (self->entries[i] == key) {
|
if (pstack->entries[i] == key) {
|
||||||
if (i < last_index)
|
if (i < last_index)
|
||||||
memmove(self->entries + i,
|
memmove(pstack->entries + i,
|
||||||
self->entries + i + 1,
|
pstack->entries + i + 1,
|
||||||
(last_index - i) * sizeof(void *));
|
(last_index - i) * sizeof(void *));
|
||||||
--self->top;
|
--pstack->top;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pr_err("%s: %p not on the pstack!\n", __func__, key);
|
pr_err("%s: %p not on the pstack!\n", __func__, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pstack__push(struct pstack *self, void *key)
|
void pstack__push(struct pstack *pstack, void *key)
|
||||||
{
|
{
|
||||||
if (self->top == self->max_nr_entries) {
|
if (pstack->top == pstack->max_nr_entries) {
|
||||||
pr_err("%s: top=%d, overflow!\n", __func__, self->top);
|
pr_err("%s: top=%d, overflow!\n", __func__, pstack->top);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self->entries[self->top++] = key;
|
pstack->entries[pstack->top++] = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *pstack__pop(struct pstack *self)
|
void *pstack__pop(struct pstack *pstack)
|
||||||
{
|
{
|
||||||
void *ret;
|
void *ret;
|
||||||
|
|
||||||
if (self->top == 0) {
|
if (pstack->top == 0) {
|
||||||
pr_err("%s: underflow!\n", __func__);
|
pr_err("%s: underflow!\n", __func__);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = self->entries[--self->top];
|
ret = pstack->entries[--pstack->top];
|
||||||
self->entries[self->top] = NULL;
|
pstack->entries[pstack->top] = NULL;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user