Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MISRA rule 8-3(1/2) 'declarations of a function same name and type' #1742

Merged
merged 6 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/codeql/resolved-misra-rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ queries:
- uses: ./codeql-coding-standards/c/misra/src/rules/RULE-21-19/ValuesReturnedByLocaleSettingUsedAsPtrToConst.ql
- uses: ./codeql-coding-standards/c/misra/src/rules/RULE-17-4/NonVoidFunctionReturnCondition.ql
- uses: ./codeql-coding-standards/c/misra/src/rules/RULE-8-2/FunctionTypesNotInPrototypeForm.ql
- uses: ./codeql-coding-standards/c/misra/src/rules/RULE-8-3/DeclarationsOfAFunctionSameNameAndType.ql #[1/2]
# - uses: ./codeql-coding-standards/c/misra/src/rules/RULE-8-3/DeclarationsOfAnObjectSameNameAndType.ql #[2/2]
30 changes: 15 additions & 15 deletions src/core/cdr/include/dds/cdr/dds_cdrstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ dds_ostream_t dds_ostream_from_buffer(void *buffer, size_t size, uint16_t write_
* @param size size of the data
* @param bswap byte-swapping required
* @param xcdr_version XCDR version of the CDR data
* @param type type descriptor
* @param desc type descriptor
* @param just_key indicates if the data is a serialized key or a complete sample
* @param actual_size is set to the actual size of the data (*actual_size <= size) on successful return
* @returns True iff validation and normalization succeeded
*/
DDS_EXPORT bool dds_stream_normalize (void * __restrict data, uint32_t size, bool bswap, uint32_t xcdr_version, const struct dds_cdrstream_desc * __restrict type, bool just_key, uint32_t * __restrict actual_size) ddsrt_attribute_warn_unused_result ddsrt_nonnull_all;
DDS_EXPORT bool dds_stream_normalize (void * __restrict data, uint32_t size, bool bswap, uint32_t xcdr_version, const struct dds_cdrstream_desc * __restrict desc, bool just_key, uint32_t * __restrict actual_size) ddsrt_attribute_warn_unused_result ddsrt_nonnull_all;

/** @component cdr_serializer */
DDS_EXPORT const uint32_t *dds_stream_normalize_data (char * __restrict data, uint32_t * __restrict off, uint32_t size, bool bswap, uint32_t xcdr_version, const uint32_t * __restrict ops) ddsrt_attribute_warn_unused_result ddsrt_nonnull_all;
Expand All @@ -172,16 +172,16 @@ DDS_EXPORT const uint32_t *dds_stream_writeBE (dds_ostreamBE_t * __restrict os,
DDS_EXPORT const uint32_t * dds_stream_write_with_byte_order (dds_ostream_t * __restrict os, const struct dds_cdrstream_allocator * __restrict allocator, const char * __restrict data, const uint32_t * __restrict ops, enum ddsrt_byte_order_selector bo);

/** @component cdr_serializer */
DDS_EXPORT bool dds_stream_write_sample (dds_ostream_t * __restrict os, const struct dds_cdrstream_allocator * __restrict allocator, const void * __restrict data, const struct dds_cdrstream_desc * __restrict type);
DDS_EXPORT bool dds_stream_write_sample (dds_ostream_t * __restrict os, const struct dds_cdrstream_allocator * __restrict allocator, const void * __restrict data, const struct dds_cdrstream_desc * __restrict desc);

/** @component cdr_serializer */
DDS_EXPORT bool dds_stream_write_sampleLE (dds_ostreamLE_t * __restrict os, const struct dds_cdrstream_allocator * __restrict allocator, const void * __restrict data, const struct dds_cdrstream_desc * __restrict type);
DDS_EXPORT bool dds_stream_write_sampleLE (dds_ostreamLE_t * __restrict os, const struct dds_cdrstream_allocator * __restrict allocator, const void * __restrict data, const struct dds_cdrstream_desc * __restrict desc);

/** @component cdr_serializer */
DDS_EXPORT bool dds_stream_write_sampleBE (dds_ostreamBE_t * __restrict os, const struct dds_cdrstream_allocator * __restrict allocator, const void * __restrict data, const struct dds_cdrstream_desc * __restrict type);
DDS_EXPORT bool dds_stream_write_sampleBE (dds_ostreamBE_t * __restrict os, const struct dds_cdrstream_allocator * __restrict allocator, const void * __restrict data, const struct dds_cdrstream_desc * __restrict desc);

/** @component cdr_serializer */
DDS_EXPORT void dds_stream_read_sample (dds_istream_t * __restrict is, void * __restrict data, const struct dds_cdrstream_allocator * __restrict allocator, const struct dds_cdrstream_desc * __restrict type);
DDS_EXPORT void dds_stream_read_sample (dds_istream_t * __restrict is, void * __restrict data, const struct dds_cdrstream_allocator * __restrict allocator, const struct dds_cdrstream_desc * __restrict desc);

/** @component cdr_serializer */
DDS_EXPORT void dds_stream_free_sample (void * __restrict data, const struct dds_cdrstream_allocator * __restrict allocator, const uint32_t * __restrict ops);
Expand All @@ -193,34 +193,34 @@ DDS_EXPORT uint32_t dds_stream_countops (const uint32_t * __restrict ops, uint32
size_t dds_stream_check_optimize (const struct dds_cdrstream_desc * __restrict desc, uint32_t xcdr_version);

/** @component cdr_serializer */
void dds_stream_write_key (dds_ostream_t * __restrict os, const struct dds_cdrstream_allocator * __restrict allocator, const char * __restrict sample, const struct dds_cdrstream_desc * __restrict type);
void dds_stream_write_key (dds_ostream_t * __restrict os, const struct dds_cdrstream_allocator * __restrict allocator, const char * __restrict sample, const struct dds_cdrstream_desc * __restrict desc);

/** @component cdr_serializer */
void dds_stream_write_keyBE (dds_ostreamBE_t * __restrict os, const struct dds_cdrstream_allocator * __restrict allocator, const char * __restrict sample, const struct dds_cdrstream_desc * __restrict type);
void dds_stream_write_keyBE (dds_ostreamBE_t * __restrict os, const struct dds_cdrstream_allocator * __restrict allocator, const char * __restrict sample, const struct dds_cdrstream_desc * __restrict desc);

/** @component cdr_serializer */
DDS_EXPORT bool dds_stream_extract_key_from_data (dds_istream_t * __restrict is, dds_ostream_t * __restrict os, const struct dds_cdrstream_allocator * __restrict allocator, const struct dds_cdrstream_desc * __restrict type);
DDS_EXPORT bool dds_stream_extract_key_from_data (dds_istream_t * __restrict is, dds_ostream_t * __restrict os, const struct dds_cdrstream_allocator * __restrict allocator, const struct dds_cdrstream_desc * __restrict desc);

/** @component cdr_serializer */
DDS_EXPORT void dds_stream_extract_key_from_key (dds_istream_t * __restrict is, dds_ostream_t * __restrict os, const struct dds_cdrstream_allocator * __restrict allocator, const struct dds_cdrstream_desc * __restrict type);
DDS_EXPORT void dds_stream_extract_key_from_key (dds_istream_t * __restrict is, dds_ostream_t * __restrict os, const struct dds_cdrstream_allocator * __restrict allocator, const struct dds_cdrstream_desc * __restrict desc);

/** @component cdr_serializer */
DDS_EXPORT bool dds_stream_extract_keyBE_from_data (dds_istream_t * __restrict is, dds_ostreamBE_t * __restrict os, const struct dds_cdrstream_allocator * __restrict allocator, const struct dds_cdrstream_desc * __restrict type);
DDS_EXPORT bool dds_stream_extract_keyBE_from_data (dds_istream_t * __restrict is, dds_ostreamBE_t * __restrict os, const struct dds_cdrstream_allocator * __restrict allocator, const struct dds_cdrstream_desc * __restrict desc);

/** @component cdr_serializer */
DDS_EXPORT void dds_stream_extract_keyBE_from_key (dds_istream_t * __restrict is, dds_ostreamBE_t * __restrict os, const struct dds_cdrstream_allocator * __restrict allocator, const struct dds_cdrstream_desc * __restrict type);
DDS_EXPORT void dds_stream_extract_keyBE_from_key (dds_istream_t * __restrict is, dds_ostreamBE_t * __restrict os, const struct dds_cdrstream_allocator * __restrict allocator, const struct dds_cdrstream_desc * __restrict desc);

/** @component cdr_serializer */
DDS_EXPORT const uint32_t *dds_stream_read (dds_istream_t * __restrict is, char * __restrict data, const struct dds_cdrstream_allocator * __restrict allocator, const uint32_t * __restrict ops);

/** @component cdr_serializer */
DDS_EXPORT void dds_stream_read_key (dds_istream_t * __restrict is, char * __restrict sample, const struct dds_cdrstream_allocator * __restrict allocator, const struct dds_cdrstream_desc * __restrict type);
DDS_EXPORT void dds_stream_read_key (dds_istream_t * __restrict is, char * __restrict sample, const struct dds_cdrstream_allocator * __restrict allocator, const struct dds_cdrstream_desc * __restrict desc);

/** @component cdr_serializer */
DDS_EXPORT size_t dds_stream_print_key (dds_istream_t * __restrict is, const struct dds_cdrstream_desc * __restrict type, char * __restrict buf, size_t size);
DDS_EXPORT size_t dds_stream_print_key (dds_istream_t * __restrict is, const struct dds_cdrstream_desc * __restrict desc, char * __restrict buf, size_t size);

/** @component cdr_serializer */
DDS_EXPORT size_t dds_stream_print_sample (dds_istream_t * __restrict is, const struct dds_cdrstream_desc * __restrict type, char * __restrict buf, size_t size);
DDS_EXPORT size_t dds_stream_print_sample (dds_istream_t * __restrict is, const struct dds_cdrstream_desc * __restrict desc, char * __restrict buf, size_t size);

/** @component cdr_serializer */
uint16_t dds_stream_minimum_xcdr_version (const uint32_t * __restrict ops);
Expand Down
20 changes: 10 additions & 10 deletions src/core/cdr/src/dds_cdrstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -4312,10 +4312,10 @@ static const uint32_t * dds_stream_print_sample1 (char * __restrict *buf, size_t
return ops;
}

size_t dds_stream_print_sample (dds_istream_t * __restrict is, const struct dds_cdrstream_desc * __restrict desc, char * __restrict buf, size_t bufsize)
size_t dds_stream_print_sample (dds_istream_t * __restrict is, const struct dds_cdrstream_desc * __restrict desc, char * __restrict buf, size_t size)
{
(void) dds_stream_print_sample1 (&buf, &bufsize, is, desc->ops.ops, true, false);
return bufsize;
(void) dds_stream_print_sample1 (&buf, &size, is, desc->ops.ops, true, false);
return size;
}

static void dds_stream_print_key_impl (dds_istream_t * __restrict is, const uint32_t *ops, uint16_t key_offset_count, const uint32_t * key_offset_insn,
Expand Down Expand Up @@ -4344,34 +4344,34 @@ static void dds_stream_print_key_impl (dds_istream_t * __restrict is, const uint
}
}

size_t dds_stream_print_key (dds_istream_t * __restrict is, const struct dds_cdrstream_desc * __restrict desc, char * __restrict buf, size_t bufsize)
size_t dds_stream_print_key (dds_istream_t * __restrict is, const struct dds_cdrstream_desc * __restrict desc, char * __restrict buf, size_t size)
{
bool cont = prtf (&buf, &bufsize, ":k:{");
bool cont = prtf (&buf, &size, ":k:{");
bool needs_comma = false;
for (uint32_t i = 0; cont && i < desc->keys.nkeys; i++)
{
if (needs_comma)
(void) prtf (&buf, &bufsize, ",");
(void) prtf (&buf, &size, ",");
needs_comma = true;
const uint32_t *op = desc->ops.ops + desc->keys.keys[i].ops_offs;
switch (DDS_OP (*op))
{
case DDS_OP_KOF: {
uint16_t n_offs = DDS_OP_LENGTH (*op);
dds_stream_print_key_impl (is, desc->ops.ops + op[1], --n_offs, op + 2, &buf, &bufsize, &cont);
dds_stream_print_key_impl (is, desc->ops.ops + op[1], --n_offs, op + 2, &buf, &size, &cont);
break;
}
case DDS_OP_ADR: {
dds_stream_print_key_impl (is, op, 0, NULL, &buf, &bufsize, &cont);
dds_stream_print_key_impl (is, op, 0, NULL, &buf, &size, &cont);
break;
}
default:
abort ();
break;
}
}
(void) prtf (&buf, &bufsize, "}");
return bufsize;
(void) prtf (&buf, &size, "}");
return size;
}

/* Gets the (minimum) extensibility of the types used for this topic, and returns the XCDR
Expand Down
10 changes: 5 additions & 5 deletions src/core/cdr/src/dds_cdrstream_keys.part.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,28 +316,28 @@ static const uint32_t *dds_stream_extract_keyBO_from_data_pl (dds_istream_t * __

static const uint32_t *dds_stream_extract_keyBO_from_data1 (dds_istream_t * __restrict is, DDS_OSTREAM_T * __restrict os, const struct dds_cdrstream_allocator * __restrict allocator,
uint32_t ops_offs_idx, uint32_t * __restrict ops_offs, const uint32_t * const __restrict op0, const uint32_t * const __restrict op0_type, const uint32_t * __restrict ops, bool mutable_member, bool mutable_member_or_parent,
uint32_t n_keys, uint32_t * __restrict keys_remaining, const dds_cdrstream_desc_key_t * __restrict keys, struct key_off_info * __restrict key_offs)
uint32_t n_keys, uint32_t * __restrict keys_remaining, const dds_cdrstream_desc_key_t * __restrict key, struct key_off_info * __restrict key_offs)
{
uint32_t insn;
while ((insn = *ops) != DDS_OP_RTS)
{
switch (DDS_OP (insn))
{
case DDS_OP_ADR:
ops = dds_stream_extract_keyBO_from_data_adr (insn, is, os, allocator, ops_offs_idx, ops_offs, op0, op0_type, ops, mutable_member, mutable_member_or_parent, n_keys, keys_remaining, keys, key_offs);
ops = dds_stream_extract_keyBO_from_data_adr (insn, is, os, allocator, ops_offs_idx, ops_offs, op0, op0_type, ops, mutable_member, mutable_member_or_parent, n_keys, keys_remaining, key, key_offs);
break;
case DDS_OP_JSR:
(void) dds_stream_extract_keyBO_from_data1 (is, os, allocator, ops_offs_idx, ops_offs, op0, op0_type, ops + DDS_OP_JUMP (insn), mutable_member, mutable_member_or_parent, n_keys, keys_remaining, keys, key_offs);
(void) dds_stream_extract_keyBO_from_data1 (is, os, allocator, ops_offs_idx, ops_offs, op0, op0_type, ops + DDS_OP_JUMP (insn), mutable_member, mutable_member_or_parent, n_keys, keys_remaining, key, key_offs);
ops++;
break;
case DDS_OP_RTS: case DDS_OP_JEQ: case DDS_OP_JEQ4: case DDS_OP_KOF: case DDS_OP_PLM:
abort ();
break;
case DDS_OP_DLC:
ops = dds_stream_extract_keyBO_from_data_delimited (is, os, allocator, ops_offs_idx, ops_offs, op0, ops, ops, mutable_member_or_parent, n_keys, keys_remaining, keys, key_offs);
ops = dds_stream_extract_keyBO_from_data_delimited (is, os, allocator, ops_offs_idx, ops_offs, op0, ops, ops, mutable_member_or_parent, n_keys, keys_remaining, key, key_offs);
break;
case DDS_OP_PLC:
ops = dds_stream_extract_keyBO_from_data_pl (is, os, allocator, ops_offs_idx, ops_offs, op0, ops, ops, n_keys, keys_remaining, keys, key_offs);
ops = dds_stream_extract_keyBO_from_data_pl (is, os, allocator, ops_offs_idx, ops_offs, op0, ops, ops, n_keys, keys_remaining, key, key_offs);
break;
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/core/ddsc/include/dds/dds.h
Original file line number Diff line number Diff line change
Expand Up @@ -2458,7 +2458,7 @@ dds_write(dds_entity_t writer, const void *data);
* datapackets for network efficiency. The normal `dds_write()` no longer
* guarantee that data is sent on the network automatically.
*
* @param[in] writer The writer entity.
* @param[in] entity The writer entity.

* @returns A dds_return_t indicating success or failure.
* @retval DDS_RETCODE_OK
Expand All @@ -2473,7 +2473,7 @@ dds_write(dds_entity_t writer, const void *data);
* The entity has already been deleted.
*/
DDS_EXPORT dds_return_t
dds_write_flush(dds_entity_t writer);
dds_write_flush(dds_entity_t entity);

/**
* @brief Write a serialized value of a data instance
Expand Down Expand Up @@ -2668,7 +2668,7 @@ dds_create_querycondition(
* This means that the guardcondition can be used to wake up a waitset when
* data is in the reader history with states that matches the given mask.
*
* @param[in] participant Participant on which to create the guardcondition.
* @param[in] owner Participant on which to create the guardcondition.
*
* @returns A valid condition handle or an error code.
*
Expand All @@ -2682,7 +2682,7 @@ dds_create_querycondition(
* The entity has already been deleted.
*/
DDS_EXPORT dds_entity_t
dds_create_guardcondition(dds_entity_t participant);
dds_create_guardcondition(dds_entity_t owner);

/**
* @brief Sets the trigger status of a guardcondition.
Expand Down Expand Up @@ -2769,7 +2769,7 @@ typedef intptr_t dds_attach_t;
* conditions of the attached entities evaluates to TRUE or until the timeout
* expires.
*
* @param[in] participant Domain participant which the WaitSet contains.
* @param[in] owner Domain participant which the WaitSet contains.
*
* @returns A valid waitset handle or an error code.
*
Expand All @@ -2783,7 +2783,7 @@ typedef intptr_t dds_attach_t;
* The entity has already been deleted.
*/
DDS_EXPORT dds_entity_t
dds_create_waitset(dds_entity_t participant);
dds_create_waitset(dds_entity_t owner);

/**
* @brief Acquire previously attached entities.
Expand Down Expand Up @@ -4155,7 +4155,7 @@ dds_lookup_instance(dds_entity_t entity, const void *data);
* @component data_instance
*
* @param[in] entity Reader, writer, readcondition or querycondition entity.
* @param[in] inst Instance handle.
* @param[in] ih Instance handle.
* @param[out] data pointer to an instance, to which the key ID corresponding to the instance handle will be
* returned, the sample in the instance should be ignored.
*
Expand All @@ -4173,7 +4173,7 @@ dds_lookup_instance(dds_entity_t entity, const void *data);
DDS_EXPORT dds_return_t
dds_instance_get_key(
dds_entity_t entity,
dds_instance_handle_t inst,
dds_instance_handle_t ih,
void *data);

/**
Expand Down
Loading