Skip to content

Commit bc3748c

Browse files
tomasixyskartben
authored andcommitted
net: lib: ptp: fix cpp compilation errors
Compilation errors in ptp library when using C++ compiler. First error is due to 'class' keyword being reserved in C++ and 'class' is used as a variable name in ptp library. Second error is due to a flexible array member in a struct is not placed at the end. Signed-off-by: Tomas Choat <[email protected]>
1 parent 7541742 commit bc3748c

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

subsys/net/lib/ptp/btca.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ int ptp_btca_ds_cmp(const struct ptp_dataset *a, const struct ptp_dataset *b)
100100
if (a->priority1 > b->priority1) {
101101
return B_BETTER;
102102
}
103-
if (a->clk_quality.class > b->clk_quality.class) {
103+
if (a->clk_quality.cls > b->clk_quality.cls) {
104104
return B_BETTER;
105105
}
106106
if (a->clk_quality.accuracy > b->clk_quality.accuracy) {
@@ -129,7 +129,7 @@ enum ptp_port_state ptp_btca_state_decision(struct ptp_port *port)
129129
return PTP_PS_LISTENING;
130130
}
131131

132-
if (clk_default->clk_quality.class <= 127) {
132+
if (clk_default->clk_quality.cls <= 127) {
133133
if (ptp_btca_ds_cmp(clk_default, port_best) > 0) {
134134
/* M1 */
135135
return PTP_PS_GRAND_MASTER;

subsys/net/lib/ptp/clock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ const struct ptp_clock *ptp_clock_init(void)
262262
dds->n_ports = 0;
263263
dds->time_receiver_only = IS_ENABLED(CONFIG_PTP_TIME_RECEIVER_ONLY) ? true : false;
264264

265-
dds->clk_quality.class = dds->time_receiver_only ? 255 : 248;
265+
dds->clk_quality.cls = dds->time_receiver_only ? 255 : 248;
266266
dds->clk_quality.accuracy = CONFIG_PTP_CLOCK_ACCURACY;
267267
/* 0xFFFF means that value has not been computed - IEEE 1588-2019 7.6.3.3 */
268268
dds->clk_quality.offset_scaled_log_variance = 0xFFFF;

subsys/net/lib/ptp/ddt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ struct ptp_port_addr {
7979
*/
8080
struct ptp_clk_quality {
8181
/** PTP Clock's class */
82-
uint8_t class;
82+
uint8_t cls;
8383
/** Accuracy of the PTP Clock. */
8484
uint8_t accuracy;
8585
/** Value representing stability of the Local PTP Clock. */

subsys/net/lib/ptp/ds.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ struct ptp_parent_ds {
101101
uint8_t gm_priority1;
102102
/** Value of Grandmaster's priority2 attribute. */
103103
uint8_t gm_priority2;
104-
/** Address of the PTP Port issuing sync messages used to synchronize this PTP Instance. */
105-
struct ptp_port_addr protocol_addr;
106104
/** Flag inticating use of sync_uncertain flag in Announce message. */
107105
bool sync_uncertain;
106+
/** Address of the PTP Port issuing sync messages used to synchronize this PTP Instance. */
107+
struct ptp_port_addr protocol_addr;
108108
};
109109

110110
/**

0 commit comments

Comments
 (0)