Skip to content

Commit 1e1507f

Browse files
nordicjmcarlescufi
authored andcommitted
tests: mgmt: mcumgr: os_mgmt_info: Update callback format
Updates the format of the MCUmgr callback to use the new style. Signed-off-by: Jamie McCrae <[email protected]>
1 parent 3d6035d commit 1e1507f

File tree

1 file changed

+31
-23
lines changed
  • tests/subsys/mgmt/mcumgr/os_mgmt_info/src

1 file changed

+31
-23
lines changed

tests/subsys/mgmt/mcumgr/os_mgmt_info/src/main.c

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -124,36 +124,40 @@ const uint8_t query_all[] = "a";
124124
const uint8_t query_test_cmd[] = "k";
125125

126126
#ifdef CONFIG_MCUMGR_GRP_OS_INFO_CUSTOM_HOOKS
127-
static int32_t os_mgmt_info_custom_os_callback(uint32_t event, int32_t rc, bool *abort_more,
128-
void *data, size_t data_size)
127+
static enum mgmt_cb_return os_mgmt_info_custom_os_callback(uint32_t event,
128+
enum mgmt_cb_return prev_status,
129+
int32_t *rc, uint16_t *group,
130+
bool *abort_more, void *data,
131+
size_t data_size)
129132
{
130133
if (event == MGMT_EVT_OP_OS_MGMT_INFO_CHECK) {
131134
struct os_mgmt_info_check *check_data = (struct os_mgmt_info_check *)data;
132135

133136
*check_data->custom_os_name = true;
134137
} else if (event == MGMT_EVT_OP_OS_MGMT_INFO_APPEND) {
135-
int rc;
138+
int int_rc;
136139
struct os_mgmt_info_append *append_data = (struct os_mgmt_info_append *)data;
137140

138141
if (*append_data->format_bitmask & OS_MGMT_INFO_FORMAT_OPERATING_SYSTEM) {
139-
rc = snprintf(&append_data->output[*append_data->output_length],
140-
(append_data->buffer_size - *append_data->output_length),
141-
"%s%s", (*append_data->prior_output == true ? " " : ""),
142-
CONFIG_CUSTOM_OS_NAME_VALUE);
142+
int_rc = snprintf(&append_data->output[*append_data->output_length],
143+
(append_data->buffer_size - *append_data->output_length),
144+
"%s%s", (*append_data->prior_output == true ? " " : ""),
145+
CONFIG_CUSTOM_OS_NAME_VALUE);
143146

144-
if (rc < 0 ||
145-
rc >= (append_data->buffer_size - *append_data->output_length)) {
147+
if (int_rc < 0 ||
148+
int_rc >= (append_data->buffer_size - *append_data->output_length)) {
146149
*abort_more = true;
147-
return -1;
150+
*rc = -1;
151+
return MGMT_CB_ERROR_RC;
148152
}
149153

150-
*append_data->output_length += (uint16_t)rc;
154+
*append_data->output_length += (uint16_t)int_rc;
151155
*append_data->prior_output = true;
152156
*append_data->format_bitmask &= ~OS_MGMT_INFO_FORMAT_OPERATING_SYSTEM;
153157
}
154158
}
155159

156-
return MGMT_ERR_EOK;
160+
return MGMT_CB_OK;
157161
}
158162

159163
static struct mgmt_callback custom_os_check_callback = {
@@ -166,8 +170,11 @@ static struct mgmt_callback custom_os_append_callback = {
166170
.event_id = MGMT_EVT_OP_OS_MGMT_INFO_APPEND,
167171
};
168172

169-
static int32_t os_mgmt_info_custom_cmd_callback(uint32_t event, int32_t rc, bool *abort_more,
170-
void *data, size_t data_size)
173+
static enum mgmt_cb_return os_mgmt_info_custom_cmd_callback(uint32_t event,
174+
enum mgmt_cb_return prev_status,
175+
int32_t *rc, uint16_t *group,
176+
bool *abort_more, void *data,
177+
size_t data_size)
171178
{
172179
if (event == MGMT_EVT_OP_OS_MGMT_INFO_CHECK) {
173180
struct os_mgmt_info_check *check_data = (struct os_mgmt_info_check *)data;
@@ -182,23 +189,24 @@ static int32_t os_mgmt_info_custom_cmd_callback(uint32_t event, int32_t rc, bool
182189
++i;
183190
}
184191
} else if (event == MGMT_EVT_OP_OS_MGMT_INFO_APPEND) {
185-
int rc;
192+
int int_rc;
186193
struct os_mgmt_info_append *append_data = (struct os_mgmt_info_append *)data;
187194

188195
if (append_data->all_format_specified ||
189196
(*append_data->format_bitmask & QUERY_TEST_CMD_BITMASK)) {
190-
rc = snprintf(&append_data->output[*append_data->output_length],
191-
(append_data->buffer_size - *append_data->output_length),
192-
"%sMagic Output for Test",
193-
(*append_data->prior_output == true ? " " : ""));
197+
int_rc = snprintf(&append_data->output[*append_data->output_length],
198+
(append_data->buffer_size - *append_data->output_length),
199+
"%sMagic Output for Test",
200+
(*append_data->prior_output == true ? " " : ""));
194201

195-
if (rc < 0 ||
196-
rc >= (append_data->buffer_size - *append_data->output_length)) {
202+
if (int_rc < 0 ||
203+
int_rc >= (append_data->buffer_size - *append_data->output_length)) {
197204
*abort_more = true;
198-
return -1;
205+
*rc = -1;
206+
return MGMT_CB_ERROR_RC;
199207
}
200208

201-
*append_data->output_length += (uint16_t)rc;
209+
*append_data->output_length += (uint16_t)int_rc;
202210
*append_data->prior_output = true;
203211
*append_data->format_bitmask &= ~QUERY_TEST_CMD_BITMASK;
204212
}

0 commit comments

Comments
 (0)