[dpdk-dev] [PATCH v6 4/4] log: add option argument help
Thomas Monjalon
thomas at monjalon.net
Tue Apr 6 16:58:20 CEST 2021
06/04/2021 16:28, David Marchand:
> On Tue, Apr 6, 2021 at 3:12 PM Thomas Monjalon <thomas at monjalon.net> wrote:
> > +void
> > +rte_log_list_types(FILE *out, const char *prefix)
> > +{
> > + struct rte_log_dynamic_type *sorted_types;
> > + const size_t type_size = sizeof(rte_logs.dynamic_types[0]);
> > + const size_t type_count = rte_logs.dynamic_types_len;
> > + const size_t total_size = type_size * type_count;
> > + size_t type;
> > +
> > + sorted_types = malloc(total_size);
> > + if (sorted_types == NULL) {
> > + /* no sorting - unlikely */
> > + sorted_types = rte_logs.dynamic_types;
> > + } else {
> > + memcpy(sorted_types, rte_logs.dynamic_types, total_size);
> > + qsort(sorted_types, type_count, type_size, log_type_compare);
> > + }
> > +
> > + for (type = 0; type < type_count; ++type) {
> > + if (sorted_types[type].name == NULL)
> > + continue;
> > + fprintf(out, "%s%s\n", prefix, sorted_types[type].name);
> > + }
>
> Missing something like:
>
> if (sorted_types != rte_logs.dynamic_types)
> free(sorted_types);
No, what is missing really is coffee, but I don't drink some ;)
Thank you for the good review.
More information about the dev
mailing list