Skip to content

Commit

Permalink
Merge pull request #1240 from RcppCore/feature/clang_conversion_warnings
Browse files Browse the repository at this point in the history
Address clang conversion warnings
  • Loading branch information
eddelbuettel authored Jan 9, 2023
2 parents 50a9585 + a15398c commit 39669cb
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 40 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ jobs:
- name: Check
run: docker run --rm -i -v ${PWD}:/mnt -w /mnt -e CI=true ${{ matrix.cntr }} ${{ matrix.r }} CMD check --no-vignettes --no-manual Rcpp_*.tar.gz

covr:
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v3

- name: Container
run: docker pull rcpp/ci

- name: Coverage
run: docker run --rm -i -v ${PWD}:/mnt -w /mnt -e CODECOV_TOKEN=${{secrets.CODECOV_TOKEN }} rcpp/ci r -l covr -e 'codecov()'
#covr:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout Project
# uses: actions/checkout@v3
#
# - name: Container
# run: docker pull rcpp/ci
#
# - name: Coverage
# run: docker run --rm -i -v ${PWD}:/mnt -w /mnt -e CODECOV_TOKEN=${{secrets.CODECOV_TOKEN }} rcpp/ci r -l covr -e 'codecov()'
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
2023-01-08 Dirk Eddelbuettel <edd@debian.org>

* inst/include/Rcpp/String.h: Address clang++-14 conversion warning
* inst/include/Rcpp/sugar/functions/mean.h: Idem
* inst/include/Rcpp/vector/Vector.h: Idem
* src/attributes.cpp: Idem
* src/date.cpp: Idem

2022-12-29 Dirk Eddelbuettel <edd@debian.org>

* .github/workflows/docker.yaml (jobs): Update several actions
Expand Down
4 changes: 2 additions & 2 deletions inst/include/Rcpp/String.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// String.h: Rcpp R/C++ interface class library -- single string
//
// Copyright (C) 2012 - 2020 Dirk Eddelbuettel and Romain Francois
// Copyright (C) 2021 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar
// Copyright (C) 2021 - 2023 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar
//
// This file is part of Rcpp.
//
Expand Down Expand Up @@ -550,7 +550,7 @@ namespace Rcpp {
#else
if (buffer.find('\0') != std::string::npos)
throw embedded_nul_in_string();
return Rf_mkCharLenCE(buffer.c_str(), buffer.size(), enc);
return Rf_mkCharLenCE(buffer.c_str(), static_cast<int>(buffer.size()), enc);
#endif
}

Expand Down
10 changes: 3 additions & 7 deletions inst/include/Rcpp/sugar/functions/mean.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
//
// mean.h: Rcpp R/C++ interface class library -- mean
//
// Copyright (C) 2011 - 2015 Dirk Eddelbuettel and Romain Francois
// Copyright (C) 2011 - 2023 Dirk Eddelbuettel and Romain Francois
//
// This file is part of Rcpp.
//
Expand Down Expand Up @@ -80,8 +78,8 @@ class Mean<CPLXSXP,NA,T> : public Lazy<Rcomplex, Mean<CPLXSXP,NA,T> > {
si += ti/n;
}
Rcomplex z;
z.r = s;
z.i = si;
z.r = static_cast<double>(s);
z.i = static_cast<double>(si);
return z;
}
private:
Expand Down Expand Up @@ -158,5 +156,3 @@ inline sugar::Mean<LGLSXP,NA,T> mean(const VectorBase<LGLSXP,NA,T>& t) {

} // Rcpp
#endif


5 changes: 2 additions & 3 deletions inst/include/Rcpp/vector/Vector.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//
// Vector.h: Rcpp R/C++ interface class library -- vectors
//
// Copyright (C) 2010 - 2022 Dirk Eddelbuettel and Romain Francois
// Copyright (C) 2010 - 2023 Dirk Eddelbuettel and Romain Francois
//
// This file is part of Rcpp.
//
Expand Down Expand Up @@ -332,7 +331,7 @@ class Vector :
}

