Skip to content

Commit f9bbb61

Browse files
micro-ROS rolling Library auto-update 19-01-2023 06:18 (#1256)
Co-authored-by: pablogs9 <[email protected]>
1 parent 47139d6 commit f9bbb61

File tree

4 files changed

+89
-64
lines changed

4 files changed

+89
-64
lines changed

built_packages

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ https://github.com/ros2/rcl_interfaces.git 43ffb7b6df6a98a1a35d0932d148ad12de549
2424
https://github.com/ros2/rcl_logging.git d76b545f881552a6d9b8563c5fd20d73545ddffa
2525
https://github.com/ros2/rclc 243ee63ca369f0fb90397ba9ae0ca1283ab16ad3
2626
https://github.com/ros2/rcpputils.git 8593a4fc66bb1348eba263639559ca638f21a19a
27-
https://github.com/ros2/rmw.git 31c6fd094c8bd01d0a231856df1bd9a476bea26a
27+
https://github.com/ros2/rmw.git 3046e9f91ac1c45bb0a1433279584849b399c883
2828
https://github.com/ros2/rmw_implementation.git 68faf3708b8dbda4577b8a4805e9e630c3d899ea
2929
https://github.com/ros2/rosidl.git a46056cc3cf0c69d1d1db5b9c2afbfd13fe9fba3
3030
https://github.com/ros2/rosidl_core.git ef51d18c37ab3fe9da87b2f6e0eb38730c5daad4
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// Copyright 2023 Open Source Robotics Foundation, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef RMW__CHECK_TYPE_IDENTIFIERS_MATCH_H_
16+
#define RMW__CHECK_TYPE_IDENTIFIERS_MATCH_H_
17+
18+
#include <string.h>
19+
20+
#include "rcutils/snprintf.h"
21+
22+
#include "rmw/allocators.h"
23+
#include "rmw/error_handling.h"
24+
#include "rmw/impl/config.h" // For RMW_AVOID_MEMORY_ALLOCATION
25+
26+
#if RMW_AVOID_MEMORY_ALLOCATION
27+
#define RMW_CHECK_TYPE_IDENTIFIERS_MATCH(ElementName, ElementTypeID, ExpectedTypeID, OnFailure) \
28+
do { \
29+
if (ElementTypeID != ExpectedTypeID) { \
30+
char __msg[1024]; \
31+
int ret = rcutils_snprintf( \
32+
__msg, sizeof(__msg), \
33+
#ElementName " implementation '%s'(%p) does not match rmw implementation '%s'(%p)", \
34+
ElementTypeID, (const void *)ElementTypeID, \
35+
ExpectedTypeID, (const void *)ExpectedTypeID); \
36+
if (ret < 0) { \
37+
static const char error_msg[] = \
38+
"RMW_CHECK_TYPE_IDENTIFIERS_MATCH(): rcutils_snprintf() failed"; \
39+
memmove(__msg, error_msg, sizeof(error_msg)); \
40+
} \
41+
RMW_SET_ERROR_MSG(__msg); \
42+
OnFailure; \
43+
} \
44+
} while(0)
45+
#else // RMW_AVOID_MEMORY_ALLOCATION
46+
#define RMW_CHECK_TYPE_IDENTIFIERS_MATCH(ElementName, ElementTypeID, ExpectedTypeID, OnFailure) \
47+
do { \
48+
if (ElementTypeID != ExpectedTypeID) { \
49+
int __bytes_that_would_have_been_written = rcutils_snprintf( \
50+
NULL, 0, \
51+
#ElementName " implementation '%s'(%p) does not match rmw implementation '%s'(%p)", \
52+
ElementTypeID, (const void *)ElementTypeID, \
53+
ExpectedTypeID, (const void *)ExpectedTypeID); \
54+
if (__bytes_that_would_have_been_written < 0) { \
55+
RMW_SET_ERROR_MSG( \
56+
"RMW_CHECK_TYPE_IDENTIFIERS_MATCH(): rcutils_snprintf(NULL, 0, ...) failed"); \
57+
OnFailure; \
58+
} else { \
59+
char * __msg = \
60+
(char *)rmw_allocate(__bytes_that_would_have_been_written + 1); \
61+
if (NULL == __msg) { \
62+
RMW_SET_ERROR_MSG( \
63+
"RMW_CHECK_TYPE_IDENTIFIERS_MATCH(): rmw_allocate() failed"); \
64+
} else { \
65+
int ret = rcutils_snprintf( \
66+
__msg, __bytes_that_would_have_been_written + 1, \
67+
#ElementName " implementation '%s'(%p) does not match rmw implementation '%s'(%p)", \
68+
ElementTypeID, (const void *)ElementTypeID, \
69+
ExpectedTypeID, (const void *)ExpectedTypeID); \
70+
if (ret < 0) { \
71+
RMW_SET_ERROR_MSG( \
72+
"RMW_CHECK_TYPE_IDENTIFIERS_MATCH(): rcutils_snprintf() failed"); \
73+
} else { \
74+
RMW_SET_ERROR_MSG(__msg); \
75+
} \
76+
} \
77+
rmw_free(__msg); \
78+
OnFailure; \
79+
} \
80+
} \
81+
} while(0)
82+
#endif // RMW_AVOID_MEMORY_ALLOCATION
83+
84+
#endif // RMW__CHECK_TYPE_IDENTIFIERS_MATCH_H_

src/rmw/impl/cpp/macros.hpp

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@
1717

1818
#include <iostream>
1919
#include <sstream>
20+
#include <stdexcept>
2021
#include <string>
2122

22-
#include "rcutils/snprintf.h"
23-
24-
#include "rmw/allocators.h"
23+
#include "rmw/check_type_identifiers_match.h"
2524
#include "rmw/error_handling.h"
26-
#include "rmw/impl/config.h" // For RMW_AVOID_MEMORY_ALLOCATION
2725
#include "rmw/impl/cpp/demangle.hpp" // For demangle.
2826

2927
#define RMW_TRY_PLACEMENT_NEW(Destination, BufferForNew, FailureAction, Type, ...) \
@@ -72,62 +70,4 @@
7270
(std::cerr << ss.str()).flush(); \
7371
}
7472

