Skip to content

Commit

Permalink
Add const to constant rcl_context functions (#872)
Browse files Browse the repository at this point in the history
* Add const keyword to signature of rcl_context_{get_instance_id,is_valid}

Signed-off-by: Thijs Raymakers <thijs@raymakers.nl>
  • Loading branch information
ThijsRay authored Dec 3, 2020
1 parent f55975a commit e569f3f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions rcl/include/rcl/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ rcl_context_get_init_options(const rcl_context_t * context);
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_context_instance_id_t
rcl_context_get_instance_id(rcl_context_t * context);
rcl_context_get_instance_id(const rcl_context_t * context);

/// Returns the context domain id.
/**
Expand Down Expand Up @@ -287,7 +287,7 @@ rcl_context_get_domain_id(rcl_context_t * context, size_t * domain_id);
RCL_PUBLIC
RCL_WARN_UNUSED
bool
rcl_context_is_valid(rcl_context_t * context);
rcl_context_is_valid(const rcl_context_t * context);

/// Return pointer to the rmw context if the given context is currently valid, otherwise `NULL`.
/**
Expand Down
4 changes: 2 additions & 2 deletions rcl/src/rcl/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ rcl_context_get_init_options(const rcl_context_t * context)
}

rcl_context_instance_id_t
rcl_context_get_instance_id(rcl_context_t * context)
rcl_context_get_instance_id(const rcl_context_t * context)
{
RCL_CHECK_ARGUMENT_FOR_NULL(context, 0);
return rcutils_atomic_load_uint64_t((atomic_uint_least64_t *)(&context->instance_id_storage));
Expand All @@ -91,7 +91,7 @@ rcl_context_get_domain_id(rcl_context_t * context, size_t * domain_id)
}

bool
rcl_context_is_valid(rcl_context_t * context)
rcl_context_is_valid(const rcl_context_t * context)
{
RCL_CHECK_ARGUMENT_FOR_NULL(context, false);
return 0 != rcl_context_get_instance_id(context);
Expand Down

0 comments on commit e569f3f

Please sign in to comment.