ropensci / redland-bindings

Redland librdf language bindings
http://librdf.org/bindings/
Other
17 stars 3 forks source link

fix compiler warnings that CRAN is no longer tolerating #100

Closed mbjones closed 1 year ago

mbjones commented 1 year ago

Got this message from CRAN today:

Dear maintainer,

Please see the problems shown on https://cran.r-project.org/web/checks/check_results_redland.html.

Please correct before 2023-03-22 to safely retain your package on CRAN.

Best, -k

Having it removed from CRAN would impact dependent packages such as dataone and datapack. The warnings currently are:

Check Details

Version: 1.0.17-16
Check: whether package can be installed
Result: WARN
    Found the following significant warnings:
     redland.c:771:37: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
     redland.c:817:31: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
     redland.c:1846:25: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
    See ‘/home/hornik/tmp/R.check/r-devel-clang/Work/PKGS/redland.Rcheck/00install.out’ for details.
    * used C compiler: ‘Debian clang version 15.0.6’
Flavor: [r-devel-linux-x86_64-debian-clang](https://www.r-project.org/nosvn/R.check/r-devel-linux-x86_64-debian-clang/redland-00check.html)

Version: 1.0.17-16
Check: whether package can be installed
Result: WARN
    Found the following significant warnings:
     redland.c:771:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
     redland.c:817:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
     redland.c:1846:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
    See ‘/home/hornik/tmp/R.check/r-devel-gcc/Work/PKGS/redland.Rcheck/00install.out’ for details.
    * used C compiler: ‘gcc-12 (Debian 12.2.0-14) 12.2.0’
Flavor: [r-devel-linux-x86_64-debian-gcc](https://www.r-project.org/nosvn/R.check/r-devel-linux-x86_64-debian-gcc/redland-00check.html)

Version: 1.0.17-16
Check: S3 generic/method consistency
Result: WARN
    roclet_process:
     function(x, blocks, env, base_path)
    roclet_process.roclet_mergeNamespace:
     function(x, blocks, env, base_path, global_options)

    See section ‘Generic functions and methods’ in the ‘Writing R
    Extensions’ manual.
Flavors: [r-devel-linux-x86_64-debian-gcc](https://www.r-project.org/nosvn/R.check/r-devel-linux-x86_64-debian-gcc/redland-00check.html), [r-devel-linux-x86_64-fedora-gcc](https://www.r-project.org/nosvn/R.check/r-devel-linux-x86_64-fedora-gcc/redland-00check.html)

Version: 1.0.17-16
Check: whether package can be installed
Result: WARN
    Found the following significant warnings:
     redland.c:771:37: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
     redland.c:817:31: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
     redland.c:1846:25: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
    See ‘/data/gannet/ripley/R/packages/tests-clang/redland.Rcheck/00install.out’ for details.
    * used C compiler: ‘clang version 16.0.0’
Flavor: [r-devel-linux-x86_64-fedora-clang](https://www.r-project.org/nosvn/R.check/r-devel-linux-x86_64-fedora-clang/redland-00check.html)

Version: 1.0.17-16
Check: whether package can be installed
Result: WARN
    Found the following significant warnings:
     redland.c:771:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
     redland.c:817:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
     redland.c:1846:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
    See ‘/data/gannet/ripley/R/packages/tests-devel/redland.Rcheck/00install.out’ for details.
    * used C compiler: ‘gcc (GCC) 12.2.1 20221121 (Red Hat 12.2.1-4)’
Flavor: [r-devel-linux-x86_64-fedora-gcc](https://www.r-project.org/nosvn/R.check/r-devel-linux-x86_64-fedora-gcc/redland-00check.html)

Version: 1.0.17-16
Check: installed package size
Result: NOTE
     installed size is 7.7Mb
     sub-directories of 1Mb or more:
     libs 6.7Mb
Flavors: [r-oldrel-macos-arm64](https://www.r-project.org/nosvn/R.check/r-oldrel-macos-arm64/redland-00check.html), [r-oldrel-windows-ix86+x86_64](https://www.r-project.org/nosvn/R.check/r-oldrel-windows-ix86+x86_64/redland-00check.html)
mbjones commented 1 year ago

Current check() on R 4.2.2 also produces a NOTE:

❯ checking R code for possible problems ... NOTE
  Found if() conditions comparing class() to string:
  File ‘redland/R/Statement.R’: if ((is.null(subject) || class(subject) == "character") && class(predicate) == "character" && (is.null(object) || class(object) == "character")) ...
  File ‘redland/R/util.R’: if (class(pointer) != "externalptr") ...
  Use inherits() (or maybe is()) instead.

I fixed this using inherits() rather than the buggy string comparison. So now we change (class(subject) == "character") to inherits(subject, "character"). I merged this to develop in sha a8e6d127, but there is still more to do on the other warnings.

mbjones commented 1 year ago

Another WARNING has been because roxygen2 7.0.0 changed its method signature for process_roclet to remove the global_options argument, which is a backwards incompatible change. Possibly to be fixed by changing our signature as well. Needs investigation.

mbjones commented 1 year ago

The folks at CRAN release a new version (1.0.17-16.1) which patches the void problems that we were having with redland.c. Here's what they changed, which I will incorporate into the next release:

--- redland.c   2023-05-22 17:20:49.000000000 -0800
+++ ../../redland-1.0.17-16.1/src/redland.c 2023-05-13 00:47:08.000000000 -0800
@@ -768,7 +768,7 @@

 SWIGRUNTIME SEXP
-R_SWIG_debug_getCallbackFunctionData()
+R_SWIG_debug_getCallbackFunctionData(void)
 {
   int n, i;
   SEXP ans;
@@ -814,7 +814,7 @@
 }

 SWIGRUNTIME RCallbackFunctionData *
-R_SWIG_getCallbackFunctionData()
+R_SWIG_getCallbackFunctionData(void)
 {
   if(!callbackFunctionDataStack) {
     Rf_error("Supposedly impossible error occurred in the SWIG callback mechanism."
@@ -1843,7 +1843,7 @@

 SWIGEXPORT SEXP
-R_swig_librdf_new_world ( )
+R_swig_librdf_new_world ( void)
 {
   librdf_world *result = 0 ;
   unsigned int r_nprotect = 0;
mbjones commented 1 year ago

Trying to fix the roclet signature change described above by removing the global_options param, which wasn't used anyways and is no longer in process_roclet:

diff --git a/R/redland/R/mergeNamespace_roclet.R b/R/redland/R/mergeNamespace_roclet.R
index 9e10c19..f802333 100644
--- a/R/redland/R/mergeNamespace_roclet.R
+++ b/R/redland/R/mergeNamespace_roclet.R
@@ -52,9 +52,8 @@ mergeNamespace_roclet <- function(x, ...) {
 #' @param blocks the documentation blocks
 #' @param env the current env
 #' @param base_path the top directory of the R package
-#' @param global_options unused by this roclet
 #' @export
-roclet_process.roclet_mergeNamespace <- function(x, blocks, env, base_path, global_options = list()) {
+roclet_process.roclet_mergeNamespace <- function(x, blocks, env, base_path) {
   #on.exit(detach(".redland-temp"))
   #attach(NULL, name=".redland-temp")
   tmpEnv <- new.env()
mbjones commented 1 year ago

Had to remove the global_options param from the Rd file as well, then that worked. So, documentation now is updated, but note that we currently can't run the doc generation from document() due to errors with the SWIG doc generation. Will have to open a new issue for this later.

mbjones commented 1 year ago

All problems are now fixed, ready to close if the release is accepted.