Skip to content

Use do-while(0) to protect ADJUST_INDICES macro #121165

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

Closed
picnixz opened this issue Jun 29, 2024 · 0 comments
Closed

Use do-while(0) to protect ADJUST_INDICES macro #121165

picnixz opened this issue Jun 29, 2024 · 0 comments
Labels
type-feature A feature request or enhancement

Comments

@picnixz
Copy link
Member

picnixz commented Jun 29, 2024

Feature or enhancement

Proposal:

Use do-while(0) construction to protect the expansion of ADJUST_INDICES in:

  • #define ADJUST_INDICES(start, end, len) \
    if (end > len) \
    end = len; \
    else if (end < 0) { \
    end += len; \
    if (end < 0) \
    end = 0; \
    } \
    if (start < 0) { \
    start += len; \
    if (start < 0) \
    start = 0; \
    }
  • #define ADJUST_INDICES(start, end, len) \
    if (end > len) \
    end = len; \
    else if (end < 0) { \
    end += len; \
    if (end < 0) \
    end = 0; \
    } \
    if (start < 0) { \
    start += len; \
    if (start < 0) \
    start = 0; \
    }

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants