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

Replace STRING_PTR with STRING_PTR_RO #1719

Merged
merged 2 commits into from
Jun 27, 2024

Conversation

yutannihilation
Copy link
Contributor

@yutannihilation yutannihilation commented Jun 25, 2024

This is to fix one of many CRAN Notes related to newly-added "non-API"s.

Version: 1.1.4
Check: compiled code
Result: NOTE
  File ‘rlang/libs/rlang.so’:
    Found non-API calls to R: ‘ENVFLAGS’, ‘FRAME’, ‘HASHTAB’, ‘LEVELS’,
      ‘NAMED’, ‘PRENV’, ‘PRVALUE’, ‘RDEBUG’, ‘R_PromiseExpr’,
      ‘Rf_findVarInFrame3’, ‘SETLENGTH’, ‘SET_BODY’, ‘SET_CLOENV’,
      ‘SET_ENCLOS’, ‘SET_ENVFLAGS’, ‘SET_FORMALS’, ‘SET_GROWABLE_BIT’,
      ‘SET_RDEBUG’, ‘SET_TRUELENGTH’, ‘SET_TYPEOF’, ‘STRING_PTR’,
      ‘XTRUELENGTH’
  
  Compiled code should not call non-API entry points in R.

(https://cran.r-project.org/web/checks/check_results_rlang.html)

src/rlang/vec.h Outdated
@@ -47,12 +47,12 @@ const void* r_raw_cbegin(r_obj* x) {
}
static inline
r_obj* const * r_chr_cbegin(r_obj* x) {
return (r_obj* const *) STRING_PTR(x);
return (r_obj* const *) STRING_PTR_RO(x);
Copy link
Member

Choose a reason for hiding this comment

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

The cast is no longer necessary I believe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, thanks for catching!

}
static inline
r_obj* const * r_list_cbegin(r_obj* x) {
#if (R_VERSION < R_Version(3, 5, 0))
return ((r_obj* const *) STRING_PTR(x));
return ((r_obj* const *) STRING_PTR_RO(x));
#else
return ((r_obj* const *) DATAPTR_RO(x));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I remove the cast in this line for consistency?

@lionel- lionel- merged commit cebbabf into r-lib:main Jun 27, 2024
13 checks passed
@lionel-
Copy link
Member

lionel- commented Jun 27, 2024

Thanks!

@yutannihilation yutannihilation deleted the remove-non-api-STRING_PTR branch June 27, 2024 09:35
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