Skip to content

Commit c02e560

Browse files
committed
Lib: hawkBit: apply clang-format
Apply clang-format in preparation for code changes. Signed-off-by: Glenn Andrews <[email protected]>
1 parent 7d1982e commit c02e560

File tree

1 file changed

+30
-32
lines changed

1 file changed

+30
-32
lines changed

subsys/mgmt/hawkbit/hawkbit.c

+30-32
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,21 @@
3939

4040
LOG_MODULE_REGISTER(hawkbit, CONFIG_HAWKBIT_LOG_LEVEL);
4141

42-
#define RECV_BUFFER_SIZE 640
43-
#define URL_BUFFER_SIZE 300
44-
#define SHA256_HASH_SIZE 32
45-
#define RESPONSE_BUFFER_SIZE 1100
46-
#define DDI_SECURITY_TOKEN_SIZE 32
47-
#define RANGE_HEADER_SIZE 50
48-
#define HAWKBIT_RECV_TIMEOUT (300 * MSEC_PER_SEC)
42+
#define RECV_BUFFER_SIZE 640
43+
#define URL_BUFFER_SIZE 300
44+
#define SHA256_HASH_SIZE 32
45+
#define RESPONSE_BUFFER_SIZE 1100
46+
#define DDI_SECURITY_TOKEN_SIZE 32
47+
#define RANGE_HEADER_SIZE 50
48+
#define HAWKBIT_RECV_TIMEOUT (300 * MSEC_PER_SEC)
4949
#define HAWKBIT_SET_SERVER_TIMEOUT K_MSEC(300)
5050

5151
#define HAWKBIT_JSON_URL "/" CONFIG_HAWKBIT_TENANT "/controller/v1"
5252

5353
#define HTTP_HEADER_CONTENT_TYPE_JSON "application/json;charset=UTF-8"
5454

5555
#define SLOT1_LABEL slot1_partition
56-
#define SLOT1_SIZE FIXED_PARTITION_SIZE(SLOT1_LABEL)
56+
#define SLOT1_SIZE FIXED_PARTITION_SIZE(SLOT1_LABEL)
5757

5858
static uint32_t poll_sleep = (CONFIG_HAWKBIT_POLL_INTERVAL * SEC_PER_MIN);
5959

@@ -90,12 +90,12 @@ static struct hawkbit_config {
9090
} hb_cfg;
9191

9292
#ifdef CONFIG_HAWKBIT_SET_SETTINGS_RUNTIME
93-
#define HAWKBIT_SERVER hb_cfg.server_addr
94-
#define HAWKBIT_PORT hb_cfg.server_port
93+
#define HAWKBIT_SERVER hb_cfg.server_addr
94+
#define HAWKBIT_PORT hb_cfg.server_port
9595
#define HAWKBIT_PORT_INT atoi(hb_cfg.server_port)
9696
#else
97-
#define HAWKBIT_SERVER CONFIG_HAWKBIT_SERVER
98-
#define HAWKBIT_PORT STRINGIFY(CONFIG_HAWKBIT_PORT)
97+
#define HAWKBIT_SERVER CONFIG_HAWKBIT_SERVER
98+
#define HAWKBIT_PORT STRINGIFY(CONFIG_HAWKBIT_PORT)
9999
#define HAWKBIT_PORT_INT CONFIG_HAWKBIT_PORT
100100
#endif /* CONFIG_HAWKBIT_SET_SETTINGS_RUNTIME */
101101

@@ -161,7 +161,7 @@ enum hawkbit_state {
161161
};
162162

163163
int hawkbit_default_config_data_cb(const char *device_id, uint8_t *buffer,
164-
const size_t buffer_size);
164+
const size_t buffer_size);
165165

166166
static hawkbit_config_device_data_cb_handler_t hawkbit_config_device_data_cb_handler =
167167
hawkbit_default_config_data_cb;
@@ -626,8 +626,7 @@ static char *hawkbit_get_url(const char *href)
626626
/*
627627
* Find URL component for the device cancel action id
628628
*/
629-
static int hawkbit_find_cancel_action_id(struct hawkbit_ctl_res *res,
630-
int32_t *cancel_action_id)
629+
static int hawkbit_find_cancel_action_id(struct hawkbit_ctl_res *res, int32_t *cancel_action_id)
631630
{
632631
char *helper;
633632

@@ -885,12 +884,10 @@ static void response_json_cb(struct http_response *rsp, enum http_final_call fin
885884
body_data = rsp->body_frag_start;
886885
body_len = rsp->body_frag_len;
887886

888-
if ((hb_context->dl.downloaded_size + body_len) >
889-
hb_context->response_data_size) {
890-
hb_context->response_data_size =
891-
hb_context->dl.downloaded_size + body_len;
887+
if ((hb_context->dl.downloaded_size + body_len) > hb_context->response_data_size) {
888+
hb_context->response_data_size = hb_context->dl.downloaded_size + body_len;
892889
rsp_tmp = k_realloc(hb_context->response_data,
893-
hb_context->response_data_size);
890+
hb_context->response_data_size);
894891
if (rsp_tmp == NULL) {
895892
LOG_ERR("Failed to realloc memory");
896893
hb_context->code_status = HAWKBIT_ALLOC_ERROR;
@@ -899,36 +896,35 @@ static void response_json_cb(struct http_response *rsp, enum http_final_call fin
899896

900897
hb_context->response_data = rsp_tmp;
901898
}
902-
strncpy(hb_context->response_data + hb_context->dl.downloaded_size,
903-
body_data, body_len);
899+
strncpy(hb_context->response_data + hb_context->dl.downloaded_size, body_data,
900+
body_len);
904901
hb_context->dl.downloaded_size += body_len;
905902
}
906903

907904
if (final_data == HTTP_DATA_FINAL) {
908905
if (hb_context->dl.http_content_size != hb_context->dl.downloaded_size) {
909906
LOG_ERR("HTTP response len mismatch, expected %d, got %d",
910-
hb_context->dl.http_content_size,
911-
hb_context->dl.downloaded_size);
907+
hb_context->dl.http_content_size, hb_context->dl.downloaded_size);
912908
hb_context->code_status = HAWKBIT_METADATA_ERROR;
913909
return;
914910
}
915911

916912
hb_context->response_data[hb_context->dl.downloaded_size] = '\0';
917913
memset(&hb_context->results, 0, sizeof(hb_context->results));
918914
if (hb_context->type == HAWKBIT_PROBE) {
919-
ret = json_obj_parse(
920-
hb_context->response_data, hb_context->dl.downloaded_size,
921-
json_ctl_res_descr, ARRAY_SIZE(json_ctl_res_descr),
922-
&hb_context->results.base);
915+
ret = json_obj_parse(hb_context->response_data,
916+
hb_context->dl.downloaded_size, json_ctl_res_descr,
917+
ARRAY_SIZE(json_ctl_res_descr),
918+
&hb_context->results.base);
923919
if (ret < 0) {
924920
LOG_ERR("JSON parse error (%s): %d", "HAWKBIT_PROBE", ret);
925921
hb_context->code_status = HAWKBIT_METADATA_ERROR;
926922
}
927923
} else {
928-
ret = json_obj_parse(
929-
hb_context->response_data, hb_context->dl.downloaded_size,
930-
json_dep_res_descr, ARRAY_SIZE(json_dep_res_descr),
931-
&hb_context->results.dep);
924+
ret = json_obj_parse(hb_context->response_data,
925+
hb_context->dl.downloaded_size, json_dep_res_descr,
926+
ARRAY_SIZE(json_dep_res_descr),
927+
&hb_context->results.dep);
932928
if (ret < 0) {
933929
LOG_ERR("JSON parse error (%s): %d", "deploymentBase", ret);
934930
hb_context->code_status = HAWKBIT_METADATA_ERROR;
@@ -1605,6 +1601,7 @@ static void s_terminate(void *o)
16051601
smf_set_terminate(SMF_CTX(s), s->hb_context.code_status);
16061602
}
16071603

1604+
/* clang-format off */
16081605
static const struct smf_state hawkbit_states[] = {
16091606
[S_HAWKBIT_START] = SMF_CREATE_STATE(
16101607
s_start,
@@ -1661,6 +1658,7 @@ static const struct smf_state hawkbit_states[] = {
16611658
NULL,
16621659
NULL),
16631660
};
1661+
/* clang-format on */
16641662

16651663
enum hawkbit_response hawkbit_probe(void)
16661664
{

0 commit comments

Comments
 (0)