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 compilation error by moving _z_session_init to the right #if #220

Merged
merged 1 commit into from
Jun 22, 2023

Conversation

clachan
Copy link
Contributor

@clachan clachan commented Jun 10, 2023

A compilation error (undefined local_zid symbol) caused when neither Z_UNICAST_TRANSPORT nor Z_MULTICAST_TRANSPORT is defined. This patch fixes it.

Copy link
Member

@cguimaraes cguimaraes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to move _z_bytes_t local_zid = _z_bytes_empty(); outside the #if instead.

Like the snippet below:

int8_t __z_open_inner(_z_session_t *zn, char *locator, z_whatami_t mode) {
    int8_t ret = _Z_RES_OK;

    _z_bytes_t local_zid = _z_bytes_empty();

#if Z_UNICAST_TRANSPORT == 1 || Z_MULTICAST_TRANSPORT == 1
    ret = _z_session_generate_zid(&local_zid, Z_ZID_LENGTH);
    if (ret == _Z_RES_OK) {
        ret = _z_new_transport(&zn->_tp, &local_zid, locator, mode);
        if (ret != _Z_RES_OK) {
            _z_bytes_clear(&local_zid);
        }
    } else {
        _z_bytes_clear(&local_zid);
    }
#else
    ret = _Z_ERR_TRANSPORT_NOT_AVAILABLE;
#endif

    if (ret == _Z_RES_OK) {
        ret = _z_session_init(zn, &local_zid);
    }

    return ret;
}

A compilation error (undefined local_zid symbol) caused when neither
Z_UNICAST_TRANSPORT nor Z_MULTICAST_TRANSPORT is defined. This patch
fixes it.

Signed-off-by: Clay Chang <clay.chang@gmail.com>
@clachan
Copy link
Contributor Author

clachan commented Jun 22, 2023

I would prefer to move _z_bytes_t local_zid = _z_bytes_empty(); outside the #if instead.

Like the snippet below:

int8_t __z_open_inner(_z_session_t *zn, char *locator, z_whatami_t mode) {
    int8_t ret = _Z_RES_OK;

    _z_bytes_t local_zid = _z_bytes_empty();

#if Z_UNICAST_TRANSPORT == 1 || Z_MULTICAST_TRANSPORT == 1
    ret = _z_session_generate_zid(&local_zid, Z_ZID_LENGTH);
    if (ret == _Z_RES_OK) {
        ret = _z_new_transport(&zn->_tp, &local_zid, locator, mode);
        if (ret != _Z_RES_OK) {
            _z_bytes_clear(&local_zid);
        }
    } else {
        _z_bytes_clear(&local_zid);
    }
#else
    ret = _Z_ERR_TRANSPORT_NOT_AVAILABLE;
#endif

    if (ret == _Z_RES_OK) {
        ret = _z_session_init(zn, &local_zid);
    }

    return ret;
}

Thanks for your comments, and I have updated the patch.
Please review.

@clachan clachan requested a review from cguimaraes June 22, 2023 14:19
Copy link
Member

@cguimaraes cguimaraes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cguimaraes cguimaraes merged commit 9b663d5 into eclipse-zenoh:master Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants