-
Notifications
You must be signed in to change notification settings - Fork 24
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
Usage of 'fixed-size' integer types in RTI code #453
base: main
Are you sure you want to change the base?
Conversation
Note Currently processing new changes in this PR. This may take a few minutes, please wait... Files selected for processing (5)
WalkthroughThe changes standardize the data type used for a federate ID across multiple files, switching from Changes
Possibly related issues
Tip CodeRabbit can generate a title for your PR based on the changes.Add @coderabbitai placeholder anywhere in the title of your PR and CodeRabbit will replace it with a title based on the changes in the PR. You can change the placeholder by changing the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- core/federated/RTI/rti_remote.c (2 hunks)
- core/federated/clock-sync.c (1 hunks)
- core/utils/util.c (1 hunks)
Files skipped from review due to trivial changes (1)
- core/utils/util.c
Additional comments not posted (1)
core/federated/RTI/rti_remote.c (1)
926-926
: Updated message size calculation for clock syncThe change from
int32_t
touint16_t
for the federate ID in the clock synchronization logic is correctly reflected in themessage_size
calculation. This change should help reduce the network overhead and aligns with the PR's aim to improve efficiency on systems whereuint16_t
is the native size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- core/federated/RTI/rti_remote.c (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- core/federated/RTI/rti_remote.c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- core/utils/util.c (2 hunks)
- include/core/utils/util.h (1 hunks)
Files skipped from review due to trivial changes (1)
- include/core/utils/util.h
Files skipped from review as they are similar to previous changes (1)
- core/utils/util.c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- core/federated/RTI/rti_remote.c (3 hunks)
- core/federated/clock-sync.c (1 hunks)
Files skipped from review as they are similar to previous changes (2)
- core/federated/RTI/rti_remote.c
- core/federated/clock-sync.c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- core/federated/RTI/rti_remote.c (3 hunks)
Files skipped from review as they are similar to previous changes (1)
- core/federated/RTI/rti_remote.c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- core/federated/RTI/rti_remote.c (3 hunks)
- core/federated/clock-sync.c (1 hunks)
- core/federated/federate.c (2 hunks)
- core/utils/util.c (2 hunks)
- include/core/utils/util.h (1 hunks)
Files skipped from review as they are similar to previous changes (4)
- core/federated/RTI/rti_remote.c
- core/federated/clock-sync.c
- core/utils/util.c
- include/core/utils/util.h
Additional comments not posted (2)
core/federated/federate.c (2)
Line range hint
1189-1192
: Verify the impact of removing the check for_lf_my_fed_id
exceedingUINT16_MAX
.The removal of this check might lead to potential issues if
_lf_my_fed_id
exceeds the maximum value for auint16_t
. Ensure that this change does not introduce any vulnerabilities or unexpected behavior.
Line range hint
1442-1445
: Verify the impact of removing the check for_lf_my_fed_id
exceedingUINT16_MAX
.The removal of this check might lead to potential issues if
_lf_my_fed_id
exceeds the maximum value for auint16_t
. Ensure that this change does not introduce any vulnerabilities or unexpected behavior.
core/utils/util.c
Outdated
@@ -112,23 +112,29 @@ void _lf_message_print(const char* prefix, const char* format, va_list args, | |||
// interleaved between threads. | |||
// vprintf() is a version that takes an arg list rather than multiple args. | |||
char* message; | |||
if (_lf_my_fed_id < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part gives compile time errors, since the uint16_t type will never be a negative integer.
However, if I remove the whole if and else
, unit-tests
fail, especially, general_utils_pqueue_test_c
fails with a segfault.
It will not go through the removed if statement, and fail at line 129, because the name
is a NULL pointer. Does anyone have ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to replace -1
with another id that indicates an uninitialized id or no id. Either 0x0000
or 0xffff
. If we go with 0x0000
than of course, the first valid ID would be 0x0001
which is a potential breaking change. So 0xffff
seems safer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- core/utils/util.c (3 hunks)
Files skipped from review as they are similar to previous changes (1)
- core/utils/util.c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. My only nitpick is that I would like to suggest using a name macro instead of the magic number 0xffff
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I made some minor suggestions for paranoid coding.
if (_lf_my_fed_id > UINT16_MAX) { | ||
// This error is very unlikely to occur. | ||
lf_print_error_and_exit("Too many federates! More than %d.", UINT16_MAX); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest:
if (_lf_my_fed_id == UINT16_MAX) {
lf_print_error_and_exit("Too many federates! More than %d.", UINT16_MAX - 1);
}
if (_lf_my_fed_id > UINT16_MAX) { | ||
lf_print_error_and_exit("Too many federates! More than %d.", UINT16_MAX); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest:
if (_lf_my_fed_id == UINT16_MAX) {
lf_print_error_and_exit("Too many federates! More than %d.", UINT16_MAX - 1);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- core/federated/RTI/rti_remote.c (3 hunks)
- core/federated/federate.c (2 hunks)
Files skipped from review as they are similar to previous changes (2)
- core/federated/RTI/rti_remote.c
- core/federated/federate.c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- core/utils/util.c (3 hunks)
Files skipped from review as they are similar to previous changes (1)
- core/utils/util.c
I'm still getting failures on this test, |
No, the error is really odd. It seems to be related to some caching mechanism. @lhstrh do you have any idea why this fails? Is there a way to reset the CI cache? |
Nope. Not a Windows user... Remove the Gradle cache and try again? It looks like this PR was almost ready to merge but somehow got stuck. How do we move it forward? |
Co-authored-by: Christian Menard <[email protected]>
This reverts commit 9b5e198.
Co-authored-by: Edward A. Lee <[email protected]>
This resolves issue #449.
Clarified types of
federate_id
, which was defined as justint
notint32_t
, which could make problems on 16-bit systems.Also, change the runtime clock-synchronization after initial clock-sync, to send a 2 byte uint16_t federate_id not int32_t which is 4 bytes.
Summary by CodeRabbit
Bug Fixes
int
touint16_t
.Refactor
_lf_my_fed_id
andlf_fed_id
fromint
touint16_t
for improved clarity and performance.