Skip to content

Commit

Permalink
include: zephyr: net: coap_service: Use _CONCAT expansion
Browse files Browse the repository at this point in the history
Passing MACRO arguments that need expansion require _CONCAT.

Signed-off-by: Pieter De Gendt <[email protected]>
  • Loading branch information
pdgendt committed Sep 30, 2024
1 parent 5e2203a commit da937ce
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions include/zephyr/net/coap_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct coap_service {
};

#define __z_coap_service_define(_name, _host, _port, _flags, _res_begin, _res_end) \
static struct coap_service_data coap_service_data_##_name = { \
static struct coap_service_data _CONCAT(coap_service_data_, _name) = { \
.sock_fd = -1, \
}; \
const STRUCT_SECTION_ITERABLE(coap_service, _name) = { \
Expand All @@ -69,7 +69,7 @@ struct coap_service {
.flags = _flags, \
.res_begin = (_res_begin), \
.res_end = (_res_end), \
.data = &coap_service_data_##_name, \
.data = &_CONCAT(coap_service_data_, _name), \
}

Check notice on line 73 in include/zephyr/net/coap_service.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

include/zephyr/net/coap_service.h:73 -#define __z_coap_service_define(_name, _host, _port, _flags, _res_begin, _res_end) \ - static struct coap_service_data _CONCAT(coap_service_data_, _name) = { \ - .sock_fd = -1, \ - }; \ - const STRUCT_SECTION_ITERABLE(coap_service, _name) = { \ - .name = STRINGIFY(_name), \ - .host = _host, \ - .port = (uint16_t *)(_port), \ - .flags = _flags, \ - .res_begin = (_res_begin), \ - .res_end = (_res_end), \ - .data = &_CONCAT(coap_service_data_, _name), \ +#define __z_coap_service_define(_name, _host, _port, _flags, _res_begin, _res_end) \ + static struct coap_service_data _CONCAT(coap_service_data_, _name) = { \ + .sock_fd = -1, \ + }; \ + const STRUCT_SECTION_ITERABLE(coap_service, _name) = { \ + .name = STRINGIFY(_name), .host = _host, .port = (uint16_t *)(_port), \ + .flags = _flags, .res_begin = (_res_begin), \ + .res_end = (_res_end), \ + .data = &_CONCAT(coap_service_data_, _name), \

/** @endcond */
Expand Down Expand Up @@ -111,8 +111,8 @@ struct coap_service {
* @param _service Name of the associated service.
*/
#define COAP_RESOURCE_DEFINE(_name, _service, ...) \
STRUCT_SECTION_ITERABLE_ALTERNATE(coap_resource_##_service, coap_resource, _name) \
= __VA_ARGS__
STRUCT_SECTION_ITERABLE_ALTERNATE(_CONCAT(coap_resource_, _service), coap_resource, \
_name) = __VA_ARGS__

Check notice on line 115 in include/zephyr/net/coap_service.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

include/zephyr/net/coap_service.h:115 -#define COAP_RESOURCE_DEFINE(_name, _service, ...) \ - STRUCT_SECTION_ITERABLE_ALTERNATE(_CONCAT(coap_resource_, _service), coap_resource, \ +#define COAP_RESOURCE_DEFINE(_name, _service, ...) \ + STRUCT_SECTION_ITERABLE_ALTERNATE(_CONCAT(coap_resource_, _service), coap_resource, \

/**
* @brief Define a CoAP service with static resources.
Expand All @@ -132,11 +132,11 @@ struct coap_service {
* @param _flags Configuration flags @see @ref COAP_SERVICE_FLAGS.
*/
#define COAP_SERVICE_DEFINE(_name, _host, _port, _flags) \
extern struct coap_resource _CONCAT(_coap_resource_##_name, _list_start)[]; \
extern struct coap_resource _CONCAT(_coap_resource_##_name, _list_end)[]; \
extern struct coap_resource _CONCAT(_CONCAT(_coap_resource_, _name), _list_start)[]; \
extern struct coap_resource _CONCAT(_CONCAT(_coap_resource_, _name), _list_end)[]; \
__z_coap_service_define(_name, _host, _port, _flags, \
&_CONCAT(_coap_resource_##_name, _list_start)[0], \
&_CONCAT(_coap_resource_##_name, _list_end)[0])
&_CONCAT(_CONCAT(_coap_resource_, _name), _list_start)[0], \
&_CONCAT(_CONCAT(_coap_resource_, _name), _list_end)[0])

Check notice on line 139 in include/zephyr/net/coap_service.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

include/zephyr/net/coap_service.h:139 -#define COAP_SERVICE_DEFINE(_name, _host, _port, _flags) \ - extern struct coap_resource _CONCAT(_CONCAT(_coap_resource_, _name), _list_start)[]; \ - extern struct coap_resource _CONCAT(_CONCAT(_coap_resource_, _name), _list_end)[]; \ - __z_coap_service_define(_name, _host, _port, _flags, \ - &_CONCAT(_CONCAT(_coap_resource_, _name), _list_start)[0], \ +#define COAP_SERVICE_DEFINE(_name, _host, _port, _flags) \ + extern struct coap_resource _CONCAT(_CONCAT(_coap_resource_, _name), _list_start)[]; \ + extern struct coap_resource _CONCAT(_CONCAT(_coap_resource_, _name), _list_end)[]; \ + __z_coap_service_define(_name, _host, _port, _flags, \ + &_CONCAT(_CONCAT(_coap_resource_, _name), _list_start)[0], \

/**
* @brief Count the number of CoAP services.
Expand Down Expand Up @@ -177,7 +177,7 @@ struct coap_service {
* @param _it Name of iterator (of type @ref coap_resource)
*/
#define COAP_RESOURCE_FOREACH(_service, _it) \
STRUCT_SECTION_FOREACH_ALTERNATE(coap_resource_##_service, coap_resource, _it)
STRUCT_SECTION_FOREACH_ALTERNATE(_CONCAT(coap_resource_, _service), coap_resource, _it)

Check notice on line 180 in include/zephyr/net/coap_service.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

include/zephyr/net/coap_service.h:180 -#define COAP_RESOURCE_FOREACH(_service, _it) \ +#define COAP_RESOURCE_FOREACH(_service, _it) \

/**
* @brief Iterate over all static resources associated with @p _service .
Expand Down

0 comments on commit da937ce

Please sign in to comment.