Skip to content

Commit 0ffcc0f

Browse files
committed
Update to use new struct and field nmames
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
1 parent 490d7a6 commit 0ffcc0f

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

rcl/include/rcl/type_version_hash.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ extern "C"
2323
#include "rcl/types.h"
2424
#include "rcl/visibility_control.h"
2525
#include "rcutils/sha256.h"
26+
#include "rosidl_runtime_c/type_hash.h"
2627
#include "type_description_interfaces/msg/type_description.h"
2728

2829
/// Given a TypeDescription, output a string of the hashable JSON representation of that data.
@@ -66,7 +67,7 @@ RCL_PUBLIC
6667
rcl_ret_t
6768
rcl_calculate_type_version_hash(
6869
const type_description_interfaces__msg__TypeDescription * type_description,
69-
uint8_t output_hash[RCUTILS_SHA256_BLOCK_SIZE]);
70+
rosidl_type_hash_t * out_type_hash);
7071

7172
#ifdef __cplusplus
7273
}

rcl/src/rcl/type_version_hash.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ rcl_type_description_to_hashable_json(
239239
rcl_ret_t
240240
rcl_calculate_type_version_hash(
241241
const type_description_interfaces__msg__TypeDescription * type_description,
242-
uint8_t output_hash[RCUTILS_SHA256_BLOCK_SIZE])
242+
rosidl_type_hash_t * output_hash)
243243
{
244244
RCL_CHECK_ARGUMENT_FOR_NULL(type_description, RCL_RET_INVALID_ARGUMENT);
245245
RCL_CHECK_ARGUMENT_FOR_NULL(output_hash, RCL_RET_INVALID_ARGUMENT);
@@ -248,13 +248,14 @@ rcl_calculate_type_version_hash(
248248
rcutils_char_array_t msg_repr = rcutils_get_zero_initialized_char_array();
249249
msg_repr.allocator = rcl_get_default_allocator();
250250

251+
output_hash->version = 1;
251252
result = rcl_type_description_to_hashable_json(type_description, &msg_repr);
252253
if (result == RCL_RET_OK) {
253254
rcutils_sha256_ctx_t sha_ctx;
254255
rcutils_sha256_init(&sha_ctx);
255256
// Last item in char_array is null terminator, which should not be hashed.
256257
rcutils_sha256_update(&sha_ctx, (const uint8_t *)msg_repr.buffer, msg_repr.buffer_length - 1);
257-
rcutils_sha256_final(&sha_ctx, output_hash);
258+
rcutils_sha256_final(&sha_ctx, output_hash->value);
258259
}
259260
result = rcutils_char_array_fini(&msg_repr);
260261
return result;

rcl/test/rcl/test_type_version_hash.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ TEST(TestTypeVersionHash, smoke_check) {
6565
);
6666

6767
rosidl_type_hash_t direct_hash;
68-
direct_hash.version = 1;
69-
res = rcl_calculate_type_version_hash(td_msg, direct_hash.value);
68+
res = rcl_calculate_type_version_hash(td_msg, &direct_hash);
7069
ASSERT_EQ(res, RCL_RET_OK);
7170

7271
rosidl_type_hash_t hash_from_repr;
@@ -185,7 +184,7 @@ TEST(TestTypeVersionHash, nested_types) {
185184
);
186185

187186
rosidl_type_hash_t direct_hash;
188-
res = rcl_calculate_type_version_hash(td_msg, direct_hash.value);
187+
res = rcl_calculate_type_version_hash(td_msg, &direct_hash);
189188
ASSERT_EQ(res, RCL_RET_OK);
190189

191190
rosidl_type_hash_t hash_from_repr;

0 commit comments

Comments
 (0)