From: Srikar Dronamraju on 12 Jul 2010 12:10 > > What if strlist__new() fails? > Okay will add a check. > > Humm, here I think perhaps we should try to do as the kernel and > introduce some form of: > > map_groups__for_each_map(self, pos) > > Like we have for list_for_each_entry, strlist__for_each, for_each_lang, > for_each_script, etc. > > Matter of coding style, following the culture of the kernel is a goal > for these tools, to encourage kernel hackers to contribute to these > tools. Okay. > > > Also here please follow the style of the other routines that print > entries, i.e.: > > size_t dso__fprintf_symbols(self, type, fp) > > like this: > > diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c > index 971d0a0..85fe580 100644 > --- a/tools/perf/util/symbol.c > +++ b/tools/perf/util/symbol.c > @@ -370,9 +370,21 @@ size_t dso__fprintf_buildid(struct dso *self, FILE *fp) > return fprintf(fp, "%s", sbuild_id); > } > > -size_t dso__fprintf(struct dso *self, enum map_type type, FILE *fp) > +size_t dso__fprintf_symbols(struct dso *self, enum map_type type, FILE *fp) > { > + size_t ret = 0; > struct rb_node *nd; > + > + for (nd = rb_first(&self->symbols[type]); nd; nd = rb_next(nd)) { > + struct symbol *pos = rb_entry(nd, struct symbol, rb_node); > + ret += symbol__fprintf(pos, fp); > + } > + > + return ret; > +} > + > +size_t dso__fprintf(struct dso *self, enum map_type type, FILE *fp) > +{ > size_t ret = fprintf(fp, "dso: %s (", self->short_name); > > if (self->short_name != self->long_name) > @@ -381,12 +393,8 @@ size_t dso__fprintf(struct dso *self, enum map_type type, FILE *fp) > self->loaded ? "" : "NOT "); > ret += dso__fprintf_buildid(self, fp); > ret += fprintf(fp, ")\n"); > - for (nd = rb_first(&self->symbols[type]); nd; nd = rb_next(nd)) { > - struct symbol *pos = rb_entry(nd, struct symbol, rb_node); > - ret += symbol__fprintf(pos, fp); > - } > > - return ret; > + return ret + dso__fprintf_symbols(self, type, fp); > } > > int kallsyms__parse(const char *filename, void *arg, > diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h > index 261a3e3..714d286 100644 > --- a/tools/perf/util/symbol.h > +++ b/tools/perf/util/symbol.h > @@ -177,6 +177,7 @@ size_t machines__fprintf_dsos(struct rb_root *self, FILE *fp); > size_t machines__fprintf_dsos_buildid(struct rb_root *self, FILE *fp, bool with_hits); > > size_t dso__fprintf_buildid(struct dso *self, FILE *fp); > +size_t dso__fprintf_symbols(struct dso *self, enum map_type type, FILE *fp); > size_t dso__fprintf(struct dso *self, enum map_type type, FILE *fp); > > enum dso_origin { > > ------------------------------------ > > This way we reduce the resulting code size while following the existing > style. Okay. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|
Pages: 1 Prev: trivial: fix typos concerning "empty" Next: Staging: line6: fix leaks in line6_probe() |