On Wed, Jun 27, 2018 at 8:02 PM, Qi, Fuli <[email protected]> wrote:
> Thanks for your comments.
>
Thanks for continuing to work through the feedback.
>> > +static struct monitor_dimm *util_dimm_event_filter(struct monitor_dimm
>> > *mdimm,
>> > + const char *__ident)
>> > +{
>> > + char *ident, *save;
>> > + const char *name;
>> > + struct monitor_dimm *__mdimm;
>> > + struct ndctl_ctx *ctx = ndctl_dimm_get_ctx(mdimm->dimm);
>> > +
>> > + __mdimm = calloc(1, sizeof(struct monitor_dimm));
>> > + if (!__mdimm) {
>> > + fail("\n");
>> > + return NULL;
>> > + }
>>
>> Why do we need a dynamic allocation? Can't this just live on the stack?
>>
> Actually, I just use the __dimm to compare current dimm health with the dimm
> health when the monitor started.
> When the dimm changed, the __dimm should be initialized. I think a dynamic
> allocation is smarter than live on the stack.
Allocating memory should always be avoided when not necessary because
it's so error prone in C. None of the other util_X_filter() routines
need to allocate memory, in fact the point is to validate that the
passed in object passes the filter, not to swap the passed in object
with a new one.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm