From 6d72bf4598c04b01df5dbf43333b197005734303 Mon Sep 17 00:00:00 2001 From: Daniel Adam Date: Wed, 11 Oct 2023 09:05:14 +0200 Subject: [PATCH] Don't mix up coap_status_t and oc_status_t enum values --- api/oc_collection.c | 47 +++++++++++++------------ api/oc_ri.c | 68 +++++++++++++++++++++++------------- api/oc_ri_internal.h | 5 ++- api/oc_server_api.c | 33 ++++++++++++----- api/oc_server_api_internal.h | 6 ++-- messaging/coap/constants.h | 2 +- messaging/coap/observe.c | 6 ++-- messaging/coap/oscore.c | 5 +-- util/oc_crc.c | 7 +++- util/oc_crc_internal.h | 7 ++-- 10 files changed, 117 insertions(+), 69 deletions(-) diff --git a/api/oc_collection.c b/api/oc_collection.c index 479b42d384..dac4b27b84 100644 --- a/api/oc_collection.c +++ b/api/oc_collection.c @@ -625,8 +625,8 @@ oc_get_next_collection_with_link(const oc_resource_t *resource, typedef struct oc_handle_collection_request_result_t { bool ok; - int ecode; - int pcode; + coap_status_t ecode; + coap_status_t pcode; } oc_handle_collection_request_result_t; static bool @@ -752,8 +752,8 @@ static oc_handle_collection_request_result_t oc_handle_collection_baseline_request(oc_method_t method, oc_request_t *request) { oc_collection_t *collection = (oc_collection_t *)request->resource; - int ecode = oc_status_code(OC_STATUS_OK); - int pcode = oc_status_code(OC_STATUS_BAD_REQUEST); + coap_status_t ecode = oc_status_code_unsafe(OC_STATUS_OK); + coap_status_t pcode = oc_status_code_unsafe(OC_STATUS_BAD_REQUEST); if (method == OC_PUT || method == OC_POST) { if (collection->res.set_properties.cb.set_props == NULL) { OC_ERR("internal collection error: set properties callback not set"); @@ -791,7 +791,7 @@ oc_handle_collection_baseline_request(oc_method_t method, oc_request_t *request) collection->res.get_properties.user_data); } oc_rep_end_root_object(); - pcode = ecode = oc_status_code(OC_STATUS_OK); + pcode = ecode = oc_status_code_unsafe(OC_STATUS_OK); } oc_handle_collection_request_result_t result = { @@ -894,8 +894,8 @@ oc_handle_collection_batch_request(oc_method_t method, oc_request_t *request, const oc_resource_t *notify_resource) { assert(request != NULL); - int ecode = oc_status_code(OC_STATUS_OK); - int pcode = oc_status_code(OC_STATUS_BAD_REQUEST); + coap_status_t ecode = oc_status_code_unsafe(OC_STATUS_OK); + coap_status_t pcode = oc_status_code_unsafe(OC_STATUS_BAD_REQUEST); CborEncoder encoder; CborEncoder prev_link; oc_request_t rest_request; @@ -945,7 +945,7 @@ oc_handle_collection_batch_request(oc_method_t method, oc_request_t *request, pay = pay->next; } if (href == NULL || oc_string_len(*href) == 0) { - ecode = oc_status_code(OC_STATUS_BAD_REQUEST); + ecode = oc_status_code_unsafe(OC_STATUS_BAD_REQUEST); goto processed_request; } process_request: @@ -980,7 +980,7 @@ oc_handle_collection_batch_request(oc_method_t method, oc_request_t *request, #ifdef OC_SECURITY if (request->origin != NULL && !oc_sec_check_acl(method, link->resource, request->origin)) { - response_buffer.code = oc_status_code(OC_STATUS_FORBIDDEN); + response_buffer.code = oc_status_code_unsafe(OC_STATUS_FORBIDDEN); } else #endif /* OC_SECURITY */ { @@ -992,8 +992,8 @@ oc_handle_collection_batch_request(oc_method_t method, oc_request_t *request, NULL)) { oc_handle_collection_request_result_t res = { .ok = false, - .ecode = oc_status_code(OC_STATUS_OK), - .pcode = oc_status_code(OC_STATUS_BAD_REQUEST), + .ecode = oc_status_code_unsafe(OC_STATUS_OK), + .pcode = oc_status_code_unsafe(OC_STATUS_BAD_REQUEST), }; return res; } @@ -1043,16 +1043,16 @@ oc_handle_collection_batch_request(oc_method_t method, oc_request_t *request, } } if (method_not_found) { - ecode = oc_status_code(OC_STATUS_METHOD_NOT_ALLOWED); + ecode = oc_status_code_unsafe(OC_STATUS_METHOD_NOT_ALLOWED); memcpy(&links_array, &prev_link, sizeof(CborEncoder)); goto next; } else { if ((method == OC_PUT || method == OC_POST) && response_buffer.code < - oc_status_code(OC_STATUS_BAD_REQUEST)) { + oc_status_code_unsafe(OC_STATUS_BAD_REQUEST)) { } if (response_buffer.code < - oc_status_code(OC_STATUS_BAD_REQUEST)) { + oc_status_code_unsafe(OC_STATUS_BAD_REQUEST)) { pcode = response_buffer.code; } else { ecode = response_buffer.code; @@ -1076,7 +1076,7 @@ oc_handle_collection_batch_request(oc_method_t method, oc_request_t *request, } } break; default: - ecode = oc_status_code(OC_STATUS_BAD_REQUEST); + ecode = oc_status_code_unsafe(OC_STATUS_BAD_REQUEST); goto processed_request; } rep = rep->next; @@ -1098,15 +1098,15 @@ oc_handle_collection_request(oc_method_t method, oc_request_t *request, oc_interface_mask_t iface_mask, const oc_resource_t *notify_resource) { - int ecode = oc_status_code(OC_STATUS_OK); - int pcode = oc_status_code(OC_STATUS_BAD_REQUEST); + coap_status_t ecode = oc_status_code_unsafe(OC_STATUS_OK); + coap_status_t pcode = oc_status_code_unsafe(OC_STATUS_BAD_REQUEST); switch (iface_mask) { #ifdef OC_COLLECTIONS_IF_CREATE case OC_IF_CREATE: if (oc_handle_collection_create_request(method, request)) { - pcode = ecode = oc_status_code(OC_STATUS_OK); + pcode = ecode = oc_status_code_unsafe(OC_STATUS_OK); } else { - pcode = ecode = oc_status_code(OC_STATUS_BAD_REQUEST); + pcode = ecode = oc_status_code_unsafe(OC_STATUS_BAD_REQUEST); } break; #endif /* OC_COLLECTIONS_IF_CREATE */ @@ -1122,7 +1122,7 @@ oc_handle_collection_request(oc_method_t method, oc_request_t *request, } case OC_IF_LL: oc_handle_collection_linked_list_request(request); - pcode = ecode = oc_status_code(OC_STATUS_OK); + pcode = ecode = oc_status_code_unsafe(OC_STATUS_OK); break; case OC_IF_B: { oc_handle_collection_request_result_t res = @@ -1149,8 +1149,8 @@ oc_handle_collection_request(oc_method_t method, oc_request_t *request, } oc_status_t code = OC_STATUS_BAD_REQUEST; - if (ecode < oc_status_code(OC_STATUS_BAD_REQUEST) && - pcode < oc_status_code(OC_STATUS_BAD_REQUEST)) { + if (ecode < oc_status_code_unsafe(OC_STATUS_BAD_REQUEST) && + pcode < oc_status_code_unsafe(OC_STATUS_BAD_REQUEST)) { switch (method) { case OC_GET: code = OC_STATUS_OK; @@ -1173,8 +1173,9 @@ oc_handle_collection_request(oc_method_t method, oc_request_t *request, oc_send_response_internal(request, code, APPLICATION_VND_OCF_CBOR, size, true); + coap_status_t status_code = oc_status_code_unsafe(code); if ((method == OC_PUT || method == OC_POST) && - oc_status_code(code) < oc_status_code(OC_STATUS_BAD_REQUEST)) { + status_code < oc_status_code_unsafe(OC_STATUS_BAD_REQUEST)) { if (iface_mask == OC_IF_CREATE) { coap_notify_collection_observers( collection, request->response->response_buffer, iface_mask); diff --git a/api/oc_ri.c b/api/oc_ri.c index 9290e592ad..230da0274a 100644 --- a/api/oc_ri.c +++ b/api/oc_ri.c @@ -22,6 +22,7 @@ #include "api/oc_network_events_internal.h" #include "api/oc_rep_encode_internal.h" #include "api/oc_rep_decode_internal.h" +#include "api/oc_ri_internal.h" #include "messaging/coap/coap_internal.h" #include "messaging/coap/coap_options.h" #include "messaging/coap/constants.h" @@ -119,7 +120,7 @@ OC_MEMB(g_resource_default_s, oc_resource_defaults_data_t, OC_MAX_APP_RESOURCES); #endif /* OC_SERVER */ -static unsigned int oc_coap_status_codes[__NUM_OC_STATUS_CODES__]; +static coap_status_t oc_coap_status_codes[__NUM_OC_STATUS_CODES__] = { 0 }; static const char *oc_status_strs[] = { "OC_STATUS_OK", /* 0 */ @@ -145,7 +146,7 @@ static const char *oc_status_strs[] = { }; static void -set_mpro_status_codes(void) +ri_set_status_codes(void) { /* OK_200 */ oc_coap_status_codes[OC_STATUS_OK] = CONTENT_2_05; @@ -299,11 +300,26 @@ oc_delayed_delete_resource(oc_resource_t *resource) #endif /* OC_SERVER */ +coap_status_t +oc_status_code_unsafe(oc_status_t key) +{ + return oc_coap_status_codes[key]; +} + int oc_status_code(oc_status_t key) { - // safe: no status code is larger than INT_MAX - return (int)oc_coap_status_codes[key]; + assert(key >= 0); + if (key >= __NUM_OC_STATUS_CODES__) { + if (OC_IGNORE == key) { + return CLEAR_TRANSACTION; + } + OC_WRN("oc_status_code: invalid status code %d", (int)key); + return -1; + } + + // int cast is safe: no status code is larger than INT_MAX + return oc_status_code_unsafe(key); } int @@ -314,6 +330,7 @@ oc_coap_status_to_status(coap_status_t status) return i; } } + OC_WRN("oc_coap_status_to_status: invalid coap status code %d", (int)status); return -1; } @@ -446,7 +463,7 @@ oc_ri_get_app_resource_by_uri(const char *uri, size_t uri_len, size_t device) void oc_ri_init(void) { - set_mpro_status_codes(); + ri_set_status_codes(); #ifdef OC_SERVER oc_list_init(g_app_resources); @@ -1146,10 +1163,10 @@ ri_invoke_coap_entity_set_response(coap_packet_t *response, const oc_response_buffer_t *response_buffer = ctx.response_obj->response_buffer; - if (response_buffer->code == OC_IGNORE) { + if (response_buffer->code == CLEAR_TRANSACTION) { /* If the server-side logic chooses to reject a request, it sends - * below a response code of IGNORE, which results in the messaging - * layer freeing the CoAP transaction associated with the request. + * below a response code of CLEAR_TRANSACTION, which results in the + * messaging layer freeing the CoAP transaction associated with the request. */ coap_set_global_status_code(CLEAR_TRANSACTION); return; @@ -1159,8 +1176,9 @@ ri_invoke_coap_entity_set_response(coap_packet_t *response, if (ctx.resource != NULL) { #ifdef OC_HAS_FEATURE_ETAG if (ctx.method == OC_GET && - (response_buffer->code == oc_status_code(OC_STATUS_OK) || - response_buffer->code == oc_status_code(OC_STATUS_NOT_MODIFIED))) { + (response_buffer->code == oc_status_code_unsafe(OC_STATUS_OK) || + response_buffer->code == + oc_status_code_unsafe(OC_STATUS_NOT_MODIFIED))) { ri_invoke_coap_entity_set_response_etag(response, &ctx); } #endif /* OC_HAS_FEATURE_ETAG */ @@ -1174,7 +1192,7 @@ ri_invoke_coap_entity_set_response(coap_packet_t *response, !ctx.resource_is_collection && #endif /* OC_COLLECTIONS */ (ctx.method == OC_PUT || ctx.method == OC_POST) && - response_buffer->code < oc_status_code(OC_STATUS_BAD_REQUEST)) { + response_buffer->code < oc_status_code_unsafe(OC_STATUS_BAD_REQUEST)) { if ((ctx.iface_mask == OC_IF_STARTUP) || (ctx.iface_mask == OC_IF_STARTUP_REVERT)) { oc_resource_defaults_data_t *resource_defaults_data = @@ -1210,7 +1228,7 @@ ri_invoke_coap_entity_set_response(coap_packet_t *response, } if (response_buffer->code == - oc_status_code(OC_STATUS_REQUEST_ENTITY_TOO_LARGE)) { + oc_status_code_unsafe(OC_STATUS_REQUEST_ENTITY_TOO_LARGE)) { coap_options_set_size1(response, (uint32_t)OC_BLOCK_SIZE); } @@ -1275,7 +1293,7 @@ oc_ri_invoke_coap_entity_handler(coap_make_response_ctx_t *ctx, !oc_ri_filter_request_by_device_id(endpoint->device, uri_query, uri_query_len)) { coap_set_global_status_code(CLEAR_TRANSACTION); - coap_set_status_code(ctx->response, OC_IGNORE); + coap_set_status_code(ctx->response, CLEAR_TRANSACTION); return false; } @@ -1562,28 +1580,29 @@ oc_ri_invoke_coap_entity_handler(coap_make_response_ctx_t *ctx, if (forbidden) { OC_WRN("ocri: Forbidden request"); response_buffer.response_length = 0; - response_buffer.code = oc_status_code(OC_STATUS_FORBIDDEN); + response_buffer.code = oc_status_code_unsafe(OC_STATUS_FORBIDDEN); } else if (entity_too_large) { OC_WRN("ocri: Request payload too large (hence incomplete)"); response_buffer.response_length = 0; - response_buffer.code = oc_status_code(OC_STATUS_REQUEST_ENTITY_TOO_LARGE); + response_buffer.code = + oc_status_code_unsafe(OC_STATUS_REQUEST_ENTITY_TOO_LARGE); } else if (bad_request) { OC_WRN("ocri: Bad request"); /* Return a 4.00 response */ response_buffer.response_length = 0; - response_buffer.code = oc_status_code(OC_STATUS_BAD_REQUEST); + response_buffer.code = oc_status_code_unsafe(OC_STATUS_BAD_REQUEST); } else if (!cur_resource) { OC_WRN("ocri: Could not find resource"); /* Return a 4.04 response if the requested resource was not found */ response_buffer.response_length = 0; - response_buffer.code = oc_status_code(OC_STATUS_NOT_FOUND); + response_buffer.code = oc_status_code_unsafe(OC_STATUS_NOT_FOUND); } else if (method_not_allowed) { OC_WRN("ocri: Could not find method"); /* Return a 4.05 response if the resource does not implement the * request method. */ response_buffer.response_length = 0; - response_buffer.code = oc_status_code(OC_STATUS_METHOD_NOT_ALLOWED); + response_buffer.code = oc_status_code_unsafe(OC_STATUS_METHOD_NOT_ALLOWED); } #ifdef OC_SECURITY else if (not_authorized) { @@ -1593,13 +1612,13 @@ oc_ri_invoke_coap_entity_handler(coap_make_response_ctx_t *ctx, * access the resource. A 4.01 response is sent. */ response_buffer.response_length = 0; - response_buffer.code = oc_status_code(OC_STATUS_UNAUTHORIZED); + response_buffer.code = oc_status_code_unsafe(OC_STATUS_UNAUTHORIZED); } #endif /* OC_SECURITY */ else { if (not_modified) { response_buffer.response_length = 0; - response_buffer.code = oc_status_code(OC_STATUS_NOT_MODIFIED); + response_buffer.code = oc_status_code_unsafe(OC_STATUS_NOT_MODIFIED); } success = true; } @@ -1612,16 +1631,17 @@ oc_ri_invoke_coap_entity_handler(coap_make_response_ctx_t *ctx, uint16_t block2_size = 0; #endif /* OC_BLOCK_WISE */ if (success && method == OC_GET && - response_buffer.code < oc_status_code(OC_STATUS_BAD_REQUEST)) { + response_buffer.code < oc_status_code_unsafe(OC_STATUS_BAD_REQUEST)) { observe = ri_handle_observation(ctx->request, ctx->response, cur_resource, resource_is_collection, block2_size, endpoint, iface_query); } #endif /* OC_SERVER */ - if (request_obj.origin && (request_obj.origin->flags & MULTICAST) && - response_buffer.code >= oc_status_code(OC_STATUS_BAD_REQUEST)) { - response_buffer.code = OC_IGNORE; + if (request_obj.origin != NULL && + (request_obj.origin->flags & MULTICAST) != 0 && + response_buffer.code >= oc_status_code_unsafe(OC_STATUS_BAD_REQUEST)) { + response_buffer.code = CLEAR_TRANSACTION; } ri_invoke_coap_entity_set_response_ctx_t resp_ctx = { diff --git a/api/oc_ri_internal.h b/api/oc_ri_internal.h index 277ffff2cf..9d26371c15 100644 --- a/api/oc_ri_internal.h +++ b/api/oc_ri_internal.h @@ -66,7 +66,7 @@ typedef struct oc_response_buffer_s uint8_t *buffer; size_t buffer_size; size_t response_length; - int code; + coap_status_t code; oc_content_format_t content_format; #ifdef OC_HAS_FEATURE_ETAG oc_coap_etag_t etag; @@ -89,6 +89,9 @@ void oc_ri_init(void); */ void oc_ri_shutdown(void); +/** Unchecked conversion from a non-error oc_status_t to coap_status_t */ +coap_status_t oc_status_code_unsafe(oc_status_t key); + #ifdef OC_HAS_FEATURE_ETAG /** @brief Get ETag for given resource */ diff --git a/api/oc_server_api.c b/api/oc_server_api.c index df021111ed..dd73e127a7 100644 --- a/api/oc_server_api.c +++ b/api/oc_server_api.c @@ -132,20 +132,22 @@ oc_trigger_send_response_callback(oc_request_t *request, g_oc_send_response_cb(request, response_code); } -void +bool oc_send_response_internal(oc_request_t *request, oc_status_t response_code, oc_content_format_t content_format, size_t response_length, bool trigger_cb) { - if (!request) { - return; + int status_code = oc_status_code(response_code); + if (status_code < 0) { + return false; } request->response->response_buffer->content_format = content_format; request->response->response_buffer->response_length = response_length; - request->response->response_buffer->code = oc_status_code(response_code); + request->response->response_buffer->code = (coap_status_t)status_code; if (trigger_cb) { oc_trigger_send_response_callback(request, response_code); } + return true; } void @@ -168,8 +170,10 @@ oc_send_response_with_callback(oc_request_t *request, oc_status_t response_code, content_format = APPLICATION_CBOR; } #endif /* OC_SPEC_VER_OIC */ - oc_send_response_internal(request, response_code, content_format, - response_length(), trigger_cb); + if (!oc_send_response_internal(request, response_code, content_format, + response_length(), trigger_cb)) { + OC_ERR("could not send response: invalid response code"); + } } void @@ -181,7 +185,8 @@ oc_send_response(oc_request_t *request, oc_status_t response_code) void oc_ignore_request(oc_request_t *request) { - request->response->response_buffer->code = OC_IGNORE; + // oc_status_code(OC_IGNORE) equals CLEAR_TRANSACTION + request->response->response_buffer->code = CLEAR_TRANSACTION; } void @@ -416,10 +421,15 @@ oc_send_response_raw(oc_request_t *request, const uint8_t *payload, size_t size, oc_content_format_t content_format, oc_status_t response_code) { + int status_code = oc_status_code(response_code); + if (status_code < 0) { + OC_ERR("invalid response code(%d)", (int)response_code); + return; + } request->response->response_buffer->content_format = content_format; memcpy(request->response->response_buffer->buffer, payload, size); request->response->response_buffer->response_length = size; - request->response->response_buffer->code = oc_status_code(response_code); + request->response->response_buffer->code = (coap_status_t)status_code; } void @@ -777,7 +787,12 @@ oc_send_separate_response(oc_separate_response_t *handle, response_buffer.response_length = response_length(); } - response_buffer.code = oc_status_code(response_code); + int code = oc_status_code(response_code); + if (code < 0) { + OC_ERR("invalid response code(%d)", (int)response_code); + return; + } + response_buffer.code = (coap_status_t)code; response_buffer.content_format = APPLICATION_VND_OCF_CBOR; coap_separate_t *cur = oc_list_head(handle->requests); diff --git a/api/oc_server_api_internal.h b/api/oc_server_api_internal.h index 519b63b8fb..c1f9ec1bea 100644 --- a/api/oc_server_api_internal.h +++ b/api/oc_server_api_internal.h @@ -28,6 +28,7 @@ #include #endif /* OC_RES_BATCH_SUPPORT */ +#include #include #ifdef __cplusplus @@ -86,9 +87,10 @@ void oc_process_baseline_interface_with_filter( OC_NONNULL(1); /** Setup response for the request */ -void oc_send_response_internal(oc_request_t *request, oc_status_t response_code, +bool oc_send_response_internal(oc_request_t *request, oc_status_t response_code, oc_content_format_t content_format, - size_t response_length, bool trigger_cb); + size_t response_length, bool trigger_cb) + OC_NONNULL(); #ifdef __cplusplus } diff --git a/messaging/coap/constants.h b/messaging/coap/constants.h index 012a96965c..bffaaedb52 100644 --- a/messaging/coap/constants.h +++ b/messaging/coap/constants.h @@ -156,7 +156,7 @@ typedef enum { PACKET_SERIALIZATION_ERROR, CLEAR_TRANSACTION, EMPTY_ACK_RESPONSE, - CLOSE_ALL_TLS_SESSIONS /* DEPRECATED - NOT USED ANY MORE */ + CLOSE_ALL_TLS_SESSIONS, /* DEPRECATED - NOT USED ANY MORE */ } coap_status_t; /* CoAP header option numbers */ diff --git a/messaging/coap/observe.c b/messaging/coap/observe.c index c4f7468278..f4ae15865e 100644 --- a/messaging/coap/observe.c +++ b/messaging/coap/observe.c @@ -1009,12 +1009,12 @@ coap_fill_response(oc_response_t *response, oc_resource_t *resource, resource->get_handler.cb(&request, iface_mask, resource->get_handler.user_data); } else { - response->response_buffer->code = OC_IGNORE; + response->response_buffer->code = CLEAR_TRANSACTION; } #ifdef OC_DYNAMIC_ALLOCATION response->response_buffer->buffer_size = oc_rep_get_encoded_payload_size(); #endif /* OC_DYNAMIC_ALLOCATION */ - if (response->response_buffer->code == OC_IGNORE) { + if (response->response_buffer->code == CLEAR_TRANSACTION) { COAP_DBG("resource request ignored"); return false; } @@ -1315,7 +1315,7 @@ observe_batch_set_response_buffer(coap_batch_observer_t *batch_obs, COAP_DBG("sending data with size %d", size_after); response_buffer->content_format = APPLICATION_VND_OCF_CBOR; response_buffer->response_length = size_after; - response_buffer->code = oc_status_code(OC_STATUS_OK); + response_buffer->code = oc_status_code_unsafe(OC_STATUS_OK); #ifdef OC_HAS_FEATURE_ETAG uint64_t etag = oc_ri_get_batch_etag(obs->resource, &obs->endpoint, obs->endpoint.device); diff --git a/messaging/coap/oscore.c b/messaging/coap/oscore.c index 62a1728256..bc135faf71 100644 --- a/messaging/coap/oscore.c +++ b/messaging/coap/oscore.c @@ -19,6 +19,7 @@ #ifdef OC_SECURITY #ifdef OC_OSCORE +#include "api/oc_ri_internal.h" #include "api/oc_message_internal.h" #include "oscore.h" #include "coap.h" @@ -149,11 +150,11 @@ oscore_get_outer_code(const coap_packet_t *packet) } else { /* Responses */ if (observe) { - return oc_status_code(OC_STATUS_OK); + return oc_status_code_unsafe(OC_STATUS_OK); } } - return oc_status_code(OC_STATUS_CHANGED); + return oc_status_code_unsafe(OC_STATUS_CHANGED); } int diff --git a/util/oc_crc.c b/util/oc_crc.c index b814a73129..8037f87482 100644 --- a/util/oc_crc.c +++ b/util/oc_crc.c @@ -16,10 +16,15 @@ * ******************************************************************/ -#include "util/oc_crc_internal.h" +#include "util/oc_features.h" #ifdef OC_HAS_FEATURE_CRC64 +#include "util/oc_crc_internal.h" + +#include +#include + // ECMA-182, reflected form polynomial #define CRC64_POLYNOMIAL (0xC96C5795D7870F42ULL) diff --git a/util/oc_crc_internal.h b/util/oc_crc_internal.h index 49c3e861df..440994b5d1 100644 --- a/util/oc_crc_internal.h +++ b/util/oc_crc_internal.h @@ -19,13 +19,14 @@ #ifndef OC_CRC_INTERNAL_H #define OC_CRC_INTERNAL_H -#include "util/oc_compiler.h" #include "util/oc_features.h" -#include -#include #ifdef OC_HAS_FEATURE_CRC64 +#include "util/oc_compiler.h" +#include +#include + #ifdef __cplusplus extern "C" { #endif