inline iterator begin() { return cache.get() ; }
inline iterator end() { return cache.get() + size() ; }
inline iterator end() { return cache.get() + static_cast<int>(size()) ; }
inline const_iterator begin() const{ return cache.get_const() ; }
inline const_iterator end() const{ return cache.get_const() + size() ; }
inline const_iterator cbegin() const{ return cache.get_const() ; }
Expand Down
5 changes: 2 additions & 3 deletions src/attributes.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//
// attributes.cpp: Rcpp R/C++ interface class library -- Rcpp attributes
//
// Copyright (C) 2012 - 2020 JJ Allaire, Dirk Eddelbuettel and Romain Francois
// Copyright (C) 2021 - 2022 JJ Allaire, Dirk Eddelbuettel, Romain Francois, Iñaki Ucar and Travers Ching
// Copyright (C) 2021 - 2023 JJ Allaire, Dirk Eddelbuettel, Romain Francois, Iñaki Ucar and Travers Ching
//
// This file is part of Rcpp.
//
Expand Down Expand Up @@ -1622,7 +1621,7 @@ namespace attributes {
// Look for the signature termination ({ or ; not inside quotes)
// on this line and then subsequent lines if necessary
std::string signature;
for (int i = lineNumber; i<lines_.size(); i++) {
for (size_t i = lineNumber; i<lines_.size(); i++) {
std::string line;
line = lines_[i];
bool insideQuotes = false;
Expand Down
26 changes: 12 additions & 14 deletions src/date.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

//
// Date.cpp: Rcpp R/C++ interface class library -- Date type
//
// Copyright (C) 2010 - 2019 Dirk Eddelbuettel and Romain Francois
// Copyright (C) 2010 - 2023 Dirk Eddelbuettel and Romain Francois
//
// The mktime00() as well as the gmtime_() replacement function are
// Copyright (C) 2000 - 2010 The R Development Core Team.
Expand Down Expand Up @@ -85,10 +83,10 @@ namespace Rcpp {
/* safety check for unbounded loops */
if (year0 > 3000) {
excess = (int)(year0/2000) - 1; // #nocov start
year0 -= excess * 2000;
year0 -= (int)(excess * 2000);
} else if (year0 < 0) {
excess = -1 - (int)(-year0/2000);
year0 -= excess * 2000; // #nocov end
year0 -= (int)(excess * 2000); // #nocov end
}

for(i = 0; i < tm.tm_mon; i++) day += days_in_month[i];
Expand Down Expand Up @@ -450,7 +448,7 @@ struct tzhead {
** Normalize logic courtesy Paul Eggert.
*/

static int increment_overflow(int *const ip, int j) {
static int increment_overflow(int *const ip, int j) {
int const i = *ip;

/*
Expand All @@ -460,7 +458,7 @@ struct tzhead {
** or if j < INT_MIN - i; given i < 0, INT_MIN - i cannot overflow.
*/
if ((i >= 0) ? (j > INT_MAX - i) : (j < INT_MIN - i))
return TRUE; // #nocov
return TRUE; // #nocov
*ip += j;
return FALSE;
}
Expand All @@ -476,10 +474,10 @@ struct tzhead {
: *tp <= time_t_max - j))
return TRUE;
*tp += j;
return FALSE;
return FALSE;
}

static int_fast32_t detzcode(const char *const codep) {
static int_fast32_t detzcode(const char *const codep) {
int_fast32_t result = (codep[0] & 0x80) ? -1 : 0;
for (int i = 0; i < 4; ++i)
result = (result << 8) | (codep[i] & 0xff);
Expand Down Expand Up @@ -628,7 +626,7 @@ struct tzhead {
return strp;
}

// this routine modified / simplified / reduced in 2010
// this routine modified / simplified / reduced in 2010
static int tzload(const char * name, struct state * const sp, const int doextend) {
const char * p;
int i;
Expand Down Expand Up @@ -701,7 +699,7 @@ struct tzhead {
}

}
nread = read(fid, u.buf, sizeof u.buf);
nread = (int)read(fid, u.buf, sizeof u.buf);
if (close(fid) < 0 || nread <= 0)
return -1;
for (stored = 4; stored <= 8; stored *= 2) {
Expand Down Expand Up @@ -851,7 +849,7 @@ struct tzhead {
while (i < ts.timecnt &&
sp->timecnt < TZ_MAX_TIMES) {
sp->ats[sp->timecnt] = ts.ats[i];
sp->types[sp->timecnt] = sp->typecnt + ts.types[i];
sp->types[sp->timecnt] = (unsigned char)sp->typecnt + ts.types[i];
++sp->timecnt;
++i;
}
Expand Down Expand Up @@ -1217,7 +1215,7 @@ struct tzhead {
&sp->chars[bp->tt_abbrind]) == 0;
}
return result;
} // #nocov end
} // #nocov end

static int leaps_thru_end_of(const int y) {
return (y >= 0) ? (y / 4 - y / 100 + y / 400) :
Expand Down Expand Up @@ -1316,7 +1314,7 @@ struct tzhead {
}
// Previously we returned 'year + base', so keep behaviour
// It seems like R now returns just 'year - 1900' (as libc does)
// But better for continuity to do as before
// But better for continuity to do as before
tmp->tm_year = y + TM_YEAR_BASE;
if (increment_overflow(&tmp->tm_year, -TM_YEAR_BASE))
return NULL; // #nocov
Expand Down

0 comments on commit 39669cb

Please sign in to comment.