Skip to content

Commit

Permalink
Fix misra violations (#390)
Browse files Browse the repository at this point in the history
* chore: run clang format

* fix: misra issues
  • Loading branch information
jean-roland authored Mar 27, 2024
1 parent ecb919a commit 27b9189
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
28 changes: 15 additions & 13 deletions src/api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,11 +613,11 @@ OWNED_FUNCTIONS_PTR_CLONE(z_publisher_t, z_owned_publisher_t, publisher, _z_owne
void z_publisher_drop(z_owned_publisher_t *val) { z_undeclare_publisher(val); }

z_put_options_t z_put_options_default(void) {
return (z_put_options_t){.encoding = z_encoding_default(),
.congestion_control = Z_CONGESTION_CONTROL_DEFAULT,
.priority = Z_PRIORITY_DEFAULT,
return (z_put_options_t) {
.encoding = z_encoding_default(), .congestion_control = Z_CONGESTION_CONTROL_DEFAULT,
.priority = Z_PRIORITY_DEFAULT,
#if Z_FEATURE_ATTACHMENT == 1
.attachment = z_attachment_null()
.attachment = z_attachment_null()
#endif
};
}
Expand Down Expand Up @@ -715,9 +715,10 @@ int8_t z_undeclare_publisher(z_owned_publisher_t *pub) {
}

z_publisher_put_options_t z_publisher_put_options_default(void) {
return (z_publisher_put_options_t){.encoding = z_encoding_default(),
return (z_publisher_put_options_t) {
.encoding = z_encoding_default(),
#if Z_FEATURE_ATTACHMENT == 1
.attachment = z_attachment_null()
.attachment = z_attachment_null()
#endif
};
}
Expand Down Expand Up @@ -781,13 +782,14 @@ z_owned_keyexpr_t z_publisher_keyexpr(z_publisher_t publisher) {
OWNED_FUNCTIONS_PTR_INTERNAL(z_reply_t, z_owned_reply_t, reply, _z_reply_free, _z_owner_noop_copy)

z_get_options_t z_get_options_default(void) {
return (z_get_options_t){.target = z_query_target_default(),
.consolidation = z_query_consolidation_default(),
.value = {.encoding = z_encoding_default(), .payload = _z_bytes_empty()},
return (z_get_options_t) {
.target = z_query_target_default(), .consolidation = z_query_consolidation_default(),
.value = {.encoding = z_encoding_default(), .payload = _z_bytes_empty()},
#if Z_FEATURE_ATTACHMENT == 1
// TODO:ATT.attachment = z_attachment_null()
// TODO:ATT.attachment = z_attachment_null()
#endif
.timeout_ms = Z_GET_TIMEOUT_DEFAULT};
.timeout_ms = Z_GET_TIMEOUT_DEFAULT
};
}

typedef struct __z_reply_handler_wrapper_t {
Expand Down Expand Up @@ -1088,7 +1090,7 @@ z_owned_keyexpr_t z_subscriber_keyexpr(z_subscriber_t sub) {

/**************** Tasks ****************/
zp_task_read_options_t zp_task_read_options_default(void) {
return (zp_task_read_options_t){
return (zp_task_read_options_t) {
#if Z_FEATURE_MULTI_THREAD == 1
.task_attributes = NULL
#else
Expand Down Expand Up @@ -1121,7 +1123,7 @@ int8_t zp_stop_read_task(z_session_t zs) {
}

zp_task_lease_options_t zp_task_lease_options_default(void) {
return (zp_task_lease_options_t){
return (zp_task_lease_options_t) {
#if Z_FEATURE_MULTI_THREAD == 1
.task_attributes = NULL
#else
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/definitions/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ _z_msg_query_reqexts_t _z_msg_query_required_extensions(const _z_msg_query_t *ms
#if Z_FEATURE_ATTACHMENT == 1
z_attachment_t att = _z_encoded_as_attachment(&msg->_ext_attachment);
#endif
return (_z_msg_query_reqexts_t){
return (_z_msg_query_reqexts_t) {
.body = msg->_ext_value.payload.start != NULL || msg->_ext_value.encoding.prefix != 0 ||
!_z_bytes_is_empty(&msg->_ext_value.encoding.suffix),
.info = _z_id_check(msg->_ext_info._id) || msg->_ext_info._entity_id != 0 || msg->_ext_info._source_sn != 0,
Expand Down
7 changes: 4 additions & 3 deletions src/system/espidf/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,17 @@ static z_task_attr_t z_default_task_attr = {
};

/*------------------ Thread ------------------*/
int8_t z_task_init(z_task_t *task, z_task_attr_t *attr, void *(*fun)(void *), void *arg) {
int8_t z_task_init(z_task_t *task, z_task_attr_t *arg_attr, void *(*fun)(void *), void *arg) {
z_task_attr_t *attr = arg_attr;
z_task_arg *z_arg = (z_task_arg *)z_malloc(sizeof(z_task_arg));
if (z_arg == NULL) {
return -1;
}

z_arg->fun = fun;
z_arg->arg = arg;
z_arg->join_event = task->join_event = xEventGroupCreate();
task->join_event = xEventGroupCreate();
z_arg->join_event = task->join_event;

if (attr == NULL) {
attr = &z_default_task_attr;
Expand Down Expand Up @@ -154,7 +156,6 @@ int z_sleep_ms(size_t time) {
// This may compound, so this approach may make sleeps longer than expected.
// This extra check tries to minimize the amount of extra time it might sleep.
while (z_time_elapsed_ms(&start) < time) {
// z_sleep_us(1000);
vTaskDelay(1 / portTICK_PERIOD_MS);
}

Expand Down

0 comments on commit 27b9189

Please sign in to comment.