On Tue, Jun 02, 2015 at 10:12:06AM -0700, Sukadev Bhattiprolu wrote:

SNIP

> @@ -1033,37 +1064,49 @@ void print_pmu_events(const char *event_glob, bool 
> name_only)
>                                                      event_glob))))
>                               continue;
>  
> -                     if (is_cpu && !name_only)
> +                     if (is_cpu && !name_only && !alias->desc)
>                               name = format_alias_or(buf, sizeof(buf), pmu, 
> alias);
>  
> -                     aliases[j] = strdup(name);
> -                     if (aliases[j] == NULL)
> -                             goto out_enomem;
> +                     aliases[j].name = name;
> +                     if (is_cpu && !name_only && !alias->desc)
> +                             aliases[j].name = format_alias_or(buf, 
> sizeof(buf),
> +                                                               pmu, alias);
> +                     aliases[j].name = strdup(aliases[j].name);
> +                     /* failure harmless */

yea but we still try to care everywhere.. ;-)
we would print "NULL" for name in the code below right?

please keep the above pattern:

                        if (aliases[j].name == NULL)
                                goto out_enomem;



> +                     aliases[j].desc = alias->desc;
>                       j++;
>               }
>               if (pmu->selectable) {
>                       char *s;
>                       if (asprintf(&s, "%s//", pmu->name) < 0)
>                               goto out_enomem;
> -                     aliases[j] = s;
> +                     aliases[j].name = s;
>                       j++;
>               }
>       }
>       len = j;
> -     qsort(aliases, len, sizeof(char *), cmp_string);
> +     qsort(aliases, len, sizeof(struct pair), cmp_pair);
>       for (j = 0; j < len; j++) {
>               if (name_only) {
> -                     printf("%s ", aliases[j]);
> +                     printf("%s ", aliases[j].name);
>                       continue;
>               }
> -             printf("  %-50s [Kernel PMU event]\n", aliases[j]);
> +             if (aliases[j].desc) {
> +                     if (numdesc++ == 0)
> +                             printf("\n");
> +                     printf("  %-50s\n", aliases[j].name);
> +                     printf("%*s", 8, "[");
> +                     wordwrap(aliases[j].desc, 8, columns, 0);
> +                     printf("]\n");
> +             } else
> +                     printf("  %-50s [Kernel PMU event]\n", aliases[j].name);
>               printed++;

SNIP
_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Reply via email to