Skip to content

Commit

Permalink
[C] Fix var-args bug in error reporting.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeb01 committed Jan 20, 2025
1 parent c584db8 commit c9ca580
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions aeron-driver/src/main/c/uri/aeron_driver_uri.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ int aeron_uri_get_publication_window_length_param(aeron_uri_params_t *uri_params
{
AERON_SET_ERR(
EINVAL,
"%s=" PRIu64 " cannot be less than the %s=" PRIu64,
"%s=%" PRIu64 " cannot be less than the %s=%" PRIu64,
AERON_URI_PUBLICATION_WINDOW_KEY,
value,
AERON_URI_MTU_LENGTH_KEY,
Expand All @@ -137,7 +137,7 @@ int aeron_uri_get_publication_window_length_param(aeron_uri_params_t *uri_params
{
AERON_SET_ERR(
EINVAL,
"%s=" PRIu64 " must not exceed half the %s=" PRIu64,
"%s=%" PRIu64 " must not exceed half the %s=%" PRIu64,
AERON_URI_PUBLICATION_WINDOW_KEY,
value,
AERON_URI_TERM_LENGTH_KEY,
Expand Down
18 changes: 18 additions & 0 deletions aeron-driver/src/test/c/aeron_driver_uri_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,24 @@ TEST_F(DriverUriTest, shouldFailWithInvalidMaxRetransmits)
EXPECT_THAT(std::string(aeron_errmsg()), ::testing::HasSubstr("could not parse max-resend"));
}

TEST_F(DriverUriTest, shouldFailWithPublicationWindowLessThanMtu)
{
aeron_driver_uri_publication_params_t params;

EXPECT_EQ(AERON_URI_PARSE("aeron:udp?endpoint=224.10.9.8|pub-wnd=2048|mtu=4096", &m_uri), 0);
EXPECT_EQ(aeron_diver_uri_publication_params(&m_uri, &params, &m_conductor, false), -1);
EXPECT_THAT(std::string(aeron_errmsg()), ::testing::HasSubstr("pub-wnd=2048 cannot be less than the mtu=4096"));
}

TEST_F(DriverUriTest, shouldFailWithPublicationWindowMoreThanHalfTermLength)
{
aeron_driver_uri_publication_params_t params;

EXPECT_EQ(AERON_URI_PARSE("aeron:udp?endpoint=224.10.9.8|pub-wnd=262144|term-length=65536", &m_uri), 0);
EXPECT_EQ(aeron_diver_uri_publication_params(&m_uri, &params, &m_conductor, false), -1);
EXPECT_THAT(std::string(aeron_errmsg()), ::testing::HasSubstr("pub-wnd=262144 must not exceed half the term-length=65536"));
}

class UriResolverTest : public testing::Test
{
public:
Expand Down

0 comments on commit c9ca580

Please sign in to comment.