Skip to content

Commit 03c7b36

Browse files
Adding stuff to avoid malloc
1 parent 5339af5 commit 03c7b36

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/jsd.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,17 +165,17 @@ bool jsd_init(jsd_t* self, const char* ifname, uint8_t enable_autorecovery) {
165165
self->ecx_context.slavelist[0].state = EC_STATE_OPERATIONAL;
166166

167167
ecx_send_overlap_processdata(&self->ecx_context);
168-
uint64_t *bad_wkc_indices;
169-
*bad_wkc_indices = 0;
168+
uint64 bad_wkc_indices_val = 0;
169+
uint64* bad_wkc_indices = &bad_wkc_indices_val;
170170
ecx_receive_processdata(&self->ecx_context, EC_TIMEOUTRET, bad_wkc_indices);
171171

172172
ecx_writestate(&self->ecx_context, 0);
173173

174174
int attempt = 0;
175175
while (true) {
176176
int sent = ecx_send_overlap_processdata(&self->ecx_context);
177-
uint64_t *bad_wkc_indices;
178-
*bad_wkc_indices = 0;
177+
uint64 bad_wkc_indices_val = 0;
178+
uint64* bad_wkc_indices = &bad_wkc_indices_val;
179179
int wkc = ecx_receive_processdata(&self->ecx_context, EC_TIMEOUTRET, bad_wkc_indices);
180180
ec_state actual_state = ecx_statecheck(
181181
&self->ecx_context, 0, EC_STATE_OPERATIONAL, EC_TIMEOUTSTATE);
@@ -234,8 +234,8 @@ void jsd_read(jsd_t* self, int timeout_us) {
234234
assert(self);
235235

236236
// Wait for EtherCat frame to return from slaves, with logic for smart prints
237-
uint64* bad_wkc_indices;
238-
*bad_wkc_indices = 0;
237+
uint64 bad_wkc_indices_val = 0;
238+
uint64* bad_wkc_indices = &bad_wkc_indices_val;
239239
self->wkc = ecx_receive_processdata(&self->ecx_context, timeout_us, bad_wkc_indices);
240240
if (self->wkc != self->expected_wkc && self->last_wkc != self->wkc) {
241241
WARNING("ecx_receive_processdata returning bad wkc: %d (expected: %d)",
@@ -250,7 +250,7 @@ void jsd_read(jsd_t* self, int timeout_us) {
250250
for (slave_idx = 1; slave_idx < num_slaves; slave_idx++) {
251251
ec_slavet* slave = &slaves[slave_idx];
252252
// Go through every bit and see if any device was set to 1 due to bad wkc
253-
bool bad_device_wkc = *bad_wkc_indices & (1 << slave_idx);
253+
bool bad_device_wkc = bad_wkc_indices_val & (1 << slave_idx);
254254
if (bad_device_wkc) {
255255
WARNING("Device (%s) index caused a bad working counter: %d", slave->name, slave_idx);
256256
}

0 commit comments

Comments
 (0)