lkml.org 
[lkml]   [2008]   [Jul]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch 02/17] Kernel Tracepoints


On Tue, 15 Jul 2008, Mathieu Desnoyers wrote:
> +static void *
> +tracepoint_entry_remove_probe(struct tracepoint_entry *entry, void *probe)
> +{
> + int nr_probes = 0, nr_del = 0, i;
> + void **old, **new;
> +
> + old = entry->funcs;
> +
> + debug_print_probes(entry);
> + /* (N -> M), (N > 1, M >= 0) probes */
> + for (nr_probes = 0; old[nr_probes]; nr_probes++) {
> + if ((!probe || old[nr_probes] == probe))
> + nr_del++;
> + }
> +
> + if (nr_probes - nr_del == 0) {
> + /* N -> 0, (N > 1) */
> + entry->funcs = NULL;
> + entry->refcount = 0;
> + debug_print_probes(entry);
> + return old;
> + } else {
> + int j = 0;
> + /* N -> M, (N > 1, M > 0) */
> + /* + 1 for NULL */
> + new = kzalloc((nr_probes - nr_del + 1)
> + * sizeof(void *), GFP_KERNEL);
> + if (new == NULL)
> + return ERR_PTR(-ENOMEM);

Hmm, on failure of allocating a new array, we could simply use the
old array, and remove the one probe from it instead of just failing.

-- Steve

> + for (i = 0; old[i]; i++)
> + if ((probe && old[i] != probe))
> + new[j++] = old[i];
> + entry->refcount = nr_probes - nr_del;
> + entry->funcs = new;
> + }
> + debug_print_probes(entry);
> + return old;
> +}
> +


\
 
 \ /
  Last update: 2008-07-24 17:37    [W:0.218 / U:0.420 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site