75-
#if RMW_AVOID_MEMORY_ALLOCATION
76-
#define RMW_CHECK_TYPE_IDENTIFIERS_MATCH(ElementName, ElementTypeID, ExpectedTypeID, OnFailure) \
77-
{ \
78-
if (ElementTypeID != ExpectedTypeID) { \
79-
char __msg[1024]; \
80-
int ret = rcutils_snprintf( \
81-
__msg, sizeof(__msg), \
82-
#ElementName " implementation '%s'(%p) does not match rmw implementation '%s'(%p)", \
83-
ElementTypeID, reinterpret_cast<const void *>(ElementTypeID), \
84-
ExpectedTypeID, reinterpret_cast<const void *>(ExpectedTypeID)); \
85-
if (ret < 0) { \
86-
static const char error_msg[] = \
87-
"RMW_CHECK_TYPE_IDENTIFIERS_MATCH(): rcutils_snprintf() failed"; \
88-
memmove(__msg, error_msg, sizeof(error_msg)); \
89-
} \
90-
RMW_SET_ERROR_MSG(__msg); \
91-
OnFailure; \
92-
} \
93-
}
94-
#else // RMW_AVOID_MEMORY_ALLOCATION
95-
#define RMW_CHECK_TYPE_IDENTIFIERS_MATCH(ElementName, ElementTypeID, ExpectedTypeID, OnFailure) \
96-
{ \
97-
if (ElementTypeID != ExpectedTypeID) { \
98-
int __bytes_that_would_have_been_written = rcutils_snprintf( \
99-
NULL, 0, \
100-
#ElementName " implementation '%s'(%p) does not match rmw implementation '%s'(%p)", \
101-
ElementTypeID, reinterpret_cast<const void *>(ElementTypeID), \
102-
ExpectedTypeID, reinterpret_cast<const void *>(ExpectedTypeID)); \
103-
if (__bytes_that_would_have_been_written < 0) { \
104-
RMW_SET_ERROR_MSG( \
105-
"RMW_CHECK_TYPE_IDENTIFIERS_MATCH(): rcutils_snprintf(NULL, 0, ...) failed"); \
106-
OnFailure; \
107-
} else { \
108-
char * __msg = \
109-
reinterpret_cast<char *>(rmw_allocate(__bytes_that_would_have_been_written + 1)); \
110-
if (NULL == __msg) { \
111-
RMW_SET_ERROR_MSG( \
112-
"RMW_CHECK_TYPE_IDENTIFIERS_MATCH(): rmw_allocate() failed"); \
113-
} else { \
114-
int ret = rcutils_snprintf( \
115-
__msg, __bytes_that_would_have_been_written + 1, \
116-
#ElementName " implementation '%s'(%p) does not match rmw implementation '%s'(%p)", \
117-
ElementTypeID, reinterpret_cast<const void *>(ElementTypeID), \
118-
ExpectedTypeID, reinterpret_cast<const void *>(ExpectedTypeID)); \
119-
if (ret < 0) { \
120-
RMW_SET_ERROR_MSG( \
121-
"RMW_CHECK_TYPE_IDENTIFIERS_MATCH(): rcutils_snprintf() failed"); \
122-
} else { \
123-
RMW_SET_ERROR_MSG(__msg); \
124-
} \
125-
} \
126-
rmw_free(__msg); \
127-
OnFailure; \
128-
} \
129-
} \
130-
}
131-
#endif // RMW_AVOID_MEMORY_ALLOCATION
132-
13373
#endif // RMW__IMPL__CPP__MACROS_HPP_

src/rmw/macros.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
/// Expand the argument to its literal text
2121
#define RMW_STRINGIFY(x) RCUTILS_STRINGIFY(x)
2222

23-
/// Indicate that a variable is not used, and prevent compiler from issuing warnings
23+
/// Indicate that the caller of a method must check the return value,
24+
/// otherwise the compiler will issue a warning.
2425
#define RMW_WARN_UNUSED RCUTILS_WARN_UNUSED
2526

2627
#endif // RMW__MACROS_H_

0 commit comments

Comments
 (0)