[R-pkg-devel] reproducing cran warnings

Bill Dunlap w||||@mwdun|@p @end|ng |rom gm@||@com
Fri Feb 3 18:18:42 CET 2023


checking whether package ‘epanet2toolkit’ can be installed ... WARNING
Found the following significant warnings:
  report.c:1466:37: warning: argument to ‘sizeof’ in ‘snprintf’ call is the
same expression as the destination; did you mean to provide an explicit
length? [-Wsizeof-pointer-memaccess]
  report.c:1466:61: warning: ‘__builtin___snprintf_chk’ output may be
truncated before the last format character [-Wformat-truncation=]
  rules.c:1364:40: warning: argument to ‘sizeof’ in ‘snprintf’ call is the
same expression as the destination; did you mean to provide an explicit
length? [-Wsizeof-pointer-memaccess]
  rules.c:1371:43: warning: argument to ‘sizeof’ in ‘snprintf’ call is the
same expression as the destination; did you mean to provide an explicit
length? [-Wsizeof-pointer-memaccess]
  rules.c:1371:58: warning: ‘%02d’ directive output may be truncated
writing between 2 and 11 bytes into a region of size between 0 and 6
[-Wformat-truncation=]
See
https://www.r-project.org/nosvn/R.check/r-devel-linux-x86_64-debian-gcc/epanet2toolkit-00install.html
for details.


You will get these warnings if you do things like
    char *string = (char*)malloc(length);
    snprintf(string, sizeof(string), "format ...");
sizeof(string) here is 8 (on a 64 bit machine), no matter what length is.

Change this to either
   char string[64] // 64 had better be big enough
   snprintf(string, sizeof(string), "format ..");
or
   char *string = (char*)malloc(length);
   snprintf(string, length, "format ...");

-Bill


On Fri, Feb 3, 2023 at 8:28 AM Brad Eck <bradleyjeck using gmail.com> wrote:

> Dear List -
>
> What’s the latest best practice on trying to reproduce warnings raised
> on CRAN checks?
>
> I updated my epanet2toolkit package earlier this week.
> R CMD check —as-cran was clean on RHUB and Winbuilder and my local
> machines.  But on CRAN a few variations are causing warnings.
>
> For example R-devel-debian-gcc is ok on rhub
>
> https://builder.r-hub.io/status/epanet2toolkit_0.6.1.tar.gz-58c1ce1e316317307679f58450a5e17a
>
> But
> not on CRAN:
>
> https://www.r-project.org/nosvn/R.check/r-devel-linux-x86_64-debian-gcc/epanet2toolkit-00check.html
>
> Thanks in advance for any suggestions.
>
> Brad
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list