On Sun, May 15, 2022 at 01:24:13PM -0700, Richard Cochran wrote: > On Tue, Nov 23, 2021 at 02:14:13AM +0200, Vladimir Oltean wrote: > > > diff --git a/ts2phc.h b/ts2phc.h > > new file mode 100644 > > index 000000000000..14cb2b0c21a3 > > --- /dev/null > > +++ b/ts2phc.h > > @@ -0,0 +1,23 @@ > > +/** > > + * @file ts2phc.h > > + * @brief Structure definitions for ts2phc > > + * @note Copyright 2020 Vladimir Oltean <olte...@gmail.com> > > + * @note SPDX-License-Identifier: GPL-2.0+ > > + */ > > +#ifndef HAVE_TS2PHC_H > > +#define HAVE_TS2PHC_H > > + > > +struct ts2phc_sink_array; > > + > > +struct ts2phc_private { > > + struct ts2phc_pps_source *src; > > + STAILQ_HEAD(sink_ifaces_head, ts2phc_pps_sink) sinks; > > + unsigned int n_sinks; > > + struct ts2phc_sink_array *polling_array; > > + struct config *cfg; > > +}; > > + > > +#include "ts2phc_pps_source.h" > > +#include "ts2phc_pps_sink.h" > > It is a bit strange to put the include directives after the struct > definitions. After all, ts2phc_private has a pointer to a > ts2phc_pps_source. Wonder why compiler doesn't complain about missing > forward declaration. > > Anyhow, please put the include directives at the top.
Ok, I will add a forward declaration for struct ts2phc_private in ts2phc_pps_source and ts2phc_pps_sink. > > > +#endif > > > @@ -65,49 +64,55 @@ ts2phc_pps_sink_offset(struct ts2phc_pps_sink *sink, > > struct ts2phc_source_timestamp ts, > > int64_t *offset, uint64_t *local_ts); > > > > -static STAILQ_HEAD(pps_sink_ifaces_head, ts2phc_pps_sink) ts2phc_sinks = > > - STAILQ_HEAD_INITIALIZER(ts2phc_sinks); > > - > > -static unsigned int ts2phc_n_sinks; > > - > > -static int ts2phc_pps_sink_array_create(void) > > +static int ts2phc_pps_sink_array_create(struct ts2phc_private *priv) > > { > > + struct ts2phc_sink_array *polling_array; > > struct ts2phc_pps_sink *sink; > > unsigned int i; > > > > - if (polling_array.sink) { > > - return 0; > > + polling_array = malloc(sizeof(*polling_array)); > > This polling_array is never freed. Please fix it, so that there is no > memory leak on normal program termination. > > (I use valgrind in pre-release testing to make sure no new memory > issues have appeared.) > > Thanks, > Richard Bad patch splitting, sorry. I have free(polling_array) in the next patch "ts2phc: instantiate a full clock structure for every PPS sink". Anyway I've moved it here, will resend after retesting if there are no other comments. _